CPU and Memory Resource Allocation

To allocate resources, use the
cpuAllocation
and
memoryAllocation
properties of
VirtualMachineConfigSpec
. Both properties contain
ResourceAllocationInfo
objects with the following properties:
  • reservation
    – Amount of resources that is guaranteed to be available to the virtual machine. If resource utilization is less than the reservation, other running virtual machines can use the resources.
  • limit
    – Upper limit for CPU or memory resources assigned to this virtual machine. The virtual machine does not exceed this limit, even if resources are available. This property is typically used to ensure consistent performance. If end users are used to work on a virtual machine that uses extra resources, and additional virtual machines are added to the host or resource pool, the virtual machine might slow down noticably. If set to -1, no fixed upper limit on resource usage has been set.
  • shares
    – Metric for allocating memory or processing capacity among multiple virtual machines. The
    SharesInfo
    data object has two properties,
    level
    and
    shares
    .
    • level
      – Choose
      high
      ,
      low
      , or
      normal
      to map to a predetermined set of numeric values for shares. See the
      API Reference Guide
      for the numbers for CPU, memory, and disk shares. Set this property to
      custom
      to specify an explicit number of shares instead.
    • shares
      – Allows you to specify the number of shares you want to allocate to the resource pool. The allocation is divided evenly between resource pools with the same level.
Resource Allocation discusses resource allocation in the context of resource pool hierarchies. The
Resource Management Guide
includes a detailed discussion of resource allocation in the vSphere environment.