ruby-on-rails – 大型机器上的Rails应用程序只能获得60个请求秒的基准测试结果

ruby-on-rails – 大型机器上的Rails应用程序只能获得60个请求秒的基准测试结果,第1张

概述我正在一台强大的机器上托管一个Rails应用程序 – 我认为 – 它应该能够处理比我给它更高的负载.以下是ApacheBench令人印象深刻的测试结果: ab -kc 250 -n 1000 -H "Accept-Encoding: gzip,deflate" https://www.mysite.com/Server Software: nginx/1.0.15Server 我正在一台强大的机器上托管一个Rails应用程序 – 我认为 – 它应该能够处理比我给它更高的负载.以下是ApacheBench令人印象深刻的测试结果:

ab -kc 250 -n 1000 -H "Accept-EnCoding: gzip,deflate" https://www.mysite.com/Server Software:        Nginx/1.0.15Server Hostname:        www.mysite.comServer Port:            443SSL/TLS Protocol:       TLSv1/SSLv3,DHE-RSA-AES256-SHA,2048,256document Path:          /document Length:        4258 bytesConcurrency Level:      250Time taken for tests:   16.498 secondsComplete requests:      1000HTML transferred:       4258000 bytesRequests per second:    60.61 [#/sec] (mean)Time per request:       4124.432 [ms] (mean)Time per request:       16.498 [ms] (mean,across all concurrent requests)Transfer rate:          282.83 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:      302 1801 866.3   1623    3583Processing:   183 1993 867.9   1873    7050Waiting:      183 1880 864.2   1743    7036Total:       1397 3794 1389.0   3558   10580Percentage of the requests served within a certain time (ms)  50%   3558  66%   4012  75%   4179  80%   4712  90%   4947  95%   6411  98%   8376  99%   8380 100%  10580 (longest request)

呸.也许我错了,但我觉得我应该能够获得远高于每秒60个请求的数量,并且每次请求的时间要低得多于4.1秒.

该应用程序位于c1.xlarge EC2实例(7 GB内存20 EC2计算单元,8个虚拟核心,每个2.5 EC2计算单元,1690 GB实例存储64位平台,I / O性能:高). ApacheBench基准测试运行的站点根目录正在进行 *** 作缓存,甚至不会触及数据库.对它的单个请求如下所示:

Started GET "/" for ##.###.###.## at Thu Apr 19 13:05:50 +0000 2012  Processing by OneOfMyControllers#index as HTML  Read fragment vIEws/www.mysite.com/index (1.1ms)  Completed 200 OK in 2ms

该机器正在运行Ubuntu 11.04,我正在使用Rails 3.1,Ruby Enterprise Edition,Passenger和Nginx.我的Nginx配置看起来像这样:

worker_processes  8;worker_rlimit_nofile 65535;events {    worker_connections 4096;}http {    passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-3.0.8;    passenger_ruby /usr/bin/ruby1.8;    rails_spawn_method smart;    rails_app_spawner_IDle_time 0;    rails_framework_spawner_IDle_time 0;    passenger_max_pool_size 60;    passenger_pool_IDle_time 1000;    ssl_session_cache shared:SSL:3m;  # 3MB can hold about 12k SSL cache sessions    ssl_session_timeout 5m; # average user spends 5 minutes on our site    include       mime.types;    default_type  application/octet-stream;    sendfile       on;    tcp_nopush     on; # useful with the sendfile option    tcp_nodelay    off;     keepalive_timeout     10;    send_timeout          10;    clIEnt_body_timeout   10;    clIEnt_header_timeout 10;    gzip              on;    gzip_static       on;    gzip_disable      "MSIE [1-6]\.";    gzip_comp_level   4;    gzip_buffers      16 4k;    gzip_min_length   1000;    gzip_proxIEd      any;    gzip_vary         on;    gzip_types        text/plain text/CSS application/Json application/x-JavaScript text/xml application/xml application/xml+RSS text/JavaScript;    gzip_http_version 1.0; # Amazon CloudFront uses http/1.0                                                include /opt/Nginx/conf/sites-enabled/*;}

在/opt/Nginx/conf/sites-enabled/mysite.com里面,我得到了:

server {    Listen         80;    server_name    mysite.com;    rewrite ^/(.*) http://www.mysite.com/ permanent;}server {    Listen         443;    ssl            on;    server_name    mysite.com;    ssl_certificate           /opt/mysite/ssl/wildcard_gandi_2012/combined-certification.crt;    ssl_certificate_key       /opt/mysite/ssl/wildcard_gandi_2012/monserveur.key;    ssl_protocols             SSLv3 TLSv1;    ssl_ciphers               HIGH:!ADH:!MD5;    ssl_prefer_server_ciphers on;    rewrite ^/(.*) https://www.mysite.com/ permanent;}server {    Listen            80;    server_name       *.mysite.com www.mysite.com;    root /opt/mysite/public;    passenger_enabled on;    access_log  /opt/mysite/log/Nginx_access.log;    error_log   /opt/mysite/log/Nginx_error.log;    # Set the maximum file upload size to 25 MB.    clIEnt_max_body_size 25M;}server {    Listen            443;    ssl               on;    server_name       *.mysite.com www.mysite.com;    ssl_certificate           /opt/mysite/ssl/wildcard_gandi_2012/combined-certification.crt;    ssl_certificate_key       /opt/mysite/ssl/wildcard_gandi_2012/monserveur.key;    ssl_protocols             SSLv3 TLSv1;    ssl_ciphers               HIGH:!ADH:!MD5;    ssl_prefer_server_ciphers on;    root /opt/mysite/public;    passenger_enabled on;    access_log  /opt/mysite/log/Nginx_access.log;    error_log   /opt/mysite/log/Nginx_error.log;    # Set the maximum file upload size to 25 MB.    clIEnt_max_body_size 25M;    # Asset caching    location ~ ^/(assets)/  {        root /opt/mysite/public;        gzip_static on;        access_log off;        expires 1y;        add_header Cache-Control public;        add_header Last-ModifIEd "";        add_header ETag "";        break;    }}

知道为什么我不能获得超过60个请求/秒?我有什么明显的东西可以忽略吗?

解决方法 我怀疑你的一个重大问题是https.

我刚刚运行了一些比较基准测试,对我来说,他们在这样一个非常基本的页面上显示速度降低了2-4倍.如果您点击http页面,您的指标会增加吗?

还要检查您的乘客状态(rvmsudo passenger-status)以检查是否已加载所有进程并均匀地在其中分配请求.

总结

以上是内存溢出为你收集整理的ruby-on-rails – 大型机器上的Rails应用程序只能获得60个请求/秒的基准测试结果全部内容,希望文章能够帮你解决ruby-on-rails – 大型机器上的Rails应用程序只能获得60个请求/秒的基准测试结果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1267127.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-08
下一篇2022-06-08

发表评论

登录后才能评论

评论列表(0条)

    保存