In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Ab stress test Apache has its own stress test tool ab, which is easy to use and can simulate various conditions to initiate test requests to the Web server. The ab tool can initiate test requests directly on the Web server, which is very important to understand the processing performance of the server, because it does not include the network transmission time of the data and the local computing time of the user PC. Thus, the performance of the Web server can be judged by observing various time indicators, so as to optimize the parameters. In the process of performance adjustment and optimization, the ab stress test tool can be used to test and optimize the optimization effect by using the ab stress test tool. First, use ab for stress test optimization, then restart the service, and then use ab for stress test to compare the results of the two tests. To see whether the optimization effect is obvious in order to evaluate the performance of web services more objectively, it is generally necessary to test several times before and after optimization, and take the average of the test results to compare the use of ab tools.
Command format
Ab [options] website URL
Parameter description
-n,-c,-t,-v
Example
/ usr/local/httpd/bin/ab-n5000-c900 www.bt.com/index.html
In the test, the total number and the number of concurrent users should be adjusted according to the situation.
The key parameters of the ab test results indicate that the parameters describe the header information of the Server Softwarehttp response data, the host name in the url of the Server Hostname request, the listening port of the Server Portweb server software, the listening port of the url root of the Document Path request, the absolute path of the Document Lengthhttp response data, the body length of the Document Lengthhttp response data, the number of concurrent users Time taken for tests, the sum of the time taken for all these requests to be processed, the total number of requests Complete requests represents the total number of requests Failed requests failed. Sum of response data length of Total transferred requests and throughput of Requests per second server Number of requests processed per second Time per request average request wait time Time per request average of actual elapsed time per request Percentage of the requests served within a certain time (ms) describes the distribution of processing time per request test example [root@localhost bin] # ab-n 20000-c 500 www.kgc.com/index.html / / use command to test This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd Http://www.zeustech.net/Licensed to The Apache Software Foundation Http://www.apache.org/Benchmarking www.kgc.com (be patient) Completed 2000 requestsCompleted 4000 requestsCompleted 6000 requestsCompleted 8000 requestsCompleted 10000 requestsCompleted 12000 requestsCompleted 14000 requestsCompleted 16000 requestsCompleted 18000 requestsCompleted 20000 requestsFinished 20000 requestsServer Software: ApacheServer Hostname: www.kgc.comServer Port: 80Document Path: / index.htmlDocument Length: 68 bytesConcurrency Level: 500Time taken for tests: 1.237 secondsComplete requests: 20000Failed requests: 0Total transferred: 7300000 bytesHTML transferred: 1360000 bytesRequests per second: 16169.67 [# / sec] (mean) Time per request: 30.922 [ms] (mean) Time per request: 0.062 [ms] (mean) Across all concurrent requests) Transfer rate: 5763.60 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 0 560.3 1 1004Processing: 0 1449.66 808Waiting: 0 1249.55 808Total: 1 1978.28 1201Percentage of the requests served within a certain time (ms) 50% 8 66% 9 75% 9 80% 10 90% 13 95% 17 98% 211 99% 40 6% 1201 (longest request) Apache working mode Apache working mode introduction Apache as the most widely used and most stable open source server software for web servers today, there are many working modes. When the source package installs httpd, you can view the httpd-mpm.conf file, which is located in the extra/conf directory. At present, there are two main modes: event mode, worker mode prefork mode [root@apache1 bin]. / httpd- l / / View the current working mode of apache. Event is the latest working mode of Apache, which is very similar to worker mode. The difference is that it solves the problem that thread resources are wasted during keep-alive long connections. Event working mode will fail when it encounters some incompatible modules and will fall back to worker mode. Event working mode requires Linux system (Linux 2.6 +) to support epoll before it can be enabled. What needs to be added is the HTTPS connection (SSL) event working mode in the event working mode, there will be some special threads used to manage these keep-alive type threads when there is a real request, pass the request to the server thread, and allow it to release after the execution is completed, so that a thread can handle several requests, realizing asynchronous non-blocking. This enhances the explanation of event parameters for request processing in high concurrency scenarios.
In the httpd-mpm.conf configuration file, the following is the definition of the prefork module
< IfModule mpm_event_module>StartServers 3 MinSpareThreads 75 MaxSpareThreads 250 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0
Parameter description
Parameters indicate the initial number of processes when the StartServers service is started, the minimum number of free child processes in the default 3MinSpare Threads, the maximum number of free child processes in the default 75MaxSpare Threads, the number of threads generated by each child process in the default 250ThreadsPerChild, the maximum number of requests that the client can access at the same time by default, and the maximum number of requests allowed by each child process in its life cycle by default, if the total number of requests has reached this value. The child process will end, and if set to 0, the child process will never end. Setting this value to a non-zero value can prevent memory leaks caused by running PHP. The event optimization suggestion can be debugged according to the production environment to determine the appropriate parameters. Reference ServerLimit 1000StartServers 20MinSpareThreads 25MaxSpareThreads 1200ThreadsPerChild 50MaxRequestWorkers 2000MaxConnectionsPerChild 1000prefork as the mode introduction prefork is a multiplexing module (MPM), which implements a process, pre-derived web server. Systems that do not have thread-safe libraries and need to avoid thread compatibility problems have good characteristics when each request is independent of each other. If there is a problem with one request, it will not affect the strong self-adjustment ability of other requests. Only a few configuration instructions are needed to adjust it to suit enterprise application requirements. The most important thing is to set MaxClients to a large enough value to handle the potential request peak, but not too large at the same time, to avoid the need for more memory than the physical memory. Prefork working mode, a separate control process (parent process) is responsible for generating child processes, which are used to listen for requests and respond. Therefore, there will always be some spare (spare) or idle child processes in memory to respond to new requests with 3F, which can speed up the response. The parent process usually runs as root to bind port 80, and the child process is usually run as a low-privileged user. Users who run child processes through the User and Group of configuration items must have read access to the content of the website. However, you must have as few permissions to other resources as possible to ensure that the system compiles and installs safely without specifying a working mode. Prefork mode is used by default. You can use httpd-l to view the prefork parameter explanation.
In the httpd-mpm.conf configuration file, the following is the definition of the prefork module
< IfModule mpm_prefork_module>Parameter StartServers 20MinSpareServers 10MaxSpareServers 50MaxClients 150MaxRequestsPerChild 0 specifies the maximum number of processes created when ServerLimit is started. MinSpareServers minimum idle process MaxSpareServers maximum idle process MaxClients maximum number of child processes to process requests MaxRequestsPerChild maximum number of requests processed by each process, the process will be destroyed if set to 0 Child processes never end prefork optimization recommendations can be debugged according to the production environment to determine the appropriate parameters reference ServerLimit 1000 StartServers 10 MinSpareServers 10 MaxSpareServers 30 MaxClients 1000 MaxRequestsPerChild 5000worker working mode introduction worker is also a multiprocessing module (MPM), so that the network server to support mixed multithreaded multiprocesses due to the use of threads to process requests, so it can handle a large number of requests The cost of system resources is less than that of process-based MPM, but it also uses multiple processes, and each process has multiple threads to obtain the stability of process-based MPM. The most important instruction to control the MPM is: control the number of threads allowed to be established per child process ThreadsPerChild instruction and MaxClients instruction to control the number of buses allowed to be established worker working mode the number of threads that each process can have is fixed The server will increase or decrease the number of processes according to the load. A separate control process (parent process) is responsible for the establishment of child processes. Each child process can set up a number of ThreadsPerChild service threads and one listening thread. The listening thread listens to the access request and passes it to the service thread to process and reply. Apache always maintains a spare or idle service thread pool. The client does not have to wait for the establishment of a new thread or process to get the service parent process started as root to bind port 80. Subsequently, Apache sets up child processes and threads User and Group instructions with lower-privileged users to configure the running user of the Apache child process. Child processes should have read access to web pages, but should limit permissions as much as possible. The worker parameter describes the maximum number of ServerLimit processes. The default value is the maximum number of threads per child process of "16" ThreadLimit, and the default value is the number of child processes established when the "64" StartServers server starts. The default is "3" MaxClients maximum number of access requests allowed at the same time (maximum number of threads) MinSpareThreads minimum number of idle threads default value is "75" MaxSpareThreads sets the maximum number of idle threads. The default value is the number of resident threads of execution established by each child process of the "250th" ThreadsPerChild. The default value is 25MaxRequestsPerChild to set the maximum number of requests that each child process is allowed to serve during its lifetime. Set to "0", the child process will never end the worker optimization recommendation to debug ServerLimit 40 ThreadLimit 200 StartServers 20 MaxClients 1000 MinSpareThreads 25 MaxSpareThreads 100 ThreadsPerChild 200 MaxRequestsPerChild 1000Apache directory attribute directory permissions and this pair of statements are a pair of container statements that must appear in pairs Encapsulated between them are specific statements for setting directory permissions, which only work on the set directory and its subdirectories. The directory attribute parameter works. Options sets which features are used in a specific directory. AllowOverride allows the instruction type Require to exist in .htaccess files to set the access control of the directory Indexes when the user accesses the directory, but does not specify which file to access, and there is no default web page in the directory. Returns a multi-valued graph of MultiViews content negotiation between files in a directory and a subdirectory list, a smart feature of Apache. When accessing objects that do not exist in the directory, ExecCGI allows the execution of CGI scripts in that directory FollowSymLinks allows file systems to use symbolic connections Includes allows server-side inclusion of functions IncludesNoExec allows server-side inclusion of functions, but forbids execution of CGI scripts All contains all features except MultiViews, if there is no Options statement, the default is All optimization recommends that enterprise configuration example Options should be set to None to prevent the contents of the directory from being exposed Cause security risks AllowOverride is set to None, prohibited. Instead of using the .htaccess file, the directory access control is placed between the main configuration file and the Require control object is set according to the enterprise needs of the directory to control the access of the client
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.