Thursday, November 14, 2013

Rails APACHE, NGINX, UNICORN, THIN Deployment

Comparison of APACHE and NGINX web servers. 

I am a rails web developer and always wanted to know what is the best possible way to deploy a rails web site.

I searched a lot on google and got an answers that says use NGINX for mostly static web sites.          

Use APACHE + PASSANGER as easy deployment tool.and some web pages says that use THIN server.  

Finally i deployed one product based web site to test this and tried to find out which the fastest web server i can use.

When hosted with APACHE and tested with APACHE benchmark tool i got the following output.

Server Software:
Server Hostname: 178.63.19.197
Server Port: 80  
Document Path: /index.html
Document Length: 5907 bytes

Concurrency Level: 5  
Time taken for tests: 151.297 seconds
Complete requests: 1000
Failed requests: 0  
Write errors: 0
Non-2xx responses: 1002  
Total transferred: 6197440 bytes
HTML transferred: 5917882 bytes
Requests per second: 6.61 [#/sec] (mean)
Time per request: 756.487 [ms] (mean)  
Time per request: 151.297 [ms] (mean, across all concurrent requests)
Transfer rate: 40.00 [Kbytes/sec] received

Percentage of the requests served within a certain time (ms)
50% 522
66% 540
75% 559
80% 587
90% 1117
95% 2002
98% 3532
99% 3757
100% 17908 (longest request)  

When hosted with NGINX i got the following output

Server Software: NGINX
Server Hostname: 178.63.19.197
Server Port: 80
Document Path: /index.html
Document Length: 5907 bytes  

Concurrency Level: 5
Time taken for tests: 145.200 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1002  
Total transferred: 6197550 bytes
HTML transferred: 5917552 bytes
Requests per second: 5.61 [#/sec] (mean)
Time per request: 754.487 [ms] (mean)
Time per request: 150.297 [ms] (mean, across all concurrent requests)
Transfer rate: 42.00 [Kbytes/sec] received  

Percentage of the requests served within a certain time (ms)
50% 522
66% 530
75% 559
80% 587
90% 1117 95% 2002
98% 3531
99% 3757
100% 17905 (longest request)

By comparing this i can say that both are same but actually sometime it may be depend on network speed to complete a request.

On the server there is 25 gb of ram from which hardly 0.3% is used to run an UNICORN worker at a time. for test i have created 5 unicorn workers.The cpu  is i7 cpu with 2.67GHZ.which has 8 siblings.

For cpu also i seen just a 0.7% is used when serving a request. This is for both for APACHE as well as NGINX.

Let me know your thoughts on which server should i prefer APACHE+PASSANGER, NGINX+PASSANGER, NGINX+UNICORN, APACHE+UNICORN. Or any other choice for fastest rails deployment.

No comments:

Post a Comment