服务器在不引起“饥饿"的情况下为客户端提供食物. [英] Server feeding clients without causing "starvation"

查看:116
本文介绍了服务器在不引起“饥饿"的情况下为客户端提供食物.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我不必对此进行处理,但是似乎您无法避免这种不可避免的情况.
我的服务器中有一堆消息(从低层客户端和上层服务器接收),最终应该广播给所有客户端和服务器(简单树层次结构).
我对C#套接字或一般系统的性能并不十分熟悉.
我真的不知道我的设计在实时条件下如何处理(我不是在说超级计算机,只是普通的服务器,有时甚至是普通的计算机...).
无论如何,我不知道分发时间是否足以处理所有传入的消息,对其进行处理,然后再将其分发给其他消息.

我开始考虑调度策略,所有这些都必须处理以下几件事:
答:如果与客户端断开连接,则在重新连接客户端时,需要更新有关相关更改的信息.
B.有些消息更重要(它们被优先处理),但是如果我只让它们通过(首先),它们很容易饿死较低的优先级.

也许可以使用简单的循环调度,或者通过消息将消息分发给尚未得到的所有客户端.

你们怎么想?

I hoped I wouldn''t have to deal with that, but it seems like you can''t avoid the inevitable.
I have in my server a pile of messages (received from the low-tier clients, and the upper-tier server), and are supposed to be broadcast eventually to all the clients, and to the server (simple tree hierarchy).
I''m not really familiar with the performance capabilities of C# sockets, or of my system in general.
I really have no idea how would my design deal under real-time conditions (I''m not talking about a supercomputer, just an ordinary server, sometimes even an ordinary computer...).
Anyway, I don''t know if the distribution time would be sufficient to deal with all the incoming messages, treat them, and then distribute them to the others.

I started to think about scheduling strategies, all must deal with several stuff:
A. If there was a disconnection from a client, when he reconnects, he needs to be updated about the relevant changes.
B. There are messages that are more important (they are prioritized), but then if I let only them pass (first), they could very easily starve the lower priorities.

Maybe simple round-robin scheduling would do, or distribute by message to all the clients that didn''t get it yet.

What do you guys think?

推荐答案

不建议从服务器向客户端发送消息,因为客户端可能处于脱机状态,并且会占用服务器和服务器上的大量资源.无法缩放.

建议从客户端轮询.

对于消息的分发(取决于您对低延迟和低优先级的要求),您可以查看RSS feed.

对消息进行优先级排序就像将优先级值放在消息上并对其进行排序一样简单.
Sending messages from servers to clients is not recommended as the clients could be offline and it would take up to much resources on the server and wouldn''t scale.

Polling from the clients is recommended.

For the distribution of messages (depending on your requirements of low latency and low priority) you can look into RSS feeds.

Prioritizing messages is as simple as putting a priority value on them and sorting on that.


这篇关于服务器在不引起“饥饿"的情况下为客户端提供食物.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆