ideal httpd config

Discussion in 'Apache' started by Gizlen, Jun 29, 2011.

  1. #1
    hi,

    up to 250 online user everthing is okey. If over, load is more than 5 (8 CPU) and speed of opening web page is slowly.


    Nginx installed ;)
    nginx.conf
    user  nobody;
    # no need for more workers in the proxy mode
    worker_processes  4;
    error_log  /var/log/nginx/error.log info;
    worker_rlimit_nofile 20480;
    events {
     worker_connections 10240; # increase for busier servers
     use epoll; # you should use epoll here for Linux kernels 2.6.x
    }
    http {
     server_name_in_redirect off;
     server_names_hash_max_size 10240;
     server_names_hash_bucket_size 1024;
     include    mime.types;
     default_type  application/octet-stream;
     server_tokens off;
     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;
     keepalive_timeout  5;
     gzip on;
     gzip_vary on;
     gzip_disable "MSIE [1-6]\.";
     gzip_proxied any;
     gzip_http_version 1.1;
     gzip_min_length  1000;
     gzip_comp_level  6;
     gzip_buffers  16 8k;
    # You can remove image/png image/x-icon image/gif image/jpeg if you have slow CPU
     gzip_types    text/plain text/xml text/css application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg application/xml+rss text/javascript application/atom+xml;
     ignore_invalid_headers on;
     client_header_timeout  3m;
     client_body_timeout 3m;
     send_timeout     3m;
     reset_timedout_connection on;
     connection_pool_size  256;
     client_header_buffer_size 256k;
     large_client_header_buffers 4 256k;
     client_max_body_size 200M; 
     client_body_buffer_size 128k;
     request_pool_size  32k;
     output_buffers   4 32k;
     postpone_output  1460;
     proxy_temp_path  /tmp/nginx_proxy/;
     client_body_in_file_only on;
     log_format bytes_log "$msec $bytes_sent .";
     include "/etc/nginx/vhosts/*";
    }
    
    PHP:
    apache status
    Total accesses: 7059 - Total Traffic: 20.4 MB
    CPU Usage: u1.62 s1.93 cu134.88 cs0 - 11.2% CPU load
    5.72 requests/sec - 16.9 kB/second - 3033 B/request
    10 requests currently being processed, 8 idle workers
    PHP:
    httpd.conf
    Timeout 200
    KeepAlive On
    KeepAliveTimeout 10
    MaxKeepAliveRequests 0
    MinSpareServers 8
    MaxSpareServers 16
    StartServers 8
    MaxClients 210
    MaxRequestsPerChild 10000
    
    PHP:
    How can I solve this problem ?
     
    Gizlen, Jun 29, 2011 IP
  2. LH-Danny

    LH-Danny Member

    Messages:
    398
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Would it be possible that you could show us your server specification also?

    I've never really used Ngnix before, however have you considered using Apache + Varnish Cache? It's free and according to benchmarks against Litespeed, it's around 50% faster.
     
    LH-Danny, Jul 1, 2011 IP
  3. RHS-Chris

    RHS-Chris Well-Known Member

    Messages:
    1,007
    Likes Received:
    35
    Best Answers:
    10
    Trophy Points:
    150
    #3
    I would be turning KeepAlive off, in both nginx and apache:

    nginx
    keepalive_timeout 0;

    Apache
    KeepAlive Off

    If you are serving PHP pages as well, install a caching system (not applicable if you are using suphp).

    Chris
     
    RHS-Chris, Jul 1, 2011 IP
  4. BinaryBits

    BinaryBits Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sounds like you have the wrong Apache MPM or MPM settings.
    A thread based MPM with PHP as a module (vs. cgi) will easily handle 100s of connections.

    But with what you have (the prefork MPM / process based) I would...

    
    Timeout 60
    KeepAlive On
    KeepAliveTimeout 2
    MaxKeepAliveRequests 0
    MinSpareServers 8
    MaxSpareServers 16
    StartServers 8
    MaxClients 386
    MaxRequestsPerChild 10000
    
    Code (markup):
    KeepAlives should be 1-2 seconds, not zero.
    MaxClients is the most important one...
    http://httpd.apache.org/docs/2.2/mod/prefork.html
     
    BinaryBits, Jul 6, 2011 IP
  5. CoderJosh

    CoderJosh Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Are you using a combination of nginx and Apache (for example, nginx for static files and Apache for dynamic requests such as PHP scripts), or have you switched from Apache to nginx?
     
    CoderJosh, Jul 9, 2011 IP