Hello all, I am developing a multiplayer game using Coronium GS and I came up with an idea that may be a less complicated alternative to load balancing when dealing with high traffic. ( It might not be the most efficient )
Fortunately my game requires minimum information from the server, basically it returns a score value and a player handle. So I figured something like this might work :
The player who creates a room :
pNum = 4 -- Room designed for 4 players TAG\_ID = math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9)..math.random(0,9) MAX\_conn = 1000 -- Max clients connected CURRENT\_server = 1 -- first attempt on first server connection\_tbl\_1 = first\_instance connection\_tbl\_2 = second\_instance connection\_tbl\_3 = third\_instance function onClientData( event ) if event.data.ClientCount then -- event.data.ClientCount = gs:getClientCount() if CURRENT\_server == 1 then if event.data.ClientCount \> MAX\_conn then gs:disconnect() timer.performWithDelay( 500, function() CURRENT\_server = 2 gs:connect( connection\_tbl\_2 ) end ) else gs:createGame(pNum, { tag = '1'..TAG\_ID } ) end elseif CURRENT\_server == 2 then if event.data.ClientCount \> MAX\_conn then gs:disconnect() timer.performWithDelay( 500, function() CURRENT\_server = 3 gs:connect( connection\_tbl\_3 ) end ) else gs:createGame(pNum, { tag = '2'..TAG\_ID } ) end elseif CURRENT\_server == 3 then if event.data.ClientCount \> MAX\_conn then gs:disconnect() timer.performWithDelay( 500, function() print(" ALL CROWDED ") end ) else gs:createGame(pNum, { tag = '3'..TAG\_ID } ) end end end
For the player who joins the room:
gameID = keyboard-input or QR code that translates to ‘server_num’…TAG_ID
and the string.sub( gameID, 1,1 ) will tell him which server to connect. That goes for as much instances as necessary,
also when the client connects, the server fires a client:send( { ClientCount = gs:getClientCount() } )
,would someone more experienced say that this will work? Thank you