处理实时分布式系统中的延迟
我正在尝试实现一个扑克服务器。 http 服务器将数据包转发到处理所有扑克牌状态的后端服务器。在任何给定的牌局中,要行动的玩家有 10 秒的时间来行动(下注、弃牌、跟注、加注等)。如果10秒内没有响应,服务器会自动为他们折叠。为了检查 10 秒是否已经过去,必须维护何时必须接收操作的事件列表。它是一个按时间排序的优先级队列,当前正在玩的每一手牌在优先级队列中都有一个条目。
考虑以下场景,因为上一个操作在下一个操作到达 http 服务器之前已经过了 9.99 秒。当操作被转发到后端服务器时,已经过去了额外的时间,所以现在总共已经过去了 10.1 秒。后端服务器将声明手已折叠,但我希望处理该操作,因为从技术上讲,它在 9.99 秒后到达 http 服务器。现在,一种解决方案是让后端在声明手已折叠之前等待一些额外的时间,以查看时间戳为 9.99 秒的操作是否到来。但这会导致下一个人采取行动时的延迟。
我想要的目标是
- 处理在 9.99 秒到达 http 服务器的操作,而不是折叠他们的手。
- 积极减少因必须进行空闲等待来“解决”要点 1 中提到的问题而导致的延迟。
有哪些不同的解决方案?对于分布式系统的专家来说,有关于各种解决方案的权衡的已知文献。我想知道分布式系统文献认为可以接受的各种解决方案。不仅仅是各种临时解决方案。
I am trying to implement a poker server. An http server forwards data packets to the backend servers which handle the state of all the poker hands. In any given hand the player to act gets 10 seconds to act (bet,fold,call,raise,etc.). If there is no response within 10 seconds the server automatically folds for them. To check that 10 seconds has passed an event list of when actions must be received is maintained. It is a priority queue ordered by time and each poker hand currently being played has an entry in the priority queue.
Consider the following scenario since the last action 9.99 seconds pass before the next action arrives at the http server. By the time the action is forwarded to the backend servers extra time passes so now a total of 10.1 seconds have passed. The backend servers will have declared the hand folded, but I would like the action to be processed since technically it arrived at the http server after 9.99 seconds. Now one solution would be to have the backends wait some extra time before declaring a hand folded to see if an action timestamped at 9.99 seconds comes. But that would result in delaying when the next person in the hand gets to act.
The goals I would like are
- Handle actions reaching the http server at 9.99 seconds instead of folding their hand.
- Aggressively minimize delay resulting from having to do idle waiting to "solve" problem mentioned in bullet point 1.
What are the various solutions? To experts in distributed systems is there known literature on what the trade offs are to various solutions. I would like to know the various solutions deemed acceptable by distributed systems literature. Not just various ad hocs solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许在服务器端,当客户端请求到达时,您可以获取时间戳?
那么您会采用“开始”和“停止”时间戳来准确测量 9.9 秒吗?
Maybe on the server side when client request arrives you could take the timestamp?
So you would take "start" and "stop" timestamps, to measure exactly 9.9s?