Friday, 25 November 2011

Using MEMCTL (with MEMSZ), SWAP, and ZIP to diagnose a memory bottleneck in ESXi

Following on from a comment posted on a previous post, here's a quick explanation of why MEMCTL (with MEMSZ), SWAP, and ZIP can be used to diagnose a memory bottleneck at the ESXi host level.

First: Definitions


MEMCTL (MB) = displays the memory balloon statistics.
MEMSZ (MB) = amount of memory allocated to a virtual machine.
SWAP (MB) = displays the ESXi swap usage statistics.
ZIP/s (MB/s) = compressed memory per second

Second: Why we might want to look at these?

SWAP (MB) – if an ESX(i) host is excessively swapping memory to disk, this points to the ESX(i) host suffering memory contention issues. VMs should either be moved or powered off from the host in question (if this is not an option then it is time for either a memory upgrade or to introduce a new ESX(i) Host into the environment.)

MEMCTL (MB) & MEMSZ (MB) – need to look at these two metrics together. Ballooning as displayed by MEMCTL is not always a problem and could indicate that guest VMs have been over allocated memory (see MEMSZ for guest memory allocation;) also, if an administrator has set a VMs memory limit lower than the memory allocation, this will cause the VM to balloon. If have been careful to correctly allocate memory to guest VMs, then excessive ballooning again points to the ESX(i) host suffering memory contention issues; basically the host is taking memory away from inside guest VMs by using the memory balloon driver installed along with VMware tools, with this memory being written to the vswp file.

Remember that – unlike in the physical world – in the virtual world throwing too much resource at a virtual server can actually result in less performance.

ZIP/s (MB/s) – if an ESX(i) host is compressing memory pages, this points to the ESX(i) host suffering memory contention issues. You will never see memory compression activating for a guest on a host with plenty of memory to spare (unless an administrator has configured a guest VMs memory limit lower than its allocation.)

Third: Where can we see these?

Easiest way is to SSH to the ESXi host (the host in the example below is a vSphere 5 host,) run the command

esxtop

Type a lowercase m when in esxtop to display memory stats as shown in the image below (SWAP, MEMCTL, and MEMSZ are circled in red):


Appendix: esxtop interactive commands

When in esxtop, type a lowercase h to bring up the help screen as below. Press any key to exit this display.

Interactive commands are:

fF Add or remove fields
oO Change the order of displayed fields
s Set the delay in seconds between updates
# Set the number of instances to display
W Write configuration file ~/.esxtop50rc
k Kill a world
V View only VM instances
L Change the length of the NAME field
l Limit display to a single group

Sort by:
M:MEMSZ B:MCTLSZ N:GID
Switch display:
c:cpu i:interrupt m:memory n:network
d:disk adapter u:disk device v:disk VM p:power mgmt

No comments:

Post a Comment