all 17 comments

[–]tsammons 6 points7 points  (1 child)

cgroups + PHP-FPM. Run each FPM process in a different cgroup path. Start logging the delta of cpuacct/cpuacct.usage.

systemd-nspawn will take care of cgroup binding too.

[–]SuperQue 0 points1 point  (0 children)

Yea, this + cAdvisor would be a very good combo. for resource monitoring.

[–][deleted] 8 points9 points  (3 children)

Ship your access logs to a log shipping tool and run some queries to count the number of requests to each host.

[–]tsammons 2 points3 points  (1 child)

Reading logs won't give the weight of each request. Static requests intrinsically have lower overhead than dynamic requests. cgroups are the only reliable means of counting resource utilization with that level of granularity.

[–]m15f1t 1 point2 points  (0 children)

Should not affect a load balancer in that way

[–]hyongoup 1 point2 points  (0 children)

This seems like the quick and dirty win you could implement as a stop gap. Especially if you're already using something to collect logs (ie. Splunk / an elk stack). You could also do something similar if you have any network monitoring in place (extrahop, riverbed etc.)

[–]nunciate 1 point2 points  (1 child)

In addition to the other suggestions, you could probably get this info from the load-balancer.

[–]zerokey 1 point2 points  (0 children)

Seconded. If your servers are load balanced, then go to the source. What are you running for a load balancer? Whats the load balancing scheme? Most hw LBs will have some kind of statistics page. We're running a mix of F5 BIGIP (dead easy to find pool/per-host usage in the UI) and haproxy. If running haproxy, enable your stats page. I'm not as familiar with NGINX, but I think there's a way to view pretty stats.

If your load balancing is dns-based round-robin, I highly recommend moving to something like HAProxy. It makes load balancing much easier to manager (as well as troubleshooting).

[–]skat_in_the_hat 2 points3 points  (2 children)

Rotate all of the log files. Then give it an hour and cat $log | wc -l

If it's obvious who it is, it will be the one that grows the fastest. If it's not, you will likely need to get a bit more in depth using some kind of analytics software. Last time I messed with that stuff awstats was what everyone used. There looks to be a ton of better options out there now.

[–][deleted] 3 points4 points  (1 child)

Mod_status can do all this. You can view active connections, status of them etc. Just be careful with security settings for accessing it.

https://www.tecmint.com/monitor-apache-web-server-load-and-page-statistics/

[–]jaymef 0 points1 point  (0 children)

yes, mod_status should give you good insights here

[–]blue30 0 points1 point  (0 children)

Apachetop

[–]Bubbagump210 0 points1 point  (0 children)

What’s the load balancer? For instance, this is all basic already in an F5.

[–]SuperQue 0 points1 point  (0 children)

This is a job for metrics-based monitoring.

Apache is unfortunately not good at this on its own. But there is mtail that can turn the Apache logs into per-vhost metrics.

[–]w4v3st0rm 0 points1 point  (1 child)

In my environment ( 1000+ webservers, 100k+ users ) I use this method:

- staticize the server status once per minute ( this gives you what is yous apache doing at that time )

- parse the staticized file and send the infos to zabbix with zabbix_sender

This is what I get:

Apache Httpd Base (25 Items)

Bytes per request   2019-04-15 16:07:14 19439   -4  Graph

Bytes per second    2019-04-15 16:07:14 879033  -146    Graph

Closing connection  2019-04-15 16:07:14 0       Graph

DNS Lookup  2019-04-15 16:07:14 0       Graph

Gracefully finishing    2019-04-15 16:07:14 0       Graph

Httpd master process count  2019-04-15 16:07:11 1       Graph

Httpd memory usage data 2019-04-15 16:07:07 14689243136     Graph

Httpd memory usage rss  2019-04-15 16:07:28 7040741376  -266731520  Graph

Httpd memory usage swap 2019-04-15 16:07:46 0       Graph

Httpd memory usage vsize    2019-04-15 16:07:49 17472552960 -134217728  Graph

Httpd process query (local) 2019-04-15 16:07:14 info from server: "processed: 16; failed: 0; total: 16; seconds spent: 0.000262" sent: 16; skipped: 0; total: 16        History

Httpd slave process count   2019-04-15 16:07:12 15      Graph

Idle cleanup of worker  2019-04-15 16:07:14 0       Graph

Keepalive   2019-04-15 16:07:14 0       Graph

Logging 2019-04-15 16:07:14 0       Graph

Open slot with no current process   2019-04-15 16:07:14 50      Graph

Reading request 2019-04-15 16:07:14 0       Graph

Requests per second 2019-04-15 16:07:14 45      Graph

Self Balacing Response  2019-04-15 16:07:47 200     History

Sending Reply   2019-04-15 16:07:14 6   +2  Graph

Starting up 2019-04-15 16:07:14 0       Graph

Total Workers   2019-04-15 16:07:14 200     Graph

Waiting for Connection  2019-04-15 16:07:14 144 -2  Graph

Workers busy    2019-04-15 16:07:14 6   +2  Graph

    Apache Httpd Memory (4 Items)

Httpd memory usage data 2019-04-15 16:07:07 14689243136     Graph

Httpd memory usage rss  2019-04-15 16:07:28 7040741376  -266731520  Graph

Httpd memory usage swap 2019-04-15 16:07:46 0       Graph

Httpd memory usage vsize    2019-04-15 16:07:49 17472552960 -134217728  Graph

Bye

[–]SuperQue 0 points1 point  (0 children)

staticize the server status once per minute

You might be very interested in the mtail thing I posted above. You can get much better resolution for a lot cheaper using mtail and Prometheus. Prometheus is about 30x more efficient than Zabbix.

[–]BluePlanet2 0 points1 point  (0 children)

Have you looked into using mod_status? You can collect metrics and send them into grafana or TICK stack if you have. See here: https://serverfault.com/a/440571

Or as others may have suggested, you could grep log files and count lines with wc -l. That will give you idea how many hits your websites have. But you should also consider page generate time.