Memcached Caching Strategies?

I am new to using distributed caching solutions like Memcached on a large website, I have a couple of questions and maybe someone who is experienced in this comment please.

  • Obviously, the amount of data that I can put in the cache depends on the RAM of the server. Suppose I have a fairly large server farm and RAM, is there a maximum number of objects that I can put in memcached before I start to see performance degradation? The reason I ask is because I believe that if I put literally millions of objects in memcached, would it not take longer to index and search for objects? Is there a line for drawing here.

  • Should I cache fewer but more objects in memcached or more but fewer objects? Smaller objects include more round trips to the database to get them, but they are more flexible and easier to program.

Many thanks,

Ray

+7
design architecture memcached scalability
source share
2 answers

Memcached uses a hash inside to have an O (1) lookup - it is designed to do the most complex work possible.

As for caching, big or small, this is really what you need to save, it will save you strength (bearing in mind the big stupid cache, you need to help maintain synchronization if you change one part, which is also mentioned elsewhere). On the original site, it was written for Livejournal.com, the biggest block that made sense was one complete journal entry - like ready-made HTML that anyone who was allowed to see this particular post could use it.

I used it for very small records - literally one number with a participant identifier, but I generate several thousand such en-mass records with one database query, and not one at a time as required.

You can optimize the daemon a bit if you know that you will only store very large or very small elements, but for many small records it has enough skills to divide empty large memory plates into smaller pieces for use.

+4
source share

Suppose I have a fairly large server farm and RAM, is there a maximum number of objects that I can put in memcached before I start to see performance degradation?

Ideally, your cache should be 100% full at all times. memcached uses a hash algorithm to find keys, so as far as I know there should not be a performance penalty for storing more keys.

Should I cache fewer but more objects in memcached or more but fewer objects?

I would suggest that more, but fewer objects are preferable to reduce the search time for both the database and the cache, but you should take this on a case-by-case basis. If you do not know that the difference in performance will be radical, I would advise you to start with the fact that it is easiest to start and work from there if this is not enough.

+3
source share

All Articles