cdugga
cdugga

Reputation: 3859

How to calculate a safe cache size?

I have a feature which calls out to an upstream service and loads some content. The content being loaded is only updated about once every 4 hours making it a good candidate for caching.

Is there a process/algorithm or set of steps I can follow to calculate the optimal cache size which will not effect the overall performance of my application servers? Something like

  1. Calculate size of each object being cached
  2. Calculate the number of items which could potentially be cached ( this would be the total number of all requests for the feature in question)
  3. Calculate the delta between the amount of memory each of the application server JVM's has versus what it is using.
  4. Somehow calculate a safe percentage of this delta which could be used?
  5. Calculate the number of objects based on the value calculated in the above step

Step 4 is particularly vague, if anyone can provide some process for calculating cache it would really help.

Upvotes: 1

Views: 1078

Answers (1)

Chris K
Chris K

Reputation: 11927

The quick answer is no. There are more variables in cache design than just object size and amount of memory. As one constrains the situation, then an answer may start to appear however it will then hardly be a generic answer useful for all cache designs.

The best process remains, think about the problem, come up with ones best guess. Implement that, measure it. Adapt it and measure again.

Upvotes: 1

Related Questions