I am trying to figure out, why Apache sometimes processes request very slow. The most time, the "Time To First Byte" is adequate (~ 90ms), but sometimes there are peaks greater than a second.
I am monitoring three PHP pages:
- start page
- gallery page
- detail page
and as reference
- a static HTML page
While the PHP pages have sometimes (not periodically) values up to one or more seconds, the static HTML page is not affected by slow response times. Also remarkable is, that the peaks in processing time for all three PHP pages are almost congruent.
For monitoring I run curl in the same network and send requests to the webserver directly (hostname). The request does not pass any caches. The monitored processing time is calculated as follows:
Time from start required to send the requestminus time from start until the first answer byte was received from the server.
The three PHP pages use memcached (127.0.0.1) and content from a MySQL (host: hostname) database. Apache is configured with PHP-FPM (socket).
The LOAD, CPU-, MEMORY-, DISK-utilization and the time for name resolution seem not to be problematic.
A little stress test for memcached statet out, that it continiously responds quickly. I think, the problems scope could be the database. In another Post here in Server Fault I've read, that some system or kernel paramters could cause this behavier. Unfortunally, I do not know, which parameters are typically for this situation.
I could strace apache and/or xdebug php - but the slow time to first byte is every few hours. So I could try to debug for hours and there will not happen a slow processing.
So my question results in: Do you have any hint, how could I concrete investigate the problem? And in relation to the other post: Are there typical system/kernel parameter, I should have a clooser look to?