### Load balancing

In the cluster environment, JReport Enterprise Server provides a mechanism named load balancing which enables the server to work more effectively.

When a clustered server receives a task, it will send a load balancing request to the admin server. After receiving the request, the admin server can use one of the four algorithms JReport provides to select a clustered server, and then allocate the task to it.

Here are the benefits of deploying load balancing in a JReport Enterprise Server cluster.

- Automatically allocates tasks to suitable servers according to their current load and performance.
- Makes sure that all of the servers in the cluster are fully utilized.
- Automatically re-balances the network load when one server is added or removed.

Note: You can directly specify a server in a cluster to perform a scheduled task or an advanced-run task instead of using load balancing. To do this, first make sure that the Identify Server Preference option is enabled in the Profile dialog (Profile > Customize Server Preferences > Advanced > Identify Server Preference), and then use the With Load Balancer, prefer a server to run the task option in the Format tab of the Advanced Run dialog or the General tab of the Schedule dialog to specify a server manually.

#### Load detection

There is a JReport Enterprise Server residing in each node of a JReport Enterprise Server cluster. The main factor that affects load balancing is the number of concurrent report sets that are running on every JReport Enterprise Server. In order to avoid heavy load, two properties cluster.send_concurrent_reports and cluster.update_concurrent_reports_immediately are provided to enable sending the number of concurrently running report sets on member servers to the admin server immediately when the number changes.

#### Built-in load balancing algorithm

JReport Enterprise Server cluster supports several algorithms for load balancing clustered servers. Configurable algorithms for load balancing clustered servers are:

- Least Current Report Sets (Min-load) (loadbalance.type=0)
  The admin server will select the server which has the least number of currently running report sets. If the local server is one of the qualified servers, it will be given higher priority.
- Round Robin (loadbalance.type=1)
  The admin server will select each server in sequence one by one until each has been allocated a report set to run then will repeat the cycle.
- Least Weighted Current Report Sets (Weighted Min-load)(loadbalance.type=2)
  The admin server will select the server that has the least Weighted current report sets. If the local server is one of the qualified servers, it will be given higher priority.

  | Number of currently running report sets
  Weighted current report sets= |
  | Performance Weight

  Performance weight is a positive float number that you set to each server in a cluster on the JReport Administration page on the admin server > Cluster > Weight tab. The higher performance weight you set to a clustered server, the higher chance it may get selected by the admin server during load balancing. See Configuring performance weight for how to set performance weight and how this algorithm works.

  If you do not set performance weight, by default the algorithm will work same as Least Current Report Sets (Min-load) (loadbalance.type=0).

- Random (loadbalance.type=3)
  The admin server will select the server randomly.

Notes:

- You can choose the load balancing type by setting the property loadbalance.type in the server.properties file in `<install_root>\bin`.
- For the load balancing algorithms: the admin server selects from the servers with the number of concurrently running report sets less than maximum number first. However, if all servers are full, it will select from all of them.

###### Related topics:

- Balancing the server load