Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    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

    RahulBy 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.

    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
    Previous ArticleHow to Install Subversion (SVN) 1.8.19 on CentOS/RHEL 7/6/5
    Next Article 15 Best Security Tips for LAMP Stack

    Related Posts

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How to Increase Request Timeout in NGINX

    Updated:January 13, 20222 Mins Read

    How to Install Nginx, MySQL & PHP (LEMP) on Ubuntu 20.04

    5 Mins Read

    How To Install Nginx with PHP-FPM on Ubuntu 20.04

    Updated:December 3, 20203 Mins Read

    How to Install Nginx on Ubuntu 20.04

    3 Mins Read

    How to Configure Nginx for WordPress Permalinks

    Updated:April 21, 20202 Mins Read

    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

    Recent Posts
    • How to Install Sublime Text 4 on Ubuntu 22.04
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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