5 ms·
How CPU load averages work, and using them to triage webserver performance
- jbert 11y agoIsn't the calculation (assuming (for simplicity) one CPU, running at 100% only on application load) 60 requests/sec => each request takes 1/60s CPU-second == 16.6ms of CPU time to process? (This is time-on-cpu, and doesn't include time-waiting-for-cpu. I think time-on-cpu is the number you want if you're looking at optimising your codebase)
- deathanatos 11y agoShe does mention: > each request was taking 6 / 60 = 0.1s = 100ms of time using-or-waiting-for-the-CPU. (emphasis mine) In my original read, I thought her core count was greater than her load, so that would also be her direct time-on-cpu. Now I'm not so sure. And while time-waiting-for-cpu might not be important to optimizing the codebase, you probably still want to know that your serving processes are waiting for CPU; after all, it is that number that your user's browser is seeing (at least, between the two it is moreso that one). Such a result might indicate a larger machine or more machines are required, for example.
- cperciva 11y agoPretty much. If you want to get fancy you can make assumptions about the distribution of request arrival times and use the mean queue length of 6 to estimate the fraction of the time when the queue length drops to zero; you probably come out somewhere around 10% CPU idle time, so each request is taking 15 ms to process rather than 16.6 ms. But cpu-time-per-request is definitely the number you want to pay attention to. If you cut that by a factor of 2, you won't decrease the load average from 6 to 3; you'll decrease it from 6 to less than 1.
- halayli 11y agoAny decent web server shows the response time. This can easily be verified. I am not sure why such number isn't tracked in the first place.
- catchmrbharath 11y agoOne of the best articles I read on the subject was this http://blog.paralleluniverse.co/2014/02/04/littles-law/ http://blog.paralleluniverse.co/2014/02/04/littles-law/
- sserrano44 11y agoLoad average measures how long is the queue of processes waiting for the CPU. Most web applications aren't CPU intensive, rather they depend on many other services like the database, S3, ... If a web worker is waiting for another service it should release the CPU until the service responds. So is entirely possible that all workers are waiting for other services, your app is not responding and the CPU is free.
- creshal 11y ago> If a web worker is waiting for another service it should release the CPU until the service responds. Emphasis on "should". With your average drivel (Wordpress e.g.) this doesn't happen and the load on the application server scales nicely with the response time of the database server. 10 requests waiting on a locked table for 2 seconds = load of 10.
- Arnt 11y agoIf a service waits for another service, then that other service often contributes to CPU load. Not always, no...
- creshal 11y agoNot when the other service is on another machine, like in the case I described.
- Arnt 11y agoSorry, I was sloppy. I meant that it generates CPU load somewhere (or I/O load, for those OSes where those two are cleanly separated). If you measure the CPU load on half the CPUs that are involved in serving a user, you're not really measuring anything. Ditto if you're outsourcing (parts of) the backend and not measuring the outsourced service level.
- creshal 11y ago
- deleted 11y ago[deleted]
- heinrichhartman 11y agoBe aware, that load averages are exponentially damped averages not moving averages over windows of length 1,5,10 mintues. More quirks with linux performance tools are outlined in Brendan Gregg's talk: http://www.slideshare.net/brendangregg/broken-linux-performance-tools-2016 http://www.slideshare.net/brendangregg/broken-linux-performa... https://www.youtube.com/watch?v=9U4jFpsEyYE&t=150 https://www.youtube.com/watch?v=9U4jFpsEyYE&t=150
- daveguy 11y agoRelated, but not the same... There was an article on HN about various tools to evaluate resource usage in the last month or two: top, lsof, netstat, etc. I think it was put out by a big name in web services: Netflix, Amazon, etc (but I'm not sure). I was sure I had it bookmarked, but I haven't been able to find it. Does anyone remember that post or have it readily available?
- severine 11y agoThis? https://news.ycombinator.com/item?id=10654681 https://news.ycombinator.com/item?id=10654681