HP Virtual Server Environment: Tips for Application Developers
The most flexible solution is to dynamically react to changes in system resource levels. Consider this
approach:
Application starts up, low system load, minimum CPU resources allocated to this partition.
Application queries OS regarding maximum number of cores, allocates two threads per core
to handle workload.
Application queries OS regarding current number of cores, assigns work to two threads per
active core, optimizing context switching, hence performance.
Application begins processing workload, load increases.
Workload manager senses additional load, adds more cores for the application.
Application is notified (via Event Manager) or senses (via polling) additional cores available.
Application activates additional threads to maintain two per core ideal.
Application throughput rises with optimal performance.
Workload manager takes away cores when workload drops.
Application is notified or senses reduction of cores, and deactivates threads accordingly.
In this approach the key performance characteristic (simplistically assumed to be the number of
process threads running on each core) is optimized as the CPU resources change. This delivers the
best performance under all conditions, and allows the customer to move resources where they are
most needed. The application performs better, and the customer can apply the resources to other
workloads as needed.
Polling to determine the current number of cores is a simple extension of the system calls described
above. Note that core migrations take a few seconds, and workload managers typically rebalance
core allocations a few times per minute. Thus polling between once per second and once per minute
is recommended.
An alternative mechanism to discover system configuration changes is to use HP-UX Event
Management (EVM), a new feature available with HP-UX 11i v3. The purpose of an event
management system is to provide a means for any system component or application to indicate that
something has happened that may be of interest to some other entity. The indication is known as an
event, and the component posting the event is known as an event generator or event poster. The
entity interested in the indication is known as an event subscriber. The kernel generates a variety of
events to indicate resource changes in a system, including core migrations and memory migration.
Application developers can subscribe to these events, allowing applications to react immediately to
changes without the overhead of polling.
The Event Manager is a comprehensive event management system that, in addition to providing
traditional event handling facilities, unifies events from many channels to provide a system-wide
source of information.
The programming model for EVM is beyond the scope of this paper, but is thoroughly described, with
excellent sample programs, in the HP-UX Event Manager Programmer’s Guide. See also the evm(5)
manpage.
Running Applications Inside a Virtual Machine
Applications are unaware that they are running inside a virtual machine guest operating system. For
HP-UX guest operating systems, all operating system services are present, and the HP-UX OS running
in the Integrity VM provides full binary compatibility for HP-UX applications.
For virtual machine guests to run optimally, the number of virtual processors in a guest should be no
more than the number of physical cores. Cores may be added to or removed from an Integrity VM