如何将松弛型机器人扩展到1000个团队 [英] How to scale a slack bot to 1000's of teams

查看:92
本文介绍了如何将松弛型机器人扩展到1000个团队的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要实现一个松弛机器人,我需要处理松弛的实时消息API".这是一个基于WebSocket的API,可让您实时接收来自Slack的事件并以用户身份发送消息.更多信息: https://api.slack.com/rtm

To implement a slack bot, i need to deal with 'Real Time Messaging API' of slack. It is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as user. more info: https://api.slack.com/rtm

要仅创建一个团队的漫游器,我需要打开一个websocket连接,并监听事件.

To create a bot for only one team, i need to open one websocket connection and listen it for events.

为另一个团队提供松弛机器人.我需要打开一个新的 websocket连接. 因此,

To make available the slack bot for another team. I need to open a new websocket connection. So,

  • 1个团队=> 1个websocket连接
  • 2个团队=> 2个websocket连接
  • N个团队=> N个网络套接字连接

对于无休止的团队,我应该怎么做才能扩展我的websocket连接?

what should i do to scale my websocket connections for endless teams?

什么样的架构可以处理1000个websockets连接的自动扩展?

What kind of architecture can handle autoscaling of 1000’s of websockets connections?

推荐答案

使用松弛的套接字,您可以扩展很多东西:

With slack sockets, you have lots of things to scale:

  • 套接字数.这很容易,因为即使便宜的服务器也可以处理成千上万个套接字,例如超过5万个.但是每个套接字代表其他几种负载,下面列出.
  • 每个团队使用的内存量,这取决于您自己的服务器实现.如果您试图在内存中保留大量消息历史记录,则比消息处理代码有些无状态的情况要快达到服务器的限制.
  • I/O量,这可能会使您希望将任何图像服务卸载到单独的负载均衡器中.

要考虑的另一件事是容错.假设您进行了粘性负载平衡,并且其中一台服务器正在处理50个团队.该服务器是处理这50个团队的唯一服务器,因此如果该服务器出现故障,则所有50个漫游器都将脱机.另外,您可以在单独的服务器上为每个团队打开多个套接字,并使用消息处理队列,以便每条消息仅响应一次.

The other thing to consider is fault-tolerance. Let's say you did sticky load balancing and one of your servers is handling 50 teams. That server is the only one handling those 50 teams so if it goes down then all 50 bots go offline. Alternatively, you can open up multiple sockets per team on separate servers and use a message handling queue so that each message is only responded to once.

因此,我建议的体系结构是用于RTM套接字的瘦冗余负载平衡器,作为第一层,并在其下提供可靠的消息队列.

So the architecture I would propose is a thin, redundant load balancer for RTM sockets as a first layer, and a reliable message queue underneath that.

这篇关于如何将松弛型机器人扩展到1000个团队的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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