系统设计:使用API网关 / SQS的AWS聊天应用程序 - 服务器如何发送消息给收件人?
这是一个有关创建消息传递应用程序(例如WhatsApp或FB Messenger)的系统设计问题。
我看到视频使用户通过WebSocket连接到API Gateway,然后API GW将消息推向SQS-然后通过EC2计算层进行轮询以处理消息(将消息存储在DB中),并希望将消息发送回收件人。
后端EC2 /计算层如何将消息发送给收件人(BOB)?它可以只在API网关上拨打路由,并且知道收件人的连接详细信息以及发送何处?是否需要额外的缓存层来存储有关每个用户连接详细信息的信息?我对AWS更新,因此不确定如何完成此操作以及您是否可以致电API GW将其发送回用户。
另外,如果您知道小组聊天的工作方式,请分享。
This is a system design question about creating a messaging application (like WhatsApp or FB messenger).
I saw a video that had the users connected via websocket to the API Gateway , then API GW pushed the message onto SQS - which was then polled by the EC2 compute layer to process the message (store it in the db) and hopefully send the message back to recipient.
How can the backend ec2 / compute layer send the message to the recipient (Bob) ? Can it just call a route on the API Gateway and it would know the connection details of the recipient and where to send? Would there need to be an additional caching layer to store info about the connection details of every user? I'm newer to AWS so not sure how this is accomplished and whether you can call API GW to send back to a user.
Also if you know how group chat would work please share.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如,您的后端EC2服务器可以直接通过
@connections
api将消息发送给连接的客户端。此 /a>带您完成如何做到这一点。为此,您需要将ConnectionID添加到标题。请参阅此答案关于如何做到这一点。
As mentioned in the documentation, your backend EC2 servers can send messages to the connected clients directly via the
@connections
API. This documentation page walks you through how to do that.For this, you'll need to add the connectionId to the header. See this answer on how to do so.