系统设计:使用API​​网关 / SQS的AWS聊天应用程序 - 服务器如何发送消息给收件人?

发布于 2025-02-11 04:58:11 字数 606 浏览 1 评论 0原文

这是一个有关创建消息传递应用程序(例如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.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2025-02-18 04:58:11

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文