Add new node to LoadBalancedRSocketMono


I am trying to use the LoadBalancedRSocketMono to load balance my Server Nodes. I am intending to perform a registration when a new Server node starts to support auto scaling feature. When I investigated this API, I am not able to add new node to the pool, seems to be static. Please help me how I can perform this functionality and correct my understanding as I am new to RSocket.

Thank You and Appreciate your time.

Thanks and Regards

Hi Karthik,

When creating a new a new LoadBalancedRSocketMono you pass in a Publisher<? extends Collection> that emits a collection of RSocketSupplier factors. The collection that is emitted is the current collection of RSocketSuppliers that you want to load balance against. In your case an RSocketSupplier could map to a server node. As new servers are scaled up or down the factories stream is should emit the current collection of available servers. This could be a stream like this:

on next: <server1>
on next: <server1, server2>
on next: <server1, server2, server3>
on next: <server2, server3>

What you need to do is create a Publisher that emits a collection of RSocketSuppliers that represents the current collection of servers nodes. As servers come and go the Publisher needs to emit a new list that is the current snapshot of servers.

What are you using for discovering new nodes? I might be able to help with a Publisher<? extends Collection> example or point you in the right direction.


Thank You @robertroeser. When my server node comes up, it connects to my Rsocket Broker to register on a port with its Service, host and port. Currently I am storing in memory. My application is on SpringBoot and I will call deregister when the application is destroyed. Please help me with a sample that would be helpful. If you have any recommendation on lightweight datastore to save this state would also be of great help.

@robertroeser I tested the application the way I explained above. Server at 9000 is created along with LoadBalancedRSocketMono. This sever is in operation for LoadBalancedRSocketMono to monitor. After a while I bring Server at 9001 and added this RSocketSupplier to the Collection. But LoadBalancedRSocketMono is not picking or refreshing to get the new server. I could not find any api to refresh sockets or add this new sockets to the RSocketSupplierPool. Please help me how I can dynamically add and remove the server nodes based on autoscaling needs.