Limiting the number of service instances that can run on a host
Use this feature to limit the number of service instances that an application can run on a host; for example, you have an application that consumes a lot of memory and you want to limit the amount of memory that the application consumes on a host.
This feature uses the configured number of resources on a host to limit the number of service instances that can run on the host. A host resource can represent almost anything installed on a host such as a software license, a graphics accelerator, and so on, or it can represent a virtual resource. By specifying the number of resources on a host, you can effectively control the number of service instances that an application can run on that host. When an application needs the resources, EGO does not distribute slots to it from a host unless there are sufficient available resources on that host.
In essence, this feature allows a particular type of application to run only N service instances on a host with M slots where M >=N. The remaining slots can be used by other applications.
- A cluster is made up of 25 compute hosts. Each compute host is configured to have 4 resources.
- Application1 is configured to need 2 resources to run each service instance.
- Application2 is configured to need 1 resource to run each service instance.
100 long-running tasks are submitted for Application1 and Application2.
- On the hosts that only run tasks for Application1, there will be at most 2 tasks.
- On the hosts that only run tasks for Application2, there will be at most 4 tasks.
- On the hosts that run tasks for both Application1 and Application2, there will be 1 task for Application1 and 2 tasks for Application2.
Feature interactions
This feature is not compatible with the exclusive slot allocation policy; refer to Exclusive slot allocation.
Configuration
Configure the resource name
Open the ego.shared file. In the Resource section, specify a name for each type of resource you want to configure.
For example:
Begin Resource
RESOURCENAME TYPE INTERVAL INCREASING DESCRIPTION # Keywords
...
limited_res Numeric () N (the number of resources on a host) ...
End Resource
The first line consists of the keywords. RESOURCENAME and DESCRIPTION are mandatory. Keyword TYPE must be set to Numeric for resources used by this feature. The other keywords are optional. Subsequent lines define resources.
Configure the number of host resources
You can either specify the number of available resources on specific hosts or you can set the number of resources as a global default for all hosts in the cluster. The global default also applies to any dynamically added hosts whereas the host-level configuration only applies to static hosts. Note that these two methods of configuration are mutually exclusive and only one method can be used at one time for the same resource.
- Open the ego.cluster file. Do one of the
following:
- To configure the number of resources on specific hosts, follow this step:
In the Host section, specify the host name, the resource name, and the number of resources available on the host.
For example:
Begin Host HOSTNAME model type r1m mem swp RESOURCES #Keywords HostA ! ! - - - (limited_res=5) HostB ! ! - - - (limited_res=3) End Host
- To configure the number of resources as a global default for all hosts in the cluster, follow this step:
In the ResourceMap section, specify the resource name, and the default number of resources available on every host.
For example:
Begin ResourceMap RESOURCENAME LOCATION ... limited_res 1@[default] ... End ResourceMap
- To configure the number of resources on specific hosts, follow this step:
- Open the application profile. In the consumer section, configure the number of resources each service will consume
on each host you specified in the ego.cluster file. For example:
In this example, the application needs 2 resources to run each service instance.... <Consumer applicationName="newApp" resReq="rusage(limited_res=2)" ...> ...
View the host resources
You can view a list of resources configured for each host using the CLI. For example, to view the "limited_res" resources, run the following command:
egosh resource list -o limited_res