< Docs
  • Java


MilvusClient interface. This method moves segments from one query node to another to keep the load balanced.


Milvus server has its internal machinery to keep the load balanced, sometimes the segments might be moved back.

R<RpcStatus> loadBalance(LoadBalanceParam requestParam);


Use the LoadBalanceParam.Builder to construct a LoadBalanceParam object.

import io.milvus.param.LoadBalanceParam;
LoadBalanceParam.Builder builder = LoadBalanceParam.newBuilder();

Methods of LoadBalanceParam.Builder:

Method Description Parameters
withSourceNodeID(Long srcNodeID) Set the ID of source query node in which the sealed segments were loaded. srcNodeID: The source query node ID.
addDestinationNodeID(Long destNodeID) Add the ID of destination query node to which the sealed segments will be balanced. destNodeID: The destination query node ID.
withDestinationNodeID(List\ destNodeIDs) Set an ID array of the destination query nodes to which the sealed segments will be balance. destNodeIDs: The destination query node ID array.
addSegmentID(Long segmentID) Add a sealed segment ID which to be balanced. segmentID: A sealed segment ID.
withSegmentIDs(List\ segmentIDs) Set an ID array of sealed segments which to be balanced. segmentIDs: The sealed segments ID array.
build() Construct a LoadBalanceParam object. N/A

The can throw the following exceptions:

  • ParamException: error if the parameter is invalid.


This method catches all the exceptions and returns an R<RpcStatus> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and error message of the exception.

  • If the API succeeds, it returns R.Status.Success.


import io.milvus.param.*;

LoadBalanceParam param = LoadBalanceParam.newBuilder()
R<RpcStatus> response = client.loadBalance(param);
if (response.getStatus() != R.Status.Success.getCode()) {