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

huangapple go评论87阅读模式
英文:

Data broadcasting between instances of distributed server

问题

我正在尝试获取关于在我的特定应用程序中为“roster”服务的建议的反馈。我有一个服务器应用程序,它与客户端保持持久的套接字连接。我希望进一步开发服务器以支持分布式实例。服务器“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?

答案1

得分: 2

假设您的所有面向客户的终端都在同一个局域网上(这对于扩展的第一步来说是可以的),可靠的UDP组播可以让您直接从发布端点向订阅该频道的任何终端发送已发布的消息。这也比通过持久存储层代理数据更好地满足低延迟的要求。

组播组

  • 一个中央数据库(比如Redis)可以跟踪组播组(IP:PORT)<--> 频道的映射。
  • 当一个终端接收到一个新的客户端和一个新的频道要订阅时,它可以向数据库请求该频道的组播地址并加入组播组。

可靠的UDP组播

  • 当一个终端接收到一个频道的已发布消息时,它将该消息发送到该频道的组播套接字。
  • 消息数据包将包含每个服务器每个组播组的有序标识符。如果一个终端在接收到来自服务器的前一个消息之前接收到了一条消息,它将向发布服务器发送一个“未确认”的消息,表示它错过了任何消息。
  • 发布服务器跟踪最近的消息列表,并重新发送未确认的消息。
  • 为了处理服务器仅发送一条消息但未能到达服务器的边缘情况,服务器可以在其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.

huangapple
  • 本文由 发表于 2011年9月20日 09:58:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/7479261.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定