Yesterday I configured cacti to monitor PostSharp servers. After one day of operation, I was stroked by this graph. The green area shows disk I/Os per second.
The peek corresponds to a system reboot. What is striking here is the look of the curve: it is approximately an exponential decay (with a negative exponent):
read(t) ~ b * [ (WS - R) + c * exp(- lambda * t) ]
where WS is the data working set (the amount of data your server need for normal operations), R is the amount of RAM available for cache, and b is proportional to the read flow and c and lambda are some cache filling rates.
This kind of curse is called an exponential decay.
Note that it takes a fair amount of time for the cache to be full (about 4 hours on this server). When the cache is full, there is a nearly constant read flow, about 20 KB/s here.
Should we deduce from this graph that it would not pay off to add much RAM? that the relationship between RAM and performance is an exponential decay as well?
Don’t go so fast! First, we have to understand where does this exponential decay come from.
At any time, the server needs to read some data. Suppose the probability that some data is required is uniform. The probability that the data is cached is directly proportional to the size of the cache. Therefore, the amount of data I have to read from disk is proportional to the amount of non-cached data. So we must explain why the amount of non-cached data looks like an exponential decay.
The differential equation of dynamics with exponential decay is:
Does it confirm our hypothesis? Yes! It means that the cache increase rate is proportional to the amount of non-cached data. This is exactly our initial hypothesis.
That are the maths. But what about reality? Can we believe the hypothesis that “some data is required at a given time is uniform”. Not at first sight, but if we look twice it is probable. Of course, some data is much more frequently required than other. This seems to break our assumption. But remember that we just consider disk cache, which is the last-resort cache. All executable code is already in memory; applications have their own cache (MySql, ASP.NET, Apache). So it is plausible that the remaining data has uniform probability of being accessed.
When something unusual happens (for instance some maintenance), the nice curve is disturbed, cache is filled with something less useful (or less useful at long term), and the exponential decay restarts as soon as the maintenance task has finished!
Interesting discussion around a simple graph, isn’t it?
Recent Comments