Few days back I got an assignment to configure Ngnix web server which can handle 100k requests per minute. To complete this task I take a Ubuntu system with 4 CPU and 8 GB of memory and start configuration like below.
1. Install Nginx Web server
This is optional steps if you don’t have installed Nginx on your system.
Install on Ubuntu/Debian/ Linuxmint
$ sudo apt-get install nginx
Install on CentOS / RHEL / Fedora
# yum install nginx
2. Tune Nginx Configuration File
Now edit Nginx configuration /etc/nginx/nginx.conf and make change in following values. In below configuration only changed parameters are showing.
worker_processes 8; # no of cpu * 2 worker_rlimit_nofile 50000; events { worker_connections 20000; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_requests 100; #keepalive_timeout 65; open_file_cache max=100; gzip off; access_log off; types_hash_max_size 2048; }
3. Restart Nginx and Test Load
After making all above changes just restart Nginx service using following command.
# service nginx restart
Now use Apache Benchmark tool for testing load. I have uploaded a file on server of 50Kb and hits it by 100k times.
# ab -n 100000 -c 500 http://11.22.33.44/mypage.html
This is ApacheBench, Version 2.3 <$Revision: 1528965 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 11.22.33.44 (be patient) Completed 10000 requests Completed 20000 requests Completed 30000 requests Completed 40000 requests Completed 50000 requests Completed 60000 requests Completed 70000 requests Completed 80000 requests Completed 90000 requests Completed 100000 requests Finished 100000 requests Server Software: nginx/1.4.6 Server Hostname: 11.22.33.44 Server Port: 80 Document Path: /mypage.html Document Length: 53339 bytes Concurrency Level: 500 Time taken for tests: 43.570 seconds Complete requests: 100000 Failed requests: 0 Total transferred: 5358300000 bytes HTML transferred: 5333900000 bytes Requests per second: 2295.18 [#/sec] (mean) Time per request: 217.848 [ms] (mean) Time per request: 0.436 [ms] (mean, across all concurrent requests) Transfer rate: 120100.12 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 4 84 275.9 18 7027 Processing: 39 132 124.1 90 3738 Waiting: 7 21 22.5 18 1598 Total: 50 216 308.0 109 7208 Percentage of the requests served within a certain time (ms) 50% 109 66% 127 75% 158 80% 180 90% 373 95% 1088 98% 1140 99% 1333 100% 7208 (longest request)
As per above output you can see that for 100K requests were served in 43.570 seconds by Nginx.
1 Comment
i used this , its very help me.
thanks