--- Apache Web server

1. apache configuration file (the path may be different, but the file name should not change): /etc/httpd/conf/httpd.conf 

2. executable file: / usr / sbin

3. apache service startup command: service httpd start (status stop restart)

4. apache tuning: vi /etc/httpd/conf/httpd.conf


Tuning mode of operation: a first

    ------- you can see the current mode through httpd -l

  • Prefork mode: Use multiple sub-processes, each child process only one thread, high efficiency, each request independently of each other, there is a problem if a request does not affect the other requests, but large memory footprint

    image.png

     MaxClients: If you need to set this parameter, then the first set ServerLimit, both of the same size can, but can not exceed ServerLimit


  • Worker mode: Use multiple sub-processes, each child process has multiple threads, small memory footprint, suitable for high-traffic http server, but if a thread crashes, the whole process will die together

    Internet companies generally high concurrent high traffic, you should consider using this mode, because the use of multi-threading. On the downside, you can use load balancing techniques to reduce as much as possible.

    image.png

    ThreadsPerChild: If you need to set this parameter, then the first set ThreadLimit, both of the same size can, but can not exceed ThreadLimit


Second: tuning key parameters

  • Timeout: apache specified timeout period, in seconds, if the time exceeds, apache abandonment process the request and release the connection, the default value of the parameter 120, the recommended set 60, a large amount of access to the site or can be set to 30 15

  • KeepAlive: on the very adequate server memory, regardless of whether this feature is turned off, there will be no significant changes in server performance; if less server memory, or mainly deal with dynamic web service, turn it off can save a lot of memory; treatment recommendations still open service

  • Expires: full use of the cache (this refers to the client-side caching, can be understood as the browser's cache) Expires header information is an important basis for client-side caching, if the current time Expires less than the specified time, the browser from the cache direct access to the relevant data or HTML file, on the contrary, the browser sends a request to the server to get.

    Removing LoadModule expires_module modules / foregoing mod_expires.so # 

    image.png

    Setup is complete, save, restart apache to take effect.

  • Open gzip: All text compression class resource Internet transmission, such as html, css, js, such as the use QQ when transferring large files, transfer rate after compression is significantly faster than before compression

    Removing the front of the # 2

    LoadModule deflate_module modules/mod_deflate.so

    LoadModule headers_module modules/mod_headers.so

    Compression level, do not set too high, otherwise it will take up too much cpu.

    image.png

    Setup is complete, save, restart apache to take effect.

    If you want to verify, by like Firebug or F12 tool, see requests and responses, if the request contains Accept-Encoding the header: gzip, deflate, sdch, indicates that the compression format of the current request supported; if it contains Content-Encoding the response header: gzip, it said the content of the response has been gzip compression














Guess you like

Origin blog.51cto.com/11009785/2404555