Apache Web-depth optimization

ab stress testing tool

Apache stress testing tool comes ab, easy to use and can simulate various conditions on the Web server to initiate a test request
ab tool can initiate a test request directly in the Web server locally, which for the need to understand the process server performance is critical, because it does not include network transmission time and the user's PC local time data is calculated, so as to judge the performance of the Web server by observing various indicators of time for optimization of adjustment parameters
is performed to optimize performance tuning process, can be used to optimize the stress test tool ab test results

  • Ab optimization before first use stress tests
  • After optimization, restart the service, then use ab to conduct stress tests
  • Comparison of the results of two tests to see whether the effect of significantly optimizing
  • The average in order to more objectively evaluate the performance of web services, before and after the general optimization should be carried out several tests, take the test results were compared

ab tool

Command Format

ab [options] 网站网址

Parameter Description

  • -n: total number of requests performed in the test session, the default perform a single request
  • -c: The number of simultaneous requests generated Default is one
  • -t: maximum number of seconds the tests carried out
  • -v: set the level of detail displayed

Examples

  • ab -n 2000 -c 800 www.aaa.com/index.html
  • When testing requirements and the total number of concurrent users to adjust according to the situation

ab test results illustrate the key parameters

Here Insert Picture DescriptionHere Insert Picture Description

Apache mode of presentation

Apache today as the most extensive and most stable web of open source server software server with
its mode of operation there are many kinds of source package httpd-mpm.conf can view the file when you install httpd, the file is located in extra / conf directory,
there are mainly three modes :

  • event mode
  • prefork mode
  • worker mode

execution ./httpd -l bin directory under the Apache installation directory can be viewed Apache current operating mode

event mode of operation

event mode of presentation

  • Apache is the latest event mode, much like it and worker mode, the difference is that it solves a long time keep-alive connections take up the thread resources are wasted questions
  • event work mode when it encounters certain incompatible module will fail, it will fall back to worker mode
  • event work mode requires Linux system (Linux 2.6+) support for epoll, in order to enable. It should be added that HTTPS connection (SSL)

event work

  • In the event mode of operation, there will be some threads dedicated thread to manage these types of keep-alive
  • When there is a real request after over, it passes the request to completion of the thread execution server, and allow it to release
  • In this way, a thread can handle several requests, to achieve non-blocking asynchronous, which enhances the request processing at high concurrency scenarios

event parameters to explain

  • Httpd-mpm.conf the configuration file, the following definitions are prefork module
    Here Insert Picture Description

  • Parameter Description
    Here Insert Picture Description

prefork mode of operation

prefork mode of presentation

  • prefork is a Multi-Processing Module (MPM), implements a process type, pre-derived web server, suitable for not thread-safe libraries, the need to avoid threading system compatibility issues
  • Having excellent properties required in the case of each request independently, if a request does not affect other problem request
  • Has a strong self-regulation, requires very little configuration instructions can be adjusted to suit the requirements of enterprise applications
  • The most important thing is to MaxClients is set to a value large enough to handle the peak potential of the request, at the same time not be too large, in order to avoid exceeding the size of the memory required physical memory

prefork mode of operation

  • A single control process (the parent) is responsible for producing the child, the child process listens for requests and respond, and therefore there has been some spare (spare) or idle child process in memory for responding to new requests, can speed up response
  • The parent process is usually run as root in order to bind to port 80, the child process usually runs at a low privileged user, through the User and Group Configuration Item Configuration
  • Users running child process must have read access to the site's content, but the other resources must have minimal rights, to ensure system security
  • No mode of operation if the compiler installation, the default will use prefork mode, you can view the httpd -I

prefork parameters to explain

  • Httpd-mpm.conf the configuration file, the following definitions are prefork module
    Here Insert Picture Description

  • Parameter Description
    Here Insert Picture Description

worker operating mode

worker works

  • The number of threads per process can have is fixed, the server will increase or decrease the number of processes according to the load
  • A single control process (the parent) is responsible for the establishment of the child process, each child can build ThreadsPerChild number of service threads and a listening thread, the thread monitor and monitor access to the service request processing threads and reply
  • Apache will always maintain a standby (spare) or idle thread pool service, clients do not need to wait for the establishment of a new threads or processes to obtain new service
  • The parent process usually started as root to bind to port 80; then, Apache child processes and threads in order to establish a low-privileged user
  • User and Group instructions for configuring Apache child processes running user, the child process to have read access to Web content, but it should be possible to limit rights

worker to explain the parameters

  • In the definition of worker httpd-mpm.conf
    Here Insert Picture Description

  • Parameter Description
    Here Insert Picture Description

Apache directory properties

Directory permissions set using <Directory directory path> and </ Directory> This statement is based directory or virtual directory permissions
are a pair of containers statement must appear in pairs, between which the package is disposed directory permissions specific statement these statements are only set directory and its subdirectories work
directory attribute parameters
Here Insert Picture DescriptionHere Insert Picture Description

Published 74 original articles · won praise 150 · Views 6516

Guess you like

Origin blog.csdn.net/weixin_45682995/article/details/103603950