Computing Memory Usage in SLM
As the server administrator, you may often need to properly set the amount of memory this or that Container will be allowed to consume. Therefore, you should have a clear idea of the memory computation mechanism used in the SLM scheme. On the whole, the memory usage inside every particular Container for which the SLM functionality is enabled is calculated in the same way as it would be done on a standalone server. It means that the same set of applications running inside a Container will require approximately the same amount of RAM for their functioning as it would require on any other standalone server. Consequently, the amount of memory to be allocated to any Container largely depends on the number of applications you are going to deploy inside the Container and their memory requirements. For example, if you are going to use your Container as a web server only, there is no need to allocate much RAM to this Container (e.g. no more than 50 MB). At the same time, running such memory intensive applications as MySQL, Perl, PHP requires the memory limit be set to no less than 300 MB.
The situation above provides only the general description of memory usage inside Containers. In fact, the process of memory computation used in the SLM scheme is more complicated. It includes the calculation of the
oomguarpages
,
kmemsize
,
lockedpages
, and
socket buffer
parameters and the unification of these parameters into a single
slmmemorylimit
parameter. It also assumes a number of accounting rules to be taken into consideration while deciding on the amount of memory to be allocated to a Container. The main rules are given below:
-
The memory allocated to a Container includes both memory itself and the swap space.
-
The memory consumption inside a Container is calculated by taking into account the data sharing among applications. So, if two Containers share one and the same memory page, each Container is considered to consume half a page. As the number of Containers sharing the same memory pages grows, the memory consumption inside each of these Containers decreases. Thus, an application running inside a Container can consume much less memory than the identical application launched in the Host OS or on a standalone server. Especially much data can be shared when Containers use the same versions of applications and shared libraries (e.g. in the case of using the same versions of the
apache
Web server with the same set of modules and the same versions of system libraries). In such cases the difference in memory usage may reach tens of megabytes.
-
The total amount of used memory and swap space in the system is computed on the basis of the memory consumption inside all Containers plus memory usage in the Host OS.
|