Hi Mrinal,
there is two aspects to this:
1) How to distribute load between multiple instances of leshan
2) What happens if one of the leshan instances crashes
Regarding 1) A simple strategy might be to put an IP load balancer in front of the leshan instances and route requests to leshan instances based on source IP. This is easy to set up but has the drawback of potentially not distributing the load evenly (depending on the algorithm used to determine the leshan instance based on the IP address). An advantage of this strategy is that session data can remain in-memory and does not need to be replicated/shared among the instances which allows for a very simple set-up (share nothing). If you want to use somethin glike round-robin load balancing you will need to share session data among the leshan instances which brings us to the other aspect...
Regarding 2) If you don't mind clients to re-establish the connection to leshan, you can simply re-start the failed instance and loose all existing sessions. If this is a problem and you need something like session fail-over, you will need to share session state among the leshan instances.
Session state consists of registration data, active observations and security related information which is kept in three registries
- org.eclipse.leshan.server.client.ClientRegistry
- org.eclipse.leshan.server.observation.ObservationRegistry
- org.eclipse.leshan.server.security.SecurityRegistry
The default implementations of these registries are all in-memory only. Thus, if you want to share session data among instances, you will need to create custom implementations that share the data using e.g. a database or a data grid/cache as suggested by you.
We would also like to invite you to think about contributing your code if you create such an implementation :-)
Regards,
Kai