Apache Http Status
- Apache Tomcat Http Status 404 Error
- Apache Http Status Code Enum
- Apache Mod Status
- Http Status 404 Apache Tomcat
- Org.apache.http.statusline
- Apache Check Status
Apache performance and understanding /server-status metrics
Apache Tomcat Http Status 404 Error
HttpClient is a HTTP/1.1 compliant HTTP agent implementation based on HttpCore. It also provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. HttpComponents Client is a successor of and replacement for Commons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to. HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: Informational responses (100–199) Successful responses (200–299) Redirects (300–399) Client errors (400–499) Server errors (500–599) The below status codes are defined by section 10 of RFC 2616.
Apache Statistics Module: mod_status
A machine-readable version of the status file is available by accessing the page This is useful when automatically run, see the Perl program logserverstatus, which you will find in the /support directory of your Apache HTTP Server installation. HttpClient is a HTTP/1.1 compliant HTTP agent implementation based on HttpCore. It also provides reusable components for client-side authentication, HTTP state management, and HTTP connection management. HttpComponents Client is a successor of and replacement for Commons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to.
Understanding website performance and Apache uptime should begin with external monitoring, i.e. Zabbix, which allows you to discover problems from a user’s perspective. Such problems involve:
- Response timeout – no timely response from the server;
- HTTP errors instead of a response;
- Slow response – say, comparing to the last month’s average.
All these problems should be confirmed by monitoring from multiple locations to eliminate network related problems. Only when the same issue is observed from several locations at the same time can we conclude there is something wrong on the server side of things.
The next step is to check whether everything is OK with the server itself. This is where basic metrics like CPU, memory, disk and swap come into play offering you some guidance on where to focus further.
The most frequent reason for website performance issues is malfunctioning, buggy or not optimized application (e.g. PHP script), and slow DB queries. Before digging deep into profiling of an application and its queries, however, it makes sense to check Apache configuration and statistics – and this is what this post is all about.
Apache web server exposes metrics through its status module, mod_status. If your server is running and mod_status is enabled, your server’s status page should be available at http://<YOUR_DOMAIN>/server-status. If that link does not work, it means you need to enable mod_status in your configuration file.
It’s also possible that Location specified in your configuration file is not /server-status, intentionally or not. Follow the directions below to locate your mod_status configuration file, and look for a directive that contains SetHandler server-status. If you see that it specifies a Location other than /server-status, either update it accordingly (and restart Apache) or try accessing that endpoint to see if mod_status is enabled at that location. After enabling mod_status and restarting Apache, you will be able to see your status page at http://<YOUR_DOMAIN>/server-status.
Apache processes and threads architecture
Latest Apache versions implement hybrid multi-threaded and multi-process models to server requests. This means that you will see multiple Apache processes running and each process contains multiple threads. This allows a great trade-off between efficiency and stability.
Apache always maintains a number of idle (spare) workers, single server threads that process the requests, across all the processes as this allows it to immediately assign a request to a thread for processing, without the need to spawn a thread, which would heavily increase processing latency. Workers that are already processing requests are called busy workers. Depending on the number of idle workers Apache is able to fork or kill processes. Under normal conditions the number of idle workers should be more or less stable thanks to Apache self-regulation.
The way Apache forks processes and threads is defined by a particular Multi-Processing Module (MPM) implementation. This module is also responsible for binding ports, accepting connections, and dispatching it to workers. There are several of them depending on OS with prefork and worker being most popular on Unix OS family. The difference is that prefork doesn’t use threads and preforks all the necessary processes, while worker makes use of both processes and threads. Thus prefork is less memory efficient, but allows more stability in case of non-thread safe applications.
Workers’ configuration
A typical Multi-Processing Module (MPM) configuration looks like this (taken from apache.org):
The following is a brief explanation of these configuration directives:
- ServerLimit is a hard limit on the number of active Apache child processes. It should follow this rule ServerLimit >= MaxClients / ThreadsPerChild.
- StartServers is a number of child processes launched initially.
- MaxClients is a very important parameter that sets the maximum number of workers (all threads in all processes), and also sets the limit of the maximum number of client requests that may be served simultaneously. Any connection attempts over the MaxClients limit will normally be queued, up to a specific number guided by ListenBacklog directive. Note that in Apache version 2.4 this directive is renamed to MaxRequestWorkers.
- MinSpareThreads and MaxSpareThreads are the boundaries of idle workers number.
- ThreadsPerChild specifies the fixed number of threads created by each child process.
- MaxRequestsPerChild is the number of served requests (or connections depending on the particular type of MPM in use), after which the child process will die. The purpose of this directive is to fight accidental memory leaks.
Know what workers are doing
Mod_status provides information about what each worker is doing in the form of a scoreboard, which looks like this:
Each character has the following meaning:
Normally, the majority of workers should be in R/W or idle (“_”) state. If you see a big number of workers in other states like “K”, “D” or “L”, there’s likely a corresponding problem with keep-alive settings, DNS resolving or logging.
Sizing Apache to the server
The most important server characteristic in relation to a web server is the amount of RAM. A web server should never swap because it will make request processing latency unacceptable. It is important to understand the maximum number of workers that fit RAM of your server and adjust the MaxClients(or MaxRequestWorkers) directive accordingly. In order to do this you should observe how much RAM is consumed by how many Apache processes under normal conditions. Divide the first by the second and compare it to your total available physical memory to understand how many Apache processes you can have on this server.
Apache Http Status Code Enum
Knowing the maximum number of Apache workers per server will in turn give you some insight into the traffic you can serve by the server. You can use this information to anticipate future upgrades of your infrastructure.
Watching busy and idle workers
Watching the number of busy and idle workers is a good, proactive way to find Apache configuration problems early enough.
If in case of peak traffic the number of idle workers approaches or hits zero, this may result in some requests being queued; waiting to be processed by an available worker. Such queued requests must wait for older ones to be processed, which results in lower response times of your website. To improve the situation you should consider increasing MaxClients (or MaxRequestWorkers), which is the limit of simultaneous connections. Be aware that more workers will need more server resources, so if you’re short on them (primarily RAM), then changing MaxClients/MaxRequestWorkers will be counterproductive. In this scenario the only way forward is to solve resources bottleneck – upgrade the server or buy another one and load-balance, move static data away from the server.
Tips and tricks
- If you want your mod_status page to automatically refresh at regular intervals, add ?refresh=X to the end of your URL to refresh every X seconds (e.g. http://<YOUR DOMAIN>/server-status?refresh=5)
- To access the status page in a machine-readable format if ExtendedStatus is enabled: visit (e.g. http://<YOUR DOMAIN>/server-status?auto) → it will generate server-status output more friendly for automatic value parsing
- You can combine both parameters together (e.g. http://<YOUR DOMAIN>/server-status?auto&refresh=1)
Apache Mod Status
Most used metrics for System administrators
- server version
- total accesses
- total kBytes served
- CPU load
- uptime
- requests per sec
- bytes per sec
- bytes per request
- worker statuses
Monitoring with Zabbix
Now let’s see how this data can be obtained and parsed by Zabbix. To reuse the configuration it’s best to create Apache monitoring template. Obtaining the status data is easy with HTTP agent item type. Airplay mac os sierra. Add it to the template, set URL to user macro {$APACHE.STATUS.URL} so it could be overridden by a host and add ‘auto’ to the query fields. The data will be parsed by dependent items, so the history can be set to 0, unless you want to keep history of the raw data.
Now the somewhat complicated part – data parsing. It’s possible to parse most of the data with regular expressions, however, parsing the worker statuses (scoreboard) is more problematic. That’s why we will use JavaScript preprocessing to convert the Apache status data to JSON format, which can be easily parsed by dependent items to extract specific metrics.
The data will be converted based on the following rules:
Metric | Prefix in status data | Value | Location in converted JSON |
---|---|---|---|
Server version | ServerVersion: | string | $.ServerVersion |
Uptime | ServerUptimeSeconds: | seconds, unsigned integer | $.ServerUptimeSeconds |
Total requests | Total Accesses: | unsigned integer | $[“Total Accesses”] |
Total traffic | Total kBytes: | kilobytes, unsigned integer | $[“Total kBytes”] |
CPU load | CPULoad: | floating number | $.CPULoad |
Requests per second | ReqPerSec: | floating number | $.ReqPerSec |
Bytes per second | BytesPerSec: | floating number | $.BytesPerSec |
Bytes per request | BytesPerReq: | floating number | $.BytesPerReq |
Worker statuses | Scoreboard: | string of characters according to the scoreboard legend, will be converted to <status>:<number of workers> pairs (statuses with 0 workers will be omitted) | $.Workers.waiting $.Workers.starting $.Workers.reading $.Workers.sending $.Workers.keepalive $.Workers.dnslookup $.Workers.closing $.Workers.logging $.Workers.finishing $.Workers.cleanup Boot from usb on imac. |
The conversion script:
Http Status 404 Apache Tomcat
Now create dependent items to extract metrics from the converted JSON. The items will be similar, having corresponding value type and units. The items will have at least one JSONPath preprocessing step, with ‘Custom on fail’ set to ‘Discard values’ for optional metrics. Check the following table for specific details:
Metric | Item key | Value type | Unit | Comments |
---|---|---|---|---|
Server version | apache.version | Character | ||
Uptime | apache.uptime | Numeric (unsigned) | s | |
Total requests | apache.requests | Numeric (unsigned) | ||
Total traffic | apache.traffic | Numeric (unsigned) | B | As the traffic is in kilobytes, either it should be multiplied by 1024 in the JavaScript preprocessing step, or a new preprocessing step ‘multiply by’ must be added. In this example the second option was chosen. |
CPU load | apache.cpuload | Numeric (float) | ||
Requests per second | apache.requestssec | Numeric (float) | ||
Bytes per second | apache.bytessec | Numeric (float) | B | |
Bytes per request | apache.bytesreq | Numeric (float) | B | |
Worker statuses | apache.workers.waiting apache.workers.starting apache.workers.reading apache.workers.sending apache.workers.keepalive apache.workers.dnslookup apache.workers.closing apache.workers.logging apache.workers.finishing apache.workers.cleanup apache.workers.slot | Numeric (unsigned) |
Org.apache.http.statusline
To test it create a host, link the template and add {$APACHE.STATUS.URL}host macro pointing at the apache mod status URL. After a while Zabbix should collect the Apache status data:
Apache Check Status
The Apache template is attached.