On Friday, October 07, 2016 04:43:56 PM Grant wrote: > >> >>> Swap usage on Linux always seems a little tricky to me. Should my > >> >>> goal on a web server be zero swap usage, meaning the attached graph > >> >>> should show no green lines at all if I'm doing it right? > >> >> > >> >> No. You want things that aren't in use to be swapped, like memory > >> >> leaks and such. You don't want things that will be used to be > >> >> swapped. > >> > > >> > Does this look OK? It looks to me like heavy swapping in and out with > >> > plenty of free memory (minus buffers/cache). > >> > >> Or put another way, how do I know when swapping is a problem? I'm > >> running munin so I can look over graphs of my system's characteristics > >> but I'm not sure what to look for to determine if I'm swapping > >> excessively. > > > > "Swapping excessively" is inherently a use-case-specific problem, but it > > comes down to two questions: > > > > * Do you notice your system spending time in iowait swapping data in while > > you're waiting on it? > > * Do you notice your system spending time in iowait swapping data out > > while > > you're waiting on it? (I.e. as it tries to make room for new memory > > allocations) > > I can't find a good graph for iowait in munin. Is watching wa in top > my best bet?
I've never used Munin. I use Zabbix, which monitors iowait just fine. > > If I do find a correlation between iowait and web server response > times, should I just decrease memory usage until the problem goes > away? There's more than one cause for iowait, so you can't just assume iowait is related to memory consumption. iowait can happen while waiting for files to load in from disk. In this case, freeing up memory to be used by the page cache can help. iowait can happen while waiting for data to be written *to* disk. In this case, finding what's writing to disk and reducing that can help. iowait can happen during swap. In this case, reducing things going into swap can help. You can reduce things going into swap by reducing vm.swappiness (I prefer to set it to 0, myself; swap will be used if and only if there isn't enough memory at the moment). You can reduce things going into swap by tuning applications to use less memory. (With a web server, there are going to be a lot of things to tune here. What is the webserver doing? What web server is it running? Is it running a dynamic application? What language?) > > What I do notice is that my web server's response time increases along > with the swapping peaks in the graph I posted before. Then you're using too much memory, which is leading you to use too much swap, which is causing an I/O bottleneck for you. Can you tell me more about your stack? What is the web server doing? What HTTPd are you using? Are you running dynamic applications? What language? Are you using any caching? -- :wq
signature.asc
Description: This is a digitally signed message part.