Session
当选用持久服务(-p选项)支持HTTP session时,来自同一IP地址的请求将被送到同一台服务器。所以在这种状况下,一个ab生成的请求都会被调度到一台服务器,达不到性能测试的目的。在真实系统使用中,持久服务时间一般设置好几个小时。 当ldirectord监测到并且在列表中删除一台应用服务器时,之前有建立连接的,继续转发到这台机上,确实是这样。因为IPVS并不立即淘汰刚删除的服务器,考虑到服务器太忙被删除,可能很快会被加回来。如果你需要马上淘汰已删除服务器的连接,可以用 echo 1 > /proc/sys/net/ipv4/vs/expire_nodest_conn 不用担心记录连接所消耗的内存,因为一个连接只占用128个字节,所以512M可用内存可以支持四百万条连接数。 可以考虑用分布式的测试工具,或者多台机器一起跑ab。
ssh
neo@ubuntu:~$ sudo apt-get install ssh
network
neo@ubuntu:~$ sudo ifconfig eth0 172.16.0.250 neo@ubuntu:~$ sudo route add default gw 172.16.0.254
install ipvsadm
neo@ubuntu:~$ apt-cache search ipvsadm ipvsadm - Linux Virtual Server support programs neo@ubuntu:~$ sudo apt-get install ipvsadm Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: heartbeat keepalived ldirectord The following NEW packages will be installed: ipvsadm 0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded. Need to get 0B/43.9kB of archives. After unpacking 238kB of additional disk space will be used. Preconfiguring packages ... Selecting previously deselected package ipvsadm. (Reading database ... 16572 files and directories currently installed.) Unpacking ipvsadm (from .../ipvsadm_1.24+1.21-1.1ubuntu3_i386.deb) ... Setting up ipvsadm (1.24+1.21-1.1ubuntu3) ... neo@ubuntu:~$
test
neo@ubuntu:~$ sudo ipvsadm IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn neo@ubuntu:~$
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。