分布式服务器实例之间的数据广播

发布于 2024-12-05 10:31:12 字数 1191 浏览 1 评论 0原文

我正在尝试获取有关我的特定应用程序中的服务“名册”建议的一些反馈。我有一个服务器应用程序,可以维护与客户端的持久套接字连接。我想进一步开发服务器以支持分布式实例。服务器“A”需要能够将数据广播到其他在线服务器实例。所有其他活动实例也是如此。

我正在尝试研究的选项:

  1. Redis / Zookeeper / Doozer - 每个服务器实例都会将自己注册到配置服务器,并且所有连接的服务器都会在配置更改时收到配置更新。然后呢?
    1. 维护与每个服务器实例的端到端连接并使用每个传出数据迭代列表?
    2. 一些自定义 UDP 多播,但我需要在其之上添加我自己的附加可靠性。
  2. 自定义消息代理 - 在每个服务器连接并通知它时运行和维护注册表的服务。与每个服务器保持连接以接受数据并将其重新广播到其他服务器。
  3. 一些可靠的 UDP 多播传输,其中每个服务器实例直接广播并且不维护名册。

以下是我的担忧:

  • 我希望避免依赖外部应用程序,例如 Zookeeper 或 doozer,但如果它是最佳解决方案,我显然会使用它们。
  • 使用自定义消息代理,我不希望它成为吞吐量的瓶颈。这意味着我可能还必须能够运行多个消息代理并在扩展时使用负载均衡器?
  • 如果我设法推出自己的多播进程,则不需要任何外部进程,但否则我可能需要使用 ZMQ,这再次使我陷入依赖的境地。

我意识到我也在谈论消息传递,但它与我采用的解决方案密切相关。 顺便说一句,我的服务器是用 Go 编写的。关于保持可扩展性的最佳推荐方法有什么想法吗?

* 目标编辑*

我真正要问的是,在分布式服务器实例之间实现广播数据的最佳方法是什么,给出以下条件:

  1. 每个服务器实例都与其远程客户端保持持久的 TCP 套接字连接,并且在它们之间传递消息。
  2. 消息需要能够广播到其他正在运行的实例,以便可以将它们传递到相关的客户端连接。
  3. 低延迟很重要,因为消息传递可以是高速的。
  4. 顺序和可靠性很重要。

* 更新的问题摘要 *

如果您有多个服务器/多个端点需要在彼此之间进行发布/订阅,那么它们之间推荐的通信模式是什么?一个或多个消息代理将消息重新发布到一组已发现的服务器?直接来自每个服务器的可靠多播? 如何连接分布式系统中的多个端点,同时保持低延迟、高速度和可靠的交付?

I'm trying to get some feedback on the recommendations for a service 'roster' in my specific application. I have a server app that maintains persistant socket connections with clients. I want to further develop the server to support distributed instances. Server "A" would need to be able to broadcast data to the other online server instances. Same goes for all other active instances.

Options I am trying to research:

  1. Redis / Zookeeper / Doozer - Each server instance would register itself to the configuration server, and all connected servers would receive configuration updates as it changes. What then?
    1. Maintain end-to-end connections with each server instance and iterate over the list with each outgoing data?
    2. Some custom UDP multicast, but I would need to roll my own added reliability on top of it.
  2. Custom message broker - A service that runs and maintains a registry as each server connects and informs it. Maintains a connection with each server to accept data and re-broadcast it to the other servers.
  3. Some reliable UDP multicast transport where each server instance just broadcasts directly and no roster is maintained.

Here are my concerns:

  • I would love to avoid relying on external apps, like zookeeper or doozer but I would use them obviously if its the best solution
  • With a custom message broker, I wouldnt want it to become a bottleneck is throughput. Which would mean I might have to also be able to run multiple message brokers and use a load balancer when scaling?
  • multicast doesnt require any external processes if I manage to roll my own, but otherwise I would need to maybe use ZMQ, which again puts me in the situation of depends.

I realize that I am also talking about message delivery, but it goes hand in hand with the solution I go with.
By the way, my server is written in Go. Any ideas on a best recommended way to maintain scalability?

* EDIT of goal *

What I am really asking is what is the best way to implement broadcasting data between instances of a distributed server given the following:

  1. Each server instance maintains persistent TCP socket connections with its remote clients and passes messages between them.
  2. Messages need to be able to be broadcasted to the other running instances so they can be delivered to relavant client connections.
  3. Low latency is important because the messaging can be high speed.
  4. Sequence and reliability is important.

* Updated Question Summary *

If you have multiple servers / multiple end points that need to pub/sub between each other, what is a recommended mode of communication between them? One or more message brokers to re-pub messages to a roster of the discovered servers? Reliable multicast directly from each server?
How do you connect multiple end points in a distributed system while keeping latency low, speed high, and delivery reliable?

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

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

发布评论

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

评论(1

恏ㄋ傷疤忘ㄋ疼 2024-12-12 10:31:12

假设所有面向客户端的端点都位于同一 LAN 上(它们可以作为扩展中的第一个合理步骤),可靠的 UDP 多播将允许您直接从发布端点向任何拥有客户端的端点发送已发布的消息订阅了该频道。这也比通过持久存储层代理数据更好地满足低延迟要求。

多播组

  • 中央数据库(例如,Redis)可以跟踪多播组映射(IP:PORT)<-->渠道。
  • 当端点接收到要订阅的新频道的新客户端时,它可以向数据库询问频道的多播地址并加入多播组。

可靠的 UDP 多播

  • 当端点收到某个通道的已发布消息时,它会将该消息发送到该通道的多播套接字。
  • 消息数据包将包含每个多播组的每个服务器的有序标识符。如果端点接收到一条消息而没有从服务器接收到前一条消息,它将针对它错过的任何消息向发布服务器发送一条“未确认”消息。
  • 发布服务器跟踪最近消息的列表,并重新发送 NAK 的消息。
  • 为了处理服务器仅发送一条消息并使其无法到达服务器的边缘情况,服务器可以在其 NAK 队列的生命周期内向多播组发送数据包计数:“我已发送 24 条消息”,给其他服务器有机会 NAK 以前的消息。

您可能只想实施 PGM。

持久存储

如果您最终要长期存储数据,存储服务可以像端点一样加入多播组...但将消息存储在数据库中,而不是将它们发送到客户端。

Assuming all of your client-facing endpoints are on the same LAN (which they can be for the first reasonable step in scaling), reliable UDP multicast would allow you to send published messages directly from the publishing endpoint to any of the endpoints who have clients subscribed to the channel. This also satisfies the low-latency requirement much better than proxying data through a persistent storage layer.

Multicast groups

  • A central database (say, Redis) could track a map of multicast groups (IP:PORT) <--> channels.
  • When an endpoint receives a new client with a new channel to subscribe, it can ask the database for the channel's multicast address and join the multicast group.

Reliable UDP multicast

  • When an endpoint receives a published message for a channel, it sends the message to that channel's multicast socket.
  • Message packets will contain ordered identifiers per server per multicast group. If an endpoint receives a message without receiving the previous message from a server, it will send a "not acknowledged" message for any messages it missed back to the publishing server.
  • The publishing server tracks a list of recent messages, and resends NAK'd messages.
  • To handle the edge case of a server sending only one message and having it fail to reach a server, server can send a packet count to the multicast group over the lifetime of their NAK queue: "I've sent 24 messages", giving other servers a chance to NAK previous messages.

You might want to just implement PGM.

Persistent storage

If you do end up storing data long-term, storage services can join the multicast groups just like endpoints... but store the messages in a database instead of sending them to clients.

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