在集群中运行流星和实时更改 [英] Running meteor in a cluster and real-time changes

查看:63
本文介绍了在集群中运行流星和实时更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划将Meteor部署到我的Amazon AWS EC2服务器,但我也想同时运行服务器的多个实例以服务更多的客户端.在Meteor中是否有适当的方法可以做到这一点,而又不会破坏客户更新其收藏集更新的能力?

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?

推荐答案

在运行多个Meteor服务器进程时,要考虑两个主要问题.

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

  1. 客户端会话亲和力.客户端通常使用长轮询策略(经常每隔一段时间重新连接到该服务器),使用SockJS库重新连接到Meteor服务器.服务器进程保留与每个客户端关联的状态.因此,重要的是给定客户端的连接不要在服务器之间反弹,否则服务器将认为它正在与新客户端通信并重新发送所有订阅状态.

  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.

协调数据库失效..每当客户端发出数据库写操作时,服务器进程都会进行重新计算并将更新推送到任何其他受影响的客户端.但是连接到其他服务器的客户端将看不到更改,除非该服务器进程运行10秒的Mongo轮询循环.对于某些应用程序,大多数客户端都可以落后10秒.如果您的应用程序需要更实时的内容,则必须在Meteor服务器进程之间实现自己的进程间通信.

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.

这篇关于在集群中运行流星和实时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆