Scaling real-time Node.js applications
Since our chat messages are being relayed via the server, clients can currently only communicate with other clients connected to the same server. This is a problem if we want to scale our application horizontally across many servers.
This is easy to fix, but tricky to demonstrate. To do so, we need to have two separate instances of our application running. This will be more realistic and more useful if they are also using the same shared databases for persistence. So we need to start up MongoDB and Redis, then start two instances of our application on different ports (so that they don't collide).
This means running all of the following commands (replacing the dbpath of MongoDB as appropriate for your setup):
> redis-server > mongod --dbpath C:\data\mongodb > set MONGODB_URL=mongodb://localhost/hangman > set REDIS_URL=redis://127.0.0.1:6379/ > set PORT=3000 > npm start > set PORT=3001 > npm start
The commands that start the database...