Time for action – specifying space for memory caching
We can use extra RAM space available on a running system after sparing a chunk of memory that can be utilized by the running process under heavy load. To find out the amount of free RAM available on our system, we can use either the top
or free
command. To find out the free RAM in Megabytes, we can use the free
command as follows:
$ free -m
For more details, please check the top(1)
and free(1)
man pages.
Now, let's say we have 4 GB of total RAM on the server and all the processes are running comfortably in 1 GB of RAM space. After securing another 512 MB for emergency situations where running processes may take extra memory, we can safely allocate 2.5 GB of RAM for caching.
To specify the cache size in the main memory, we use the directive cache_mem
. It has a very simple format. As we have learned before, we can specify the memory size in bytes
, KB
, MB
, or GB
. Let's specify the cache memory size for the previous example:
cache_mem 2500 MB...