Load balancing

Overview

Load balancing is the task of distributing work between multiples nodes. This can be done for CPU/RAM/Network congestion.

There are several possibilities to achieve this :

  • Split the service in multiples services

  • Use replicas

Split the service in multiples services

The best method to distribute the load is to split one module into multiple different services. The swarm will try to spread the load evenly between each node.

To do this, separate the value/device managed by one module to have two modules (or more) absorbing the load instead of just one.

For example, a module modbus with 10000 values might be spited into 5 modules with 2000 values each.

Note

See Module capabilities Split services for the list of the module supporting this feature.

Replicas

A replicas is a Swarm service instantiated multiples times. This is not supported for most OnSphere services, but some services can be instantiated multiples times to absorb the load.

Note

See Module capabilities Replicas for the list of the module supporting this feature.

Replicas configuration is done inside the Modify the configuration of a service :

For example, deploy the service on each node with the devices label:

deploy:
    mode: global
    placement:
        constraints: [node.labels.type == devices]

or to have a fix number of instances:

deploy:
    mode: replicated
    replicas: 2