2

I just started to use memcached on a VPS with 2Go of RAM.

I set the cache size at 512 Mb, but I am wondering if I can go for 1024Mb.

On the VPS there are:

  • a local business website with very few connections (like up to 10 sessions a day at best, only anonymous users), once in a while a webmaster updates content.
  • An award website inactive (which will probably move somewhere else);
  • a few dev sites I am the only one to use.
  • And hopefully I can put another local business website later (and maybe remove some of the dev sites).

Watching the top command when activating 4 sites (1 as anonymous, 3 as authenticated user), I notice the memory usage go up to 700Mb, so up to 1.3Gb free. I use Apache.

The current loading time per page is between 2 and 3 seconds, except the first page which can go for 5-8 sec for the less used sites. The idea is to maybe increase the cache to have more indexed paths and pages.

But I read a bit about the risk of swapping. So I am wondering what's the best choice in order to optimize page load for the 2 local business websites + maybe 1 sandbox and 1 dev site.

alexus
  • 12,342
  • 27
  • 115
  • 173
Tritof
  • 159
  • 1
  • 1
  • 8
  • 2
    have you checked how much it actually utilized? – alexus Sep 12 '14 at 16:33
  • possible duplicate of [Can you help me with my capacity planning?](http://serverfault.com/questions/384686/can-you-help-me-with-my-capacity-planning) – kasperd Sep 13 '14 at 08:30
  • i don't think it is a duplicate, the question you are linking to seems to me very much more general and abstract, there are no datas, only many questions. I am providing datas, and just ask one question framed in a specific configuration. If it is still not narrow enough it is because my knowledge on that topic is currently limited as I am learning. So I am sorry, I am learning and hopefully can use this website for it. I'll try to be more specifics when my knowledge will allow me to. – Tritof Sep 13 '14 at 12:33

1 Answers1

2

You are most likely good with something very little like 32mb...

Only a very busy application using memcache that stores great diversity of data may be able to make use from more memory...

If you have busy application memcached items will expire very quick if diversity is high. Memcache memory is split in multiple slabs (sections). Each slab/section gets N-th amount of memory of the total mem you assign to it. Data key value pairs of particular size particular size range are always stored in slab/section which accepts items in that size range. Having said that it takes a great diversity of data you are storing of particular size to fill up slab/section faster than keys normally expire to give you reason to increase memcached memory limit.

for more insight in how your memcache is used you may want to check http://dev.mysql.com/doc/mysql-ha-scalability/en/ha-memcached-stats-slabs.html

Ideal setting for memcache is the one where you get minimal value possible where you have acceptable number of 'evictions' (records removed from cache to make room for new ones). This can be read nicely from some graph/trend or inspected manually; for more info check http://dev.mysql.com/doc/mysql-ha-scalability/en/ha-memcached-stats-items.html

If your apps are written in PHP and you want better performance; you may want to consider using some PHP opcode cacher like APC, OPcache or Xcache depending on your PHP version.

Hrvoje Špoljar
  • 5,162
  • 25
  • 42
  • Thank you very much for the documentation, I can find my answer in these. APC is planned to be my next learning step :) – Tritof Sep 15 '14 at 08:46