Apache performance monitoring

Source: Internet
Author: User

Apache vs nginx performance 2017
Introduction to the previous chapterWebServerApacheThe architecture and principlesApacheInstallation (LinuxAs follows:

Apache camel performance 



Http://www.cnblogs.com/fnng/archive/2012/08/30/2662984.html

Apache performance testing tools



So this section will share someApachePerformance monitoring.





 





 





Monitor performance through server-status in Linux





 Apache tuning for high performance





To monitor Apache performance, we need to modify the configuration file to allow you to view the Apache running status of the host.





 





1) Load mod_status.so 


Nginx vs apache performance graph


The module for Apache status management is loadmodule status_module modules/mod_status.so, so you need to modify it in the configuration file of... apache2 \ conf '\ httpd. conf.





[Root @ localhost/] # cd/usr/local/Apache/Conf





[Root @ localhost/] # vi httpd. conf





Find loadmodule status_module modules/mod_status.so and remove the # sign (no # by default)





 





2) There are two ways to modify the configuration file::





Method 1: Add the following content at the bottom of the httpd. conf file:



 


<Location/C-server-status>Sethandler server-status order deny, allow deny from nothing allow from all</Location>Extendedstatus on



 





Method 2: Find the following memory in httpd. conf:




# Real-time info on requests and configuration # include CONF/extra/httpd-info.conf // remove the # sign before this line



Open the. apache2 \ conf \ extra \ http-info.conf configuration file for modification.The modified content is the same as method 1..





In fact, the two methods are the same, but the second method is more elegant.





 





Explanation of modification information:





<Location/C-server-status>: The name c-server-status can be obtained randomly, but it is better not to be guessed by others.





Deny fromIndicates the access address that is forbidden; nothing indicates that no access address is forbidden.
Allow fromAll indicates that all addresses can be accessed.





Extendedstatus onIt indicates that the detailed request information can be seen during access. In addition, this setting can only be used for global settings and cannot be enabled or disabled in a specific virtual host. Enabling the extended status information will reduce the server running efficiency.





 





3) Restart Apache





[Root @ localhost/] # cd/usr/local/Apache/bin/





[Root @ localhost bin] # Start apachectl





[Root @ localhost bin] # Stop apachectl stop





 





4) Access





Http: // your IP addressAddress: Port/C-server-status





Http: // your IP addressAddress: Port/C-server-Status? Refresh = N





NIt indicates that the access status page can beNAutomatically refresh once in seconds





 





 





 





Use command monitoring in Linux





 





In addition to the above method for performance monitoring, we can also use commands to view the number of processes and the current number of connections.





 





1. Use PS to check the number of httpd Processes
# Ps-Ef | grep httpd | WC-l





Use this command to count the current number of httpd processes. Of course, this result contains the grep HTTPd process output. Generally, the actual number of processes is 1 less than the output result. When apache is started, several processes are started by default. If there are more connections, more processes are generated to process requests.





 





2. Use netstat to view the current number of connections
# Netstat-ant | grep ": 80" | WC-l





The number of connections is not equal to the number of httpd threads. Of course, the more connections there are, the more httpd processes there will be. The number of returned results may include multiple connection states, such as listen, established, and time_wait. You can add the State keyword to further filter and obtain the desired result.





 





 





 





Server-status monitoring in win7 64





 





There are not many Apache in 64-bit Windows 7.AndPHPNo official64Bit version. Below is the csdnI have verified the availability.





Http://download.csdn.net/detail/yetilion/4468168





 





Decompress the downloaded package to the current directory of drive D. Start --- run --- cmd





Go to the D: \ httpd-2.2-x64 \ bin directory (currently as Administrator)





D: \ httpd-2.2-x64 \ bin>Install httpd-K install





If an error is prompted, check whether the current user is an administrator or modify HTTP. conf.Whether the port set in the file is occupied.





 





Open it in NotepadConf/DirectoryHttpd. conf





Certificate ---------------------------------------------------------------------------------------------------------------------------------------------------------





SearchServerrootTo change the following directory to the current directory, that is/Httpd-2.2-x64"





SearchDocumentRoot, Change the following directory to the directory of Your webpage





SearchDirectoryindex, Add the default homepage nameIndex.html index.htm index. php





SearchServername, Remove#To change the following URL to your own, such:127.0.0.1: 80





InHttpd. confAdd the followingCode:YourpathYour website directory





<Directory "D:/yourpath/">





Allow from all





</Directory>





Note: If the computer is installedIISAndApacheThe listening ports must be different. OtherwiseApacheCannot start





Bytes ----------------------------------------------------------------------------------------------------------------------





 





UseApache, InCMDGo\ Httpd-2.2-x64 \ binDirectory, enter the following command: 





D: \ httpd-2.2-x64 \ bin>Httpd-K startApache:





D: \ httpd-2.2-x64 \ bin>Httpd-K RestartRestartApache





D: \ httpd-2.2-x64 \ bin>Httpd-K ShutdownCloseApache





 





Http: // your IP address: Port/C-server-status





 



Apache server status for localhostserver version: Apache/2.2.19 (win64) server built: May 28 2011 15: 18: 56 current time: Sunday, 11-nov-2012 17:44:21 öð ú ú± ê × ¼ ± ¼ ärestart time: Sunday, 11-nov-2012 17:36:28 öð ú ú± ê × ¼ ± ¼ äparent server generation: 1 server uptime: 7 minutes 52 secondstotal accesses: 0-total traffic: 0 kb0 requests/sec-0 B/second-1 requests currently being processed, 63 idle workers ______________________________________________________________ W _.................................. .............................. scoreboard key: "_" waiting for connection, "S" starting up, "R" reading request, "W" sending reply, "K" keepalive (read ), "D" DNS lookup, "C" Closing connection, "L" logging, "G" gracefully finishing, "I" Idle cleanup of worker ,". "open slot with no current processsrv pid acc m ss req conn child slot client vhost Request0-1 4140 0/0/0 w 0 287636364 0.0 0.00 0.00 127.0.0.1 192.168.0.100 get/C-server-status HTTP/1.1srv child server number-generationpid OS process idacc number of accesses this connection/this child/This slotm mode of operationss seconds since beginning of most recent limit milliseconds required to process most recent requestconn limit transferred this connectionchild megabytes transferred this childslot total megabytes transferred this slot


 





 





Parameter Analysis:



Parameter Analysis: Describes the version of the server version Apache server. The time when the server built Apache server is compiled and installed. Current time the current system time. Restart time the time when Apache restarts. Parent server generation Apache parent Program (Parent process) generation number, that is, the number of times that HTTPD receives sighup and restarts. Server uptime the time that has elapsed since Apache was started. Total accesses: the number of connections received by Apache and the amount of data transferred. CPU usage current CPU usage. _ Swss... the current status of all Apache processes. Each character represents a program, and the status of up to 256 programs can be displayed. Scoreboard key. The meaning of each character symbol is as follows: * _: waiting for the link. * S: starting. * R: Reading requirement. * W: A response is being sent. * K: Keep online. * D: The DNS is being searched. * C: the link is being closed. * L: The record file is being written. * G: Enter the normal end program. * I: processing is idle. *.: This program does not exist. SRV generation number of the program and its parent program. PID process ID of the program. ACC indicates the number of accesses processed by the program and online respectively. M The current state of the program. CPU the CPU resources consumed by the program. The time when the SS was requested by the previous processing. The time required for the last req processing, measured in 1‰ seconds. Conn The amount of data transmitted online. The amount of data transmitted by the Child Program. The volume of data transmitted by the slot. The address of the client. The virtual host or the IP address of the local host. Request information.


 











----------------------------------------------





PS: Linux has never succeeded in using server-status monitoring, but I have been checking it online for two days. The method described in this article is related to the environment I set, if a netizen successfully leaves a message about the environment, let me know.





In addition, the frequency of blog sorting has been reduced recently. On the one hand, it is due to busy work. On the other hand, it is hard to take time to learn English. If technicians are not good at English, it may not affect their technical skills, in a few years, we will have a deep feeling.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.