Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Nginx»How to Optimize NGINX to Handle 100+K Requests per Minute

    How to Optimize NGINX to Handle 100+K Requests per Minute

    By RahulFebruary 2, 20152 Mins Read

    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.

    Advertisement

    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.

    nginx optimization
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How To Set Up Nginx Reverse Proxy: A Step-By-Step Tutorial

    Configuring the Nginx Reverse Proxy in Front of Apache

    Configure CORS in NGINX

    How to Enable CORS in Nginx

    View 1 Comment

    1 Comment

    1. خرید vps ارزان on November 29, 2017 7:58 am

      i used this , its very help me.
      thanks

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.