Eventmachine的性能测试

Reactor pattern的实现目前有如下几个 写道

Implementations

The ADAPTIVE Communication Environment (C++)
xSocket (Java)
Apache MINA (Java)
POE (Perl)
Twisted (Python)
EventMachine (Ruby)


JE中有篇文章介绍了Eventmachine,请参见 http://dustin.iteye.com/blog/223664

服务端:
硬件:DELL1950,2*4CPU,8G内存
操作系统:
引用
[root@PerfTestApp3 ~]# uname -a
Linux PerfTestApp3 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux


服务端EM的代码:
require 'rubygems'
require 'eventmachine'

module Echo
  def receive_data data
    send_data data+"-Agent : EventMachine"
    puts data 
  end
end

EM.run {
  EM.start_server "0.0.0.0", 3080, Echo
}

服务端单进程方式启动

客户端:
Loadrunner直接请求,代码如下:

Action()
{
    web_reg_find("Text=Hello!",
                 "Search=All",
                 LAST);

    web_custom_request("EM", "Method=POST", 
       "URL=http://10.2.226.39:3080/",
       "Body=Hello!" ,
       LAST); 

	return 0;
}


TPS最高是1200,不稳定,如图:




TPS1200时的系统资源如下:
引用
top - 14:43:38 up 25 days,  3:55,  3 users,  load average: 0.13, 0.25, 0.16
Tasks: 112 total,   1 running, 111 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.1% us,  2.1% sy,  0.0% ni, 93.8% id,  0.0% wa,  0.1% hi,  0.0% si
Mem:   8306064k total,  7201996k used,  1104068k free,   236304k buffers
Swap:  2031608k total,        0k used,  2031608k free,  6028396k cached

  PID USER      PR  NI %CPU    TIME+  %MEM  VIRT  RES  SHR S COMMAND                                                               
13011 alisoft   25   0   20 315:19.60  6.9 1543m 561m  51m S java                                                                  
9565 root      16   0   20   2:38.57  0.1 15628  10m 2148 S ruby                                                                  
9146 root      16   0    9   1:15.67  0.0  8860 2356 1844 S sshd 


服务器的并发连接情况如下:

引用
[root@PerfTestApp3 ~]# netstat -an |grep 3080
tcp        0      0 0.0.0.0:3080                0.0.0.0:*                   LISTEN     
tcp        0    292 10.2.226.39:3080            10.2.226.15:45249           ESTABLISHED
tcp        0    292 10.2.226.39:3080            10.2.226.15:45251           ESTABLISHED
tcp        0      1 10.2.226.39:3080            10.2.226.15:45260           LAST_ACK   
tcp        0    292 10.2.226.39:3080            10.2.226.15:45256           ESTABLISHED
tcp        0      0 10.2.226.39:3080            10.2.226.15:45268           ESTABLISHED
tcp        0    292 10.2.226.39:3080            10.2.226.15:45277           ESTABLISHED
tcp        0    292 10.2.226.39:3080            10.2.226.15:45278           ESTABLISHED
tcp        0      0 10.2.226.39:3080            10.2.226.15:45279           ESTABLISHED
[root@PerfTestApp3 ~]# netstat -an |grep 3080 | grep ESTABLISHED -c
11
[root@PerfTestApp3 ~]# netstat -an |grep 3080 | grep ESTABLISHED -c
9
[root@PerfTestApp3 ~]# netstat -an |grep 3080 | grep ESTABLISHED -c
9
[root@PerfTestApp3 ~]#


可见平均10个并发。

再做一个单EventMachine实例支持最大并发连接数测试

还是上面那个Eventmachine实例,客户端的并发从50开始,每分钟递增50个,看最大的并发数到多少还可以支撑。

结果是250并发的时候就降下来了,然后失去响应。看图:




你可能感兴趣的:(linux,Ruby,Mina,rubygems,loadrunner)