How can I scale an RMI server? For example, how can I spread workload of RMI server between several server hosts?
What you are looking for is called Load Balancing. Most developers use an intermediate RMI Server, a Router.
The Router contains the logic to determine which Server should process the request from a client. There are two basic scenarios:
- The client contacts the Router and the Router returns the RemoteObject for the Server,(pass back).
Some, (there are many), issues for each of these are:
This resembles the Internet where every "www" request must go to a common service that passes back the IP address.
Clients may only use the Server RemoteObject one time since it may not be best able to handle the next request.
The object the clients pass to the Server must go through the Router. This involves deserializing the object in the Router and re-serializing the object in the Router to pass on to the Server.
The object the Server returns to the client must go through the Router. This involves deserializing the object in the Router and re-serializing the object in the Router to return to the client
Both these scenarios require extensive analysis and design way, way beyond what we can provide here.