Page 1 of 1

multiple server instances talking to each other

Posted: 10 Nov 2008, 00:06
by samirn
Hi I am splitting my world into multiple parallel instances, as described in the scalability faq:

http://www.smartfoxserver.com/whitepape ... rmance/#q4

I'd like to do this transparently to the user as described:
Alternatively, this can be done in a transparent way for the client, by automatically choosing the less loaded zone inside the current region.
My question is, what is the best way to have multiple smartfox instances talk to each other? My current thought is to have one instance that just has one limbo zone running that all users initially join. This instance would have a servlet that talks to servlets for all other instances to find out which zone the user should join (whichever is emptiest, for example). This servlet would then pass the info to an extension, and the extension would tell the client where to go.

Does this make sense, or is their an easier way? Can server extensions talk directly to extensions running on seperate smartfox instances? I know they can communicate if they are on the same smartfox instance, but I haven't seen anything for cross instance communication.

Posted: 10 Nov 2008, 15:22
by Lapo
Multiple instances cannot talk directly to each other because they physically run on different machines.
One way to obtain this "magic" is using Terracotta which allows multiple JVMs to share the same memory across the network.

We show how to do this (and a lot more) here -> http://www.smartfoxserver.com/clustering/

Back to your question. I wouldn't make it so complicated.
I would simply populate an XML file for the client application where you specify all the available nodes, choose one randomly and attempt to connect. If the server refuses the connection because its full I would try another one.

A different approach would be to dedicate one server machine for each region of the world: Europe, Asia, America etc... and send users to the right server based on where they come from (there are ways to identify the country from the IP address)

multiple server instances talking to each other

Posted: 10 Nov 2008, 23:08
by samirn
Thanks Lapo.

One reason for the complicated design is that I want to fill the shards in order, rather than randomly. Basically I have two numbers: maxUsers and an idealUsers. I want to fill all shards to the idealUser limit, and if all shards are > idealUsers, then just randomly select a shard.

As for having the users select based on region, do you know how many identical zones a server instance can handle before bogging down? I know it depends on how complicated the server logic is, but is there any overhead that would limit it to a certain number? We have about 16-20 rooms per zone, if it helps.

Posted: 13 Nov 2008, 16:41
by Lapo
A simple way to do load balancing without having each instances talking to each others is to publish the current load in a central database.

Before establishing a socket connection to one of the shards you simply talk to its web-server (SFS comes with Jetty embedded) and get the address of the node to connect to.

In other words:

1- client picks a random node
2- client asks the node servlet if it can connect
3- servlet responds Yes or No. If NO will also say which is node is good
4- perform actual socket connection