思路在AWS扩展聊天? [英] Ideas for scaling chat in AWS?

查看:201
本文介绍了思路在AWS扩展聊天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图想出的AWS缩放聊天服务的最佳解决方案。我拿出一对夫妇可能的解决方案:

I'm trying to come up with the best solution for scaling a chat service in AWS. I've come up with a couple potential solutions:

  1. Redis的发布/订阅 - 当用户建立到该服务器订阅到该用户的ID服务器的连接。当某人将消息发送到该用户,一个服务器将执行一个发布与用户的ID的信道。用户连接到该服务器将收到的消息,并将其推到相应的客户端。

  1. Redis Pub/Sub - When a user establishes a connection to a server that server subscribes to that user's ID. When someone sends a message to that user, a server will perform a publish to the channel with the user's id. The server the user is connected to will receive the message and push it down to the appropriate client.

SQS - 我想创建为每个用户队列。用户连接的服务器将轮询(或使用SQS长轮询)的队列。当新消息被发现,它就会被推向从服务器的用户

SQS - I've thought of creating a queue for each user. The server the user is connected to will poll (or use SQS long-polling) that queue. When a new message is discovered, it will be pushed to the user from the server.

SNS - 我真的很喜欢这个解决方案,直到我发现了100课题的限制。我需要为每个用户创建,这将只支持100个用户的一个话题。

SNS - I really liked this solution until I discovered the 100 topic limit. I would need to create a topic for each user, which would only support 100 users.

难道他们的任何其他方式聊天可以使用AWS扩展?是SQS方法可行?多长时间需要AWS将消息添加到队列中?

Are their any other ways chat could be scaled using AWS? Is the SQS approach viable? How long does it take AWS to add a message to a queue?

推荐答案

建立一个聊天服务并不像你想象的那么简单。

Building a chat service isn't as easy as you would think.

我已经建立了完整的 XMPP 的服务器,客户端和SDK的和可以证明一些微妙和困难的问题出现。原型,用户看到彼此,聊天是很容易。一个完整的功能系统,建立帐户,安全性,发现,presence,线下交付和好友列表是更是一个挑战。到再扩展跨越服务器的任意数量是特别困难的。

I've built full XMPP servers, clients, and SDK's and can attest to some of the subtle and difficult problems that arise. A prototype where users see each other and chat is easy. A full features system with account creation, security, discovery, presence, offline delivery, and friend lists is much more of a challenge. To then scale that across an arbitrary number of servers is especially difficult.

PubSub的是聊天服务提供了一个功能(见XEP-60 ),而不是建筑的传统手段聊天服务。我可以看到的吸引力,但PubSub的可以有缺点。

PubSub is a feature offered by Chat Services (see XEP-60) rather than a traditional means of building a chat service. I can see the allure, but PubSub can have drawbacks.

为你几个问题: 1.你在Web上这样做呢?有网友将要连接和长极化或者你有一个Web套接字的解决方案?

Some questions for you: 1. Are you doing this over the Web? Are users going to be connecting and long-poling or do you have a Web Sockets solution?

  1. 有多少用户?有多少每个用户连接?写入比率读?

  1. How many users? How many connections per user? Ratio of writes to reads?

你的点子用SQS这种方式很有趣,但可能不会扩大。这不是寻常的有5万或更多的用户聊天服务器上。如果你是轮询每个SQS队列为每个用户你不会得到附近的任何地方。你会过得更好有一个队列为每个服务器,服务器轮询只有队列。然后,它是你找出服务器的用户是与消息放入正确的队列中。

Your idea for using SQS that way is interesting, but probably won't scale. It's not unusual to have 50k or more users on a chat server. If you're polling each SQS Queue for each user you're not going to get anywhere near that. You would be better off having a queue for each server, and the server polls only that queue. Then it's on you to figure out what server a user is on and put the message into the right queue.

我怀疑你会想要去是这样的:

I suspect you'll want to go something like:

  1. 在后台一大RDS数据库。
  2. 在一堆前端服务器处理客户端连接。
  3. 在一些中间层的Java / C#code跟踪一切,将消息路由到正确的地方。

要获取的阅读XMPP RFC的构建聊天服务器的复杂性的想法: RFC 3920 RFC 3921

To get an idea of the complexity of building a chat server read the XMPP RFC's: RFC 3920 RFC 3921

这篇关于思路在AWS扩展聊天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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