Communication between multiple instances of backend server

xuanbao · · 311 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>My application uses websockets to relay realtime actions to client, now in a more than 1 instance setting. User connections are distributed among the backend servers, what I want to do is when one of the server wants to broadcast an ACTION, it not only broadcasts it to the users connected to itself (using websockets) but it also sends the same actions to other servers, so that they can broadcast the same to their clients.</p> <p>I have done a quick and dirty rest endpoint for this, but I believe this has to be a common situation in scaling systems and some best practices to follow. I&#39;m looking at the RPC package but not sure if it is necessary.</p> <hr/>**评论:**<br/><br/>TheMerovius: <pre><p>That sounds like the perfect application for pubsub. If you run on the cloud, your favorite cloud provider should provide you with a pubsub broker out of the box. Otherwise you need to run your own (e.g. RabbitMQ or the like). </p></pre>theSheth: <pre><p>Thanks for pointing the direction, found this <a href="" rel="nofollow"></a> and it hits the use case perfectly.</p></pre>qu33ksilver: <pre><p>Yes, pubsub is the way to go. </p> <p>You might not need a message queue, or redis pub-sub or anything of that sort. Just create another service. And have your backend cluster of servers push updates to that service. Now, change your clients to connect to this service for realtime updates instead of the old one. So basically, your clients have 2 connections now - one for pushing data and maybe receiving contextual data from the same server, another for receiving broadcast info.</p></pre>jonbonazza: <pre><p>If you want something socket-oriented, use something like zeroMQ or nanomsg. If you want a message broker, something like Kafka would be the way to go. Both have their pros and cons.</p></pre>rphillips: <pre><p>If you want durable updates to your websocket connections, then take a look at Kafka. It will scale this pub sub to a extremely high volume. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

311 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传