简体   繁体   中英

Ruby Concurrency + Scaling with Rails

We have a social networking site runs with,

Stunnel->Haproxy->Nginx->Unicorn

We have 20 unicorn processes running in a 24 core machine.

When i run the tests with 200 requests and 100 concurrent users it takes,

50% requests takes 3694 seconds
66% requests takes 4524 seconds
75% requests takes 5444 seconds
80% requests takes 5923 seconds
90% requests takes 7676 seconds
95% requests takes 10007 seconds
98% requests takes 13841 seconds
99% requests takes 18110 seconds
100% requests takes 21987 seconds

I see in Log that each request take 0.5 seconds to complete, but the last request to complete it takes 21 secs.

How to make all requests to complete within minimum time(4-5 secs)? Should i work at my rails code to make it within 0.10 sec or is there any way I can change my server configuration for making all the requests to complete within 5 secs?

remember that each unicorn instance eats ~250Mb RAM

so 20 unicorns need at least 5 Gb RAM. If you overload RAM limit - they start work extremly slow: hibernate and wake up processes with reloading Rails environments

try to reduce count of unicorn servers and make tests

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM