Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how connect to a milvus cluster #1006

Open
hgaong opened this issue Jul 31, 2024 · 8 comments
Open

how connect to a milvus cluster #1006

hgaong opened this issue Jul 31, 2024 · 8 comments

Comments

@hgaong
Copy link

hgaong commented Jul 31, 2024

ConnectConfig.builder()
    .uri(String uri)
    .token(String token)
    .build();

The uri can only correspond to one host. If the machine corresponding to the URL is down and cannot be restored, but the entire cluster is still running normally. Won't the Java program be unable to access the cluster?

@hgaong
Copy link
Author

hgaong commented Jul 31, 2024

Isn't there a way like the Kafka Java SDK where multiple servers can be configured? Configuring only one URI might lead to a single point of failure, right?

@yhmo
Copy link
Contributor

yhmo commented Jul 31, 2024

For each milvus cluster, there is a proxy node to receive requests from client. You can add more proxy nodes to a cluster. Each proxy node has its address. If one proxy node is down, the other proxy nodes still work. So, you can use N MilvusClient for N proxy nodes, each MilvusClient connects a proxy node.

If your cluster has only one proxy node(a single uri), you will not able to connect the cluster if the proxy node is down.

Java SDK can handle multiple clusters by MilvusMultiServiceClient. This ability is not described in the document since we have concerns about the consistency of clusters.
If you have multiple milvus clusters, you can use this class to interact with them:

ServerAddress serverAddress = ServerAddress.newBuilder().withHost("address1").withPort(port1).build();
ServerAddress serverSlaveAddress = ServerAddress.newBuilder().withHost("address2").withPort(port2).build();
MultiConnectParam connectParam =  MultiConnectParam.newBuilder().withHosts(Arrays.asList(serverAddress, serverSlaveAddress)).build();
MilvusClient client = new MilvusMultiServiceClient(connectParam);

All the requests created by MilvusMultiServiceClient will be sent to multiple clusters at the same time.

@hgaong
Copy link
Author

hgaong commented Jul 31, 2024

For each milvus cluster, there is a proxy node to receive requests from client. You can add more proxy nodes to a cluster. Each proxy node has its address. If one proxy node is down, the other proxy nodes still work. So, you can use N MilvusClient for N proxy nodes, each MilvusClient connects a proxy node.

If your cluster has only one proxy node(a single uri), you will not able to connect the cluster if the proxy node is down.

Java SDK can handle multiple clusters by MilvusMultiServiceClient. This ability is not described in the document since we have concerns about the consistency of clusters. If you have multiple milvus clusters, you can use this class to interact with them:

ServerAddress serverAddress = ServerAddress.newBuilder().withHost("address1").withPort(port1).build();
ServerAddress serverSlaveAddress = ServerAddress.newBuilder().withHost("address2").withPort(port2).build();
MultiConnectParam connectParam =  MultiConnectParam.newBuilder().withHosts(Arrays.asList(serverAddress, serverSlaveAddress)).build();
MilvusClient client = new MilvusMultiServiceClient(connectParam);

All the requests created by MilvusMultiServiceClient will be sent to multiple clusters at the same time.

好嘟谢谢

@ahern88
Copy link

ahern88 commented Aug 14, 2024

我使用 nginx 反向代理多个 proxy的 gRPC协议,nginx配置 keepalived 做vip漂移,这样客户端只需通过vip连接到nginx即可。感觉这样简单点,不知道这样会不会有什么风险。

@ahern88
Copy link

ahern88 commented Aug 14, 2024

@yhmo 后续milvus java sdk 会出一个cluster连接的api吗,配置多个uri,本地做负载均衡和故障切换吗?

@yhmo
Copy link
Contributor

yhmo commented Aug 15, 2024

@ahern88
目前没有计划做

@hgaong
Copy link
Author

hgaong commented Aug 15, 2024 via email

@xiaofan-luan
Copy link
Contributor

@yhmo后续milvus java sdk会出一个集群连接的api吗,配置多个uri,本地做负载均衡和故障切换吗?

milvus的proxy是无状态的。因此并不需要重客户端通过链接多个地址来保证高可用。正确的方式是挂ALB或者Nginx然后起多个proxy做负载均衡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants