Advertisement

What about Load Balancer

Started by May 24, 2016 04:35 PM
10 comments, last by hplus0603 8 years, 5 months ago
Hello everyone
i'll start to work on a big project (Client/Server) and i'll try to implement a soft load balancer i mean i'll make a Master server and a Slave Server
The load Balancer server(master server) will split clients to server 1,server2 or server 3
160524065331506979.png
and if a client A connected on server 1 want to send a data to a client B connected on server 2 or 3 there is one scenario :
when the server 1 receive the packet from the client A he will check if the client B is Online if yes he will fetch the IP Server on which this client B is connected and the server 1 will send the data to the server 3 and the server 3 will send this data to client B
The question is : i don't know if this mechanism has a good performance or not
This network can handle more than 500 000 Connection at the same time
Ps : i'll use IOCP(Input Ouput Completion Port)
Your diagram doesn't make it clear how each client ends up talking to a particular server.
It also doesn't make it clear how each server will end up finding out about other servers/clients on those servers.
As far as I can tell, the design you suggest ends up with every server on average talking to every other server, which scales like N-squared.
For well implemented systems, and 500,000 connections, N can likely be very small, though, so it might work fine.

I think the bottleneck, in the system as you describe it, will be the "lookup if B is online, and if so which server B is on." That will probably not scale to 500,000 users with a single "master server" if the typical use case is that players talk to other players on other servers, unless connecting is rare and connections are persistent after establishment.
You'll probably want the ability to horizontally shard the "presence" bit (meaning "player B is on host Q.") You can likely build this by using a key/value store with ephemeral keys, like Memcached, Redis, or Zookeeper. (You'd have to investigate which of them best matches your particular use case.)
enum Bool { True, False, FileNotFound };
Advertisement
How many clients it depend on the slave server hardware configuration maybe 60k for each slave server i can execute many instance of my server slave i just give an example of 3 servers

For example if the master server can't find a (place) in slave servers then he will execute another instance of a slave server in another machine

To be more clear master server his job is To "redirect" clients to one of the slave servers...

How many clients it depend on the slave server hardware configuration maybe 60k for each slave server i can execute many instance of my server slave i just give an example of 3 servers

For example if the master server can't find a (place) in slave servers then he will execute another instance of a slave server in another machine

To be more clear master server his job is To "redirect" clients to one of the slave servers...

If master server spins up a new slave server, how do the other slave servers know about it? Suppose Client 1 connected to Slave Server A. Then 100K more players joined in, and Client 2 joins, Master Server decides to spin up a new Slave Server B with a different ip address and reroute Client 2 to Slave Server B. Now Client 1 wants to send a message to Client 2, how do you suppose Slave Server A knows where Slave Server B is?

That's just using 2 servers as an example. Theoretically, you can have N Slave Servers. How does one Slave Server know that Client X is connected to Slave Server Y, without pinging all Slave Servers "Is X connected to you guys?". There's also a possibility that X is disconnected, and reconnect back to a completely different Slave Server.

How many clients it depend on the slave server hardware configuration maybe 60k for each slave server i can execute many instance of my server slave i just give an example of 3 servers

For example if the master server can't find a (place) in slave servers then he will execute another instance of a slave server in another machine

To be more clear master server his job is To "redirect" clients to one of the slave servers...

If master server spins up a new slave server, how do the other slave servers know about it? Suppose Client 1 connected to Slave Server A. Then 100K more players joined in, and Client 2 joins, Master Server decides to spin up a new Slave Server B with a different ip address and reroute Client 2 to Slave Server B. Now Client 1 wants to send a message to Client 2, how do you suppose Slave Server A knows where Slave Server B is?

That's just using 2 servers as an example. Theoretically, you can have N Slave Servers. How does one Slave Server know that Client X is connected to Slave Server Y, without pinging all Slave Servers "Is X connected to you guys?". There's also a possibility that X is disconnected, and reconnect back to a completely different Slave Server.

Hello alnite, thank you for your participation
when the master server will spawn a new instance of my Slave Server :
so client 1 connected to slave server 1 send a message to client 2 connected in x slave server in this case :
the server slave 1 will send a request to the database to retrieve the IP address of the client 2 by his unique User Name of course there are three possible cases
case 1 : if the slave server x is shutdown(Not connected) then the slave server 1 will check the client 1 if he is not in the black list of the client 2 if not then he send a request to the database to add an offline message to the client 2
case 2 : the slave server x can't find the client in his map user list, then the x slave server will send a notification to the slave server 1 that the client 2 is not available and the x slave server will send a request to the database to add an offline message to the client 2 if the client 1 is not in his black list
case 3 : the slave server x can find the client 2 first he will check if the client 1 is not in the black list of the client 2 if no he will send the message if yes then he will stop the request of the slave server 1
Ps : i'm sorry for my english

Usually that situation works something more like this or this. Instances can talk to each other when needed, but it is best to keep cross-communication minimal. While those happen to use Amazon's AWS services the overall design is common.

Advertisement

Usually that situation works something more like this or this. Instances can talk to each other when needed, but it is best to keep cross-communication minimal. While those happen to use Amazon's AWS services the overall design is common.

in your schematic design the slave servers talk to each others directly or via Load Balancing server

In the systems I've worked with, nodes within a group never talk to each other.

They talk out a layer, to their clients, and they talk up a layer, to their data sources, but they are designed to not talk among others at their same group. Also they are designed to communicate as little as possible, as network traffic is incredibly slow.

Generally if you must go across the network inside your severs, that round trip costs the player a full graphics frame. Machines can request data from persistence and save to persistence, but they should only touch the servers outside of game play.

If master server spins up a new slave server, how do the other slave servers know about it?


Perhaps he can build it on top of Erlang, where the platform takes care of that bit?
We built ours on Erlang, and it was probably the right choice. It's certainly worked mostly fine for the last 5-6 years or so.
Note that we have hash-based linear scaling, rather than N-squared scaling; that certainly helps!
enum Bool { True, False, FileNotFound };

If master server spins up a new slave server, how do the other slave servers know about it?


Perhaps he can build it on top of Erlang, where the platform takes care of that bit?
We built ours on Erlang, and it was probably the right choice. It's certainly worked mostly fine for the last 5-6 years or so.
Note that we have hash-based linear scaling, rather than N-squared scaling; that certainly helps!

Heard good things about Erlang. Now I am really curious to try it out :D

This topic is closed to new replies.

Advertisement