-
Couldn't load subscription status.
- Fork 0
Multi server Experimental
This branch is experimental for multiple server support.
- Increase inactive timeout from
5000milisecond to ... i don't remember, just make it as large as possible
- Add
gateway.jsandnpm run clustercommand to start server as a cluster - Add
redisfor sharing data between servers
We're running the cluster with 4 instances of Agar.IO Server and 1 Redis server for transferring messages between instances.
The communication between instances now using Redis's Publish and Subscribe
======================================================
| REDIS |
======================================================
|| || || ||
|| || || ||
|| || || ||
Server #1 Server #2 Server #3 Server #4
By doing this, we can run multiple servers from multiple location but still able to share the data (foods, players, chat messages,...) between them.
Step 1: Run the environment
- Install and run
Rediswithredis-servercommand
Step 2: Run the server cluster
- Checkout the
multi-serverbranch - Run the server cluster with:
npm run cluster
The cluster will start up with 4 server running on http://localhost:3000, http://localhost:3001, http://localhost:3002, and http://localhost:3003
Step 3: Test multi server function
- Go to server #1: http://localhost:3000, login with any name you want
- Go to server #2: http://localhost:3001, login with any name you want
- In any client, leave some chat message
- Go to another client to see the message displayed!