VMware Cloud Community
vmwsa
Contributor
Contributor

Physical RAM and swap - question.

Hello,

I have some confussion regarding how RAM/SWAP is managed by ESX.

#1. Configured RAM on VM.

is this the max. RAM size ESX server will allow specific vm to use ?

if so, I guess "limit", "reservation" and share concept will rarely (over-commit situation) appy to memory resources ?

#2. vswap file and its properties

I create a vm and power on , I see (in ls -l ) vswap equal to the size of RAM configured. but when I run du, vdf, df before and after starting the vm I do not see any change in size ? .

Does it realy occupy any space on physical disk ?

#3. vswap file and swap partition of guest OS.

Resource managment guide says you should have vm's swap atleast equal to physical RAM configured on the vm, so that in case if ESX fails, you data can be relocated there, ..I thought vswap fileshould be used to hold such data pages - no ?

Reply
0 Kudos
5 Replies
weinstein5
Immortal
Immortal

#1 Available RAM the guest will be told it has access to - if you set a limit this will cap the consumption of memory - reservations and shares both come into play if their is an overcommittment situation - reservation will guarantee a certain amount of memory while shares will help the vmkernel allocate the available memory to the vm - the higher the shares the more memory the vm will receive when there is contention -

#2 Yes it occupy space on the disk equal to the available memory minuse the reservation - this allow the vmkernel to swap the vms entire contents of memory out to disk -

#3 That does not make sense - if your esx server fails than your vm has failed - and yes ot os the vmkernel swap that is configured for that -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos
vmwsa
Contributor
Contributor

thanks you for quick respose...

#1. Say I have 32GB host, with 5 vms , each given (configured) 4gb ram, and 6th one with 20GB configured RAM. I set no reservation, I see limit is unlimited ( by default.) and share is normal.

A. if any one of the 5 VM application needs 10GB RAM , will guest os use swap ? or ESX will allocate physical RAM since it still have unused/unallocated ram ?

B. Does it make sanse to use "limit" more then 4GB for this configuration ?

C. If I change one of the 5 VM's configuration and set share to high, does that mean that vm will get 12.8 GB ? even the configured RAM is 4GB ? remaining for normal share ?

#2. why df -k do not show any diffrance before/after power on/off of the vm? ( do you thing some issues with configuration ? )

#3. I must be missing something. may be above two may help me understand this.

Reply
0 Kudos
weinstein5
Immortal
Immortal

A. - assume you mean the 5 vms with available memory set to 4 GB RAM - all the VM needing 10 GB will get is 4 GB of physical RAM the guest o/s will have to use its own virtual memory - the ESX will not allocate any more RAM then what is assigned (4 GB)

B - No since the vmkernel will only assign what is set as the vailable RAM in the VM - the unlimited setting is a bug in vi-3 3.5

C - no - shares do not work that way - lets say all six vms have equal shares and are set to 8 GB of RAM instead of 4 GB - so when all six need RAM they will require 48 GB but I only have 32 GB - memory is over ccommitted - the memory will be divided up equally each has an equal share so they each will get 1/6 of 32 GB - lets say one of the vms is critical and you want to make sure it gets more memory when there is contention and we set it shares to 3000 while the remaining 5 each has 1000 shares - so my total pool is 8000 - how does it all get divided the critical vm will 3000/8000 of the 32 GB - or 12 GB but its available memory is set to 8 so it will get its full allocation of 8 GB the remaining 5 vms will each get 1000/8000 of the remaining 24 GB or 3 GB each - I think you are not seeing changes in the df command because you need to run the vdf command - df designed for the esx host -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
vmwsa
Contributor
Contributor

Thanks very well explained..

Just to make sure I got this right.....let me say this way...correct me if this is not right

There is a algorithm that ESX follow for any vm (or it's apps) that needs more RAM ..and does accordingly.

If vm has limit ( which is less then configured memory - do not make much sense though. say limit is 4gb and configured ram is 8GB) then do not give more then 4GB.

if there is no limit then, check what is the amount configured for the vm. In no situation ESX will give that vm more then that.

If vm is configured to have more RAM, let me check if I have unreserved RAM if so ESX will give it to vm. ( If ESX do not have free RAM, may start balloon)

While doing so ESX must follow the shares allocated for each VM , but if memory pages are not active ESX can give that to seeking vm. this will be done of best effort basis - no guarantee though.

If vm has reservation, then I must find that ram for it, even by taking away from other VM which do not have reservation.

Reply
0 Kudos
weinstein5
Immortal
Immortal

  1. I see a limit as more of a stop gap for instance someone builds a vm with 64 gb of RAM but you know as the administrator know that is crazy - the vm is up and running and you do not want to cause an outgae you can dynamically set the limit -

  2. You are correct - if the limit is 'unlimited' the esx server (vmkernel) will never give it more memory than the amount configured

  3. As vms consume ram in your esx server there can/will be a point where the server has no physical ram available for vms - yes balloning will occur forcing the vms to swap to their own guest virtual memory

  4. to explain shares lets consider your memory is a dinig room in a restaurant - each vm fills the shairs - you have 10 vms wanting seats each configured with 20 chairs maximum - as long as all 10 are using less then the 100 chairs there is no contention so shares and reservations will not come into play - now lets assume all 10 vms need their 20 chairs what happens - with no reservationsbut equal shares each vm will get an equal number of chairs - so 10 in the dining room but they need 20 - the remaining 10 shares come form the per vm vmkernel swap file or in the restaurant anaology they are seated in the patio converstion is difficult (and like in the real world this vmkernel swap space is memory of last resort) - now lets assume two of the vms have reservations of 10 chairs - in the situation just described how does it all get carved up - well the 2 vms will 10 chairs leaving 80 chairs to be devided - so the 2 with the reservation will get 18 chairs and only 2 will be out on the 'patio' - the ther 8 will have 8 chairs each in the dining room and 12 on the 'patio' - hope this helps

  5. continuing the restaurant analogy - if all the chairs are reserved by the running vms but 90 are empty and a new vm tries to come and wants a reservation they will be turned away because the reservation can not be gauranteed or in the real world the vm will not start

Note I really did not touch on the balloon driver or transparent page sharing technologies the vmekernel uses to economize on memory

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos