Chapter 8 Display Server Statistics PDF

Summary

This document provides information on server activity and performance, using Apache server statistics. It details the mod_status module, which is used to monitor web server load and current connections. The document also explains how to install and use the module and how to interpret the server statistics.

Full Transcript

Chapter 8: Display Server Statistics 1 Web Administration – FWD 213 Introduction Status module allows server administrator to find out how well their server is performing. An HTML page present the current server statistics in an easily readable form. If required, this page can...

Chapter 8: Display Server Statistics 1 Web Administration – FWD 213 Introduction Status module allows server administrator to find out how well their server is performing. An HTML page present the current server statistics in an easily readable form. If required, this page can be made to automatically refresh. Another page gives a simple machine-readable list of the current server state Description: Provides information on server activity and performance Status: Base Module Identifier: status_module Source File: mod_status.c 2 Apache mod_status module ▪ The mod_status is an Apache module that helps to monitor web server load and current httpd connections with an HTML interface that can be accessed via a web browser. ▪ The mod_status module provides an easy way to access server statistics. ▪ It generates a server status report, allowing administrators to monitor server activity. ▪ To install mod_status, ensure the module is loaded in the Apache configuration file by including the line : LoadModule status_module modules/mod_status.so 3 What are the statistics? Apache’s mod_status shows a plain HTML page containing the information about current statistics of the webserver including: ❑Total number of incoming requests ❑Total number of bytes and counts server ❑The CPU usage of Webserver ❑Server Load ❑Server Uptime ❑Total Traffic ❑Total number of idle workers ❑PIDs with the respective clients and many more. The default Apache Project enabled their server statistics page to the general 4 public. Enable mod_status in Apache The default Apache installation comes with mod_status enabled. If not, make sure to enable it in the Apache configuration file. To enable mod_status, configure the section in the Apache configuration file httpd.conf as shown below: This configuration allows access to the server status page from the localhost. 5 Accessing server statistics with mod_status ▪ After enabling mod_status, you can access the server statistics through a web browser by visiting http://localhost/server-status 6 Accessing server statistics with mod_status ▪ you can also access the server statistics through the command: Apache2ctl status 7 Understanding server statistics: Overview ▪ The server status page provides an overview of the server's performance, including current time, restart time, server uptime, total accesses, and total traffic. ▪ These metrics help in understanding the server's overall health and performance. 8 Understanding server statistics: CPU Usage ▪ Monitoring CPU usage helps identify performance bottlenecks. ▪ The mod_status report includes CPU load and CPU usage information, which can be used to determine if the server is under heavy load or if adjustments to the configuration are needed. 9 Understanding server statistics: Requests ▪ The mod_status report also provides information about requests per second, bytes per second, and bytes per request. ▪ These metrics can help you identify patterns and optimize your server configuration to handle more requests efficiently. 10 Extended server statistics ▪ To enable extended server statistics, include ExtendedStatus On in the Apache configuration file. ▪ Extended server statistics provide more detailed information about the server's performance, such as the scoreboard (server activity in a structure) and connection details. 11 Understanding extended server statistics: Scoreboard ▪ The scoreboard section in the extended server statistics provides a breakdown of worker statuses and detailed connection information for each worker. ▪ This information can be used to understand the server's performance and identify any bottlenecks or issues that need to be addressed. ▪ Note: The term “Apache worker” refers to a process or a thread, depending on the Multi- Processing Module (MPM) used, that handles the requests coming to an Apache server. 12 Understanding extended server statistics: Scoreboard Invoking the Apache scoreboard is simple, simply by running the following command: apachectl status This will display output similar to the image: Each of the characters in this output has a different meaning: ▪ _ — The server is waiting for the connection. ▪ S — The server is starting. ▪ R — The server is reading the request. ▪ W — The server is sending a reply. ▪ K — The server is in keep-alive (read) mode. ▪ D — The server received a DNS request. ▪ C — The server is closing the connection. ▪ I — Idle worker cleanup. ▪. — Idle worker. ▪ Understanding this will help you troubleshoot the issues that you may be experiencing 13 Understanding extended server statistics: Scoreboard Understanding previous slide will help you troubleshoot the issues that you may be experiencing. ▪ For example, a scoreboard that displays a large amount of "W" status, may indicate a poorly performing web application such as a PHP website. Alternatively, if this coincides with a large number of traffic spikes, it may be a result of an attack (DoS). ▪ Similarly, many requests stuck in "R" can be an indication of an attacked known as Slowloris, in which many connections are opened and kept open for as long as possible. If you suspect your server to be undergoing an attack it is recommended that you contact your service provider/data host for assistance in mitigating the effects. 14 Monitoring server statistics with apachetop ▪ apachetop is a command-line tool that provides real-time monitoring of Apache server statistics. Install it using sudo apt install apachetop ▪ and run it with apachetop -f /var/log/apache2/access.log 15 Monitoring server statistics with apachetop 16 Analyzing server logs ▪ Server logs are essential for understanding server performance. ▪ Server log: is a text document that contains a record of all activity related to a specific web server over a defined period of time ▪ Access logs and error logs: provide insights into server activity and can be used to identify issues or opportunities for optimization. ▪ Access log gathers data related to the files requested from the server ▪ Error log tracks all failed requests for the server ▪ Logs are typically located in the directory: /var/log/apache2 17 Using tail and grep to monitor logs Use the following command: tail -f /var/log/apache2/access.log or tail -f /var/log/apache2/error.log to monitor logs in real-time. You can also filter logs using grep, for example: tail -f /var/log/apache2/access.log | grep "GET /index.php". Grep (global regular expression print) is a small family of commands that search input files for a search string and print the lines that match it. Although this may not seem like a terribly useful command at first, grep is considered one of the most useful commands in any Unix system. Tail is a command being executed on the output of the grep command and so will print the last 4 lines of the output of grep 18 Using tail and grep to monitor logs 19 Visualizing server statistics with goaccess ▪ goaccess is a command-line tool that provides an interactive and visually appealing report of server statistics. ▪ Install it on Unix Ubuntu with the command: sudo apt install goaccess and run it with goaccess /var/log/apache2/access.log -a 20 Visualizing server statistics with goaccess 21 Optimizing Apache server performance ▪ Regularly monitoring server statistics helps identify areas for optimization, such as worker processes, memory usage, and caching. Addressing these areas can improve the server's performance and ensure a better experience for users. ▪ Optimizing Apache server performance is crucial for providing the best possible experience to users and ensuring that resources are utilized efficiently. Following are some key areas to focus on when optimizing Apache server performance. 22 Optimizing Apache server performance: 1: Configuring KeepAlive settings KeepAlive allows multiple requests to be served over a single connection, reducing server overhead and improving performance. ▪ Enable KeepAlive by setting KeepAlive On in the Apache configuration file. ▪ Configure the KeepAliveTimeout and MaxKeepAliveRequests settings to optimize the balance between server performance and resource consumption. 23 Optimizing Apache server performance 2. Leveraging caching ▪ Caching can significantly improve server performance by storing static content and serving it to clients without reprocessing. ▪ Enable and configure: ▪ mod_cache, ▪ mod_cache_disk, ▪ or mod_mem_cache to take advantage of caching capabilities. ▪ Set appropriate cache expiration times and cache-control headers to ensure that clients receive updated content when necessary. 24 Optimizing Apache server performance 3. Compression settings ▪ Compressing responses can reduce the amount of data transferred between the server and clients, improving performance and reducing load times. ▪ Enable the: ▪ mod_deflate module to compress responses before they are sent to clients. ▪ Configure compression settings, such as the types of files to compress and the compression level, to optimize performance. 25 Optimizing Apache server performance 4. Use a reverse proxy ▪ A reverse proxy can improve server performance and security by handling requests on behalf of the Apache server. ▪ Configure ▪ mod_proxy to set up a reverse proxy, which can help distribute the load and manage connections more efficiently. 26 Thank you 27

Use Quizgecko on...
Browser
Browser