dak1n1

Nginx config - 904k http req/sec

Apr 22nd, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.38 KB | None | 0 0
  1. #----------------------------------------------------------------------
  2. # Main Module - directives that cover basic functionality
  3. #----------------------------------------------------------------------
  4.  
  5. user              nginx;
  6.  
  7. # This number should be, at maximum, the number of CPU cores on your system.
  8. # (since  nginx doesn't benefit from more than one worker per CPU.)
  9. worker_processes 24;
  10.  
  11. # Number of file descriptors used for Nginx. This is set in the OS with 'ulimit -n 200000'
  12. worker_rlimit_nofile 200000;
  13.  
  14. #error_log  /var/log/nginx/error.log;
  15. error_log  /dev/null crit;
  16. pid        /var/run/nginx.pid;
  17.  
  18. #----------------------------------------------------------------------
  19. # Events Module
  20. #----------------------------------------------------------------------
  21.  
  22. events {
  23.     # determines how many clients will be served by each worker process.
  24.     # (Max clients = worker_connections * worker_processes)
  25.     worker_connections  45000;
  26.  
  27.     # essential for linux, optmized to serve many clients with each thread
  28.     use epoll;
  29.  
  30.     # accept as many connections as possible, after nginx gets notification about a new connection.
  31.     # May flood worker_connections, if that option is set too low.
  32.      multi_accept on;
  33. }
  34.  
  35.  #----------------------------------------------------------------------
  36.  # HTTP Core Module
  37.  #----------------------------------------------------------------------
  38.  
  39. http {
  40.     include       /etc/nginx/mime.types;
  41.     default_type  application/octet-stream;
  42.  
  43.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  44.                       '$status $body_bytes_sent "$http_referer" '
  45.                       '"$http_user_agent" "$http_x_forwarded_for"';
  46.  
  47.       # caches information about open FDs and freqently accessed files
  48.       open_file_cache max=200000 inactive=20s;
  49.       open_file_cache_valid    30s;
  50.       open_file_cache_min_uses 2;
  51.       open_file_cache_errors   on;
  52.  
  53.      # Buffer log writes to speed up IO.
  54.      #access_log /var/log/nginx/access.log main buffer=16k;
  55.      access_log off;
  56.    
  57.      # Sendfile copies data between one FD and other from within the kernel.
  58.      # More efficient than read() + write(), since the requires transferring data to and from the user space.
  59.      # Tcp_nopush causes nginx to attempt to send its HTTP response head in one packet,
  60.      # instead of using partial frames. This is useful for prepending headers before calling sendfile,
  61.      # or for throughput optimization.
  62.      sendfile      on;
  63.      tcp_nopush    on;
  64.  
  65.      # -- keep-alive options --#
  66.  
  67.      # don't buffer data-sends (disable Nagle algorithm). Good for sending frequent small bursts of data in real time.
  68.      tcp_nodelay on;    
  69.      
  70.      # Timeout for keep-alive connections. Server will close connections after this time.
  71.      keepalive_timeout 30;
  72.  
  73.      # Number of requests a client can make over the keep-alive connection.
  74.      keepalive_requests 100000;
  75.  
  76.      # -- Timeouts -- #
  77.  
  78.      # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
  79.      # Does not apply
  80.      reset_timedout_connection on;
  81.  
  82.      # send the client a "request timed out" if the body is not loaded by this time. Default 60.
  83.      client_body_timeout   10;
  84.  
  85.      # If the client stops reading data, free up the stale client connection after this much time. Default 60.
  86.      send_timeout          2;
  87.    
  88.      # Compression. Useful for cutting down on network traffic
  89.      gzip on;
  90.      gzip_min_length 10240;
  91.      gzip_proxied expired no-cache no-store private auth;
  92.      gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
  93.      gzip_disable "MSIE [1-6]\.";
  94.  
  95.     # -- The default server -- #
  96.     server {
  97.         listen       80;
  98.         server_name  _;
  99.  
  100.     location / {
  101.             root   /usr/share/nginx/html;
  102.             index  index.html index.htm;
  103.         }
  104.  
  105.      error_page  404              /404.html;
  106.         location = /404.html {
  107.             root   /usr/share/nginx/html;
  108.         }
  109.  
  110.         # redirect server error pages to the static page /50x.html
  111.         error_page   500 502 503 504  /50x.html;
  112.         location = /50x.html {
  113.             root   /usr/share/nginx/html;
  114.         }
  115.  
  116.     }
  117.  
  118.     # Load config files from the /etc/nginx/conf.d directory
  119.     #include /etc/nginx/conf.d/*.conf;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment