Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running meteor in a cluster and real-time changes

I was planning on deploying Meteor to my Amazon AWS EC2 servers but I would like to also run multiple instances of the server at the same time to serve more clients. Is there a proper way to do this in Meteor without breaking the ability for clients to updated about updates to their collections?

like image 259
HGandhi Avatar asked Nov 02 '12 18:11

HGandhi


1 Answers

There are two main issues to consider when running multiple Meteor server processes.

  1. Client session affinity. Clients use the SockJS library to connect back to the Meteor server, usually by using a long polling strategy that reconnects to the server every so often. The server process holds state associated with each client. So it is important that a given client's connection not bounce between servers, or else the server will think it's talking to a new client and resend all of the subscription state.

  2. Coordinating database invalidations. Anytime a client issues a database write, the server process runs a recalculation and pushes updates to any other affected client. But clients connected to a different server won't see the change until that server process runs the 10 second Mongo polling loop. For some applications it's okay to have most clients lag 10 seconds behind. If your application requires something more real-time, then you'll have to implement your own interprocess communication between Meteor server processes.

like image 153
debergalis Avatar answered Oct 21 '22 11:10

debergalis