1

For a college assignment I'm building a networked Java application using sockets*. My architecture must be scalable so I would like to have multiple servers available for my clients to communicate with.

My question is, how can a client know about all available servers? My first thought is for the clients to keep a (hardcoded) list of server IP addresses and select from the list. What is best practice in this case?

*We cannot use RMI.

Odhran Roche
  • 1,111
  • 1
  • 7
  • 14
  • Looks like you want to implement your own [cluster](http://en.wikipedia.org/wiki/Cluster_(computing)). – Luiggi Mendoza Oct 13 '13 at 21:53
  • You might be looking for JNDI and RMI stuffs.Read JNDI http://stackoverflow.com/questions/1350816/what-is-the-purpose-of-jndi – nullptr Oct 13 '13 at 22:03

2 Answers2

0

Let's imagine your network provider's costs got too high, and you decided to switch. Boom go your IP addresses. I would suggest the judicious use of DNS, especially round-robin DNS.

Using a central tracker could seem like a good idea, but it itself must be scalable, akin to Google App Engine, or it will become a chokepoint.

Simply create multiple A-records for a given name, and your clients will randomly select one when resolving.

If you are unable to use DNS an IP list may be beneficial--with one change. All of the servers circulate updated copies of the list and if a server cannot be reached, another is tried until a connection is made(and the list likewise updated). When the list is found to differ from the existing one the client's list is updated.

nanofarad
  • 40,330
  • 4
  • 86
  • 117
0

You can use RMI stuffs, making primary and secondary servers.

Secondary server may be continuously polling primary, when primary goes down, secondary can register on naming services to take on. When primary comes back, it will register back making secondary go down... like that.

Regarding client to know server, client can ask servers using RMI for identity.

nullptr
  • 3,320
  • 7
  • 35
  • 68