乘客托管的Rails应用*痛苦*缓慢,但是服务器是野兽 [英] Passenger hosted Rails app *painfully* slow, but the server is a beast

查看:73
本文介绍了乘客托管的Rails应用*痛苦*缓慢,但是服务器是野兽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力部署一个相对较大的Rails应用程序(Rails 2.3.5),最近进行了一些负载测试,我们发现该站点的吞吐量远低于预期的流量水平.

I have been working to deploy a relatively large Rails app (Rails 2.3.5) and recently doing some load testing we discovered that the throughput for the site is way below the expected level of traffic.

我们在标准的32位服务器上运行,具有Centos的3GB RAM,并且在运行Ruby Enterprise Edition(最新版本),Passenger(最新版本)和Nginx(最新版本)时-当只有一个或两个用户时该站点运行正常(如您所料),但是当我们尝试将负载增加到约50个并发请求时,该站点将完全消失. (Apache Bench报告〜2.3 req/sec,这很糟糕)

We were running on a standard 32bit server, 3GB of RAM with Centos, and we were running Ruby Enterprise Edition (latest build), Passenger (Latest build) and Nginx (Latest build) - when there is only one or two users the site runs fine (as you would expect) however when we try to ramp up the load to ~50 concurrent requests it completely dies. (Apache Bench report ~2.3 req/sec, which is terrible)

我们正在运行RPM并尝试确定负载问题在哪里,但是它在Rails,SQL和Memcached中分布相当均匀,因此我们或多或少地进行了代码库的优化.

We are running RPM and trying to determine where the load issue is, but it's pretty evenly distributed across Rails, SQL and Memcached, so we're more or less going through and optimizing the codebase.

出于绝望,我们启动了一个大型EC2实例(Ubuntu 9.10、7.5GB RAM,2个计算单元/内核),并设置了与原始服务器相同的配置,尽管有更多的资源,但我们仍然看到可悲的结果

Out of sheer desperation we spun up a large EC2 instance (Ubuntu 9.10, 7.5GB RAM, 2 Compute Units/Cores) and setup the same configuration as the original server, and while there are more resources we were still seeing pathetic results.

因此,在花了太多时间尝试进行优化,使用缓存配置等之后,我决定测试某些mongrels和ta-da的吞吐量,它们的性能要比Passenger好得多.

So, after spending too much time trying to optimize, playing with caching configuration etc I decided to test the throughput of some mongrels, and ta-da, they are performing much much better then Passenger.

当前配置是通过Nginx代理的15x Mongrels,我们似乎满足了我们的负载要求 just ,但这还不足以使我对上线感到满意...我想知道的是是不是有人知道导致这种情况的某些原因??

Currently the configuration is 15x Mongrels being proxied via Nginx, and we seem to be meeting our load requirements just but it's not quite enough to make me comfortable with going live... What I was wondering is if anyone knows of some possible causes for this...?

我对passenger/nginx的配置是:

My configuration for passenger/nginx was:

  • Nginx工人:尝试了1到10之间,但通常是3人.
  • 乘客可容纳的最大人数:10-30(是的,这些数字很高)
  • 乘客全局排队:尝试开启和关闭.
  • 开启NGinx GZip:是

需要注意的是,我们已经将nginx最大客户端主体的大小增加到200m,以允许上传大文件.

It might pay to note that we had increased the nginx max client body size to 200m to allow for large file uploads.

无论如何,建议都会得到真正的赞赏,尽管杂种动物工作得很好,但它改变了我们的工作方式,我真的更喜欢使用乘客-此外,不是应该这样做吗?更容易并且表现更好?

Anyway suggestions would be really appreciated, while the mongrels are working fine it changes how we do things a lot and I would really prefer to use Passenger - besides, wasn't it supposed to make this easier and perform better?

推荐答案

也许您的sql池大小太小?这从本质上限制了应用程序中数据库工作负载的并行性,一旦将工作放到应用程序堆栈上,反过来又会大大增加负载……

Maybe your sql pool size is too small? This essentially limits the parallelism of database workloads in your application which in turn builds up to much increased load as soon as you put work on your app stack...

这篇关于乘客托管的Rails应用*痛苦*缓慢,但是服务器是野兽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆