You are not aware of this, but you are actually using virtual memory for all of those already.
In essence, by default linux kernel will allow processes to map
more memory than you have available on system. Most of that memory is not actively used so trick is to use virtual memory.
Linux kernel makes this nice trick and allows processes to map as much memory as they need, even more than system has.
For example, when process requests 1 GB of memory, kernel says ok here is your 1 GB of address space. Process does not use all this 1 GB, but say rather 100 MB, so kernel knowing that only 100 MB is used says; ok this 100 MB will be in RAM; but other 900 I will consider as possibly used in future and by doing so it allows other processes to request more memory regardless of you having physically only 1 GB.
At some point if processes checked out too much memory; kernel has heuristics to calculate pressure if memory reserves are getting low, it tries to free up some memory segments. Options in short are to drop some memory segments that are backed by filesystem (files loaded in memory), move some memory portions that were not used for a while to 'swap' (killing your disk IO)
In your example you can easily have memcache with 32 MB ram assigned, redis with 32 MB too, keep an eye on usage of memory in memcache per slabs. Redis will also be happy with 32 MB up to a point when it uses all 32 MB and it starts to check what was least used in it's memory to evict it (depending on usage of redis)
Memcache things to keep in mind.
Total memcache memory is split in X equally sized portions. Each portion is called slab
and it accommodates key-value pairs of certain size range.
Some slabs
may be full; some may be empty; depending on size of values stored in memcache. There is no way to statically define size of slab, and range of values it will be holding.
Once data is in memcache slab, it will get evicted either when
- it's lifetime expires
- slab is full and to fit a new key-value pair in slab, least used one needs to be pushed out
You need to check your memcache stats, if you're not doing many evictions you don't need to increase memory limit for memcache because it's doing great, and the hit count you mention is great too because those hits are served from memory; and not from some database which is slower data source.