为什么 Windows 不适合用于实时系统/高性能服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6206305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:58:29  来源:igfitidea点击:

Why is Windows not considered suitable for real time systems/high performance servers?

windowsperformancereal-time-systems

提问by Collin Dauphinee

I hope this question isn't too subjective, but why is Windows considered an unsuitable operating system for real time systems and high performance servers? Are there any technical papers or studies that gauge it's performance compared to *nix alternatives?

我希望这个问题不是太主观,但为什么 Windows 被认为不适合实时系统和高性能服务器的操作系统?与 *nix 替代品相比,是否有任何技术论文或研究来衡量它的性能?

I've never actually heard any explanation of why developers are against using Windows for these types of systems, aside from the extremely common 'Windows is not a real time operating system' statement, as if it's some kind of well known fact that doesn't need to be justified.

除了极其常见的“Windows 不是实时操作系统”声明之外,我实际上从未听说过为什么开发人员反对将 Windows 用于这些类型的系统的任何解释,就好像它是某种众所周知的事实一样”不需要理由。

Note that I'm asking about Windows CE/Windows Server, not the desktop versions of the operating system.

请注意,我问的是 Windows CE/Windows Server,而不是操作系统的桌面版本。

回答by Tod

A real-time OS needs a certain amount of deterministic behavior. You want to be able to set up specific task priorities that are always honored and have interrupts that have a specific priority. You can't have an OS that might decide to give priority to a daemon or task that is outside your application. Depending on your system microseconds might matter, an OS that goes off for 50 usecs to handle a daemon outside your application might be deadly.

实时操作系统需要一定数量的确定性行为。您希望能够设置始终受到尊重的特定任务优先级,并具有具有特定优先级的中断。您不能拥有一个可能决定优先考虑应用程序之外的守护进程或任务的操作系统。根据您的系统微秒可能很重要,一个运行 50 微秒来处理应用程序外部守护程序的操作系统可能是致命的。

Now, with that said it doesn't mean you can't use Windows for a real time application. In fact I've done it several times, it's just the real-time aspects were handled by hardware cards and buffering built into the system. If the OS was hundreds of milliseconds late it just meant the display might have a perceptible hiccup in the data. No data was ever lost or not collected. We were also able to avoid problems by customizing what other tasks were running (pretty much the same thing hard core gamers do).

现在,话虽如此,但这并不意味着您不能将 Windows 用于实时应用程序。事实上我已经做过好几次了,只是实时方面是由硬件卡和系统内置的缓冲处理的。如果操作系统延迟数百毫秒,则仅意味着显示数据可能会出现明显的打嗝。没有数据丢失或未收集。我们还能够通过自定义其他正在运行的任务来避免问题(与硬核游戏玩家所做的几乎相同)。

Alternately, I had a recent request to do a real-time system where the real-time hardware would issue a callback that the windows code would see and then send out a USB message. The message had to be sent within microseconds and whatever the delay was it HAD to be deterministic so that the system receiving the USB message could compensate for the delay. This struck me as something that Windows is not suited for and the design was reworked.

或者,我最近有一个要求做一个实时系统,实时硬件会发出一个回调,Windows 代码会看到这个回调,然后发送一条 USB 消息。消息必须在几微秒内发送,无论延迟是多少,它都必须是确定性的,以便接收 USB 消息的系统可以补偿延迟。这让我觉得 Windows 不适合,并且重新设计了设计。

Even though this question is now closed I thought I would udpate this response with a link to lengthier blog post I wroteon the topic.

即使这个问题现在已经结束,我想我会用一个链接来更新这个回复,我写的关于这个主题的更长的博客文章

回答by djdanlib

Windows has a long-standing reputation about that, based primarily upon isolated bad experiences (everyone has a few, don't they?) which persists through major revisions that obsolete old reasons. Unfortunately, the vast majority of system administrators have never seen any of the performance tuning documents freely available from Microsoft, and even fewer have bothered to tune their systems appropriately.

Windows 在这方面享有悠久的声誉,主要基于孤立的不良体验(每个人都有一些,不是吗?)通过重大修订,旧的原因已经过时。不幸的是,绝大多数系统管理员从未见过微软免费提供的任何性能调优文档,更少人会费心适当调优他们的系统。

Real-time critical systems can work on Windows. Look at call center solutions, for example - this is one of my areas of expertise, and I oversee several dozen servers doing exactly this. These machines can have hundreds of lines simultaneously processing voice recognition and speech synthesis at the same time, communicating with databases and programmable call routing systems. Delays in responding to the telephone company's equipment can cause some or all of those calls to be dropped or call quality to degrade severely. We still have to implement antivirus and other security measures, and these systems run.

实时关键系统可以在 Windows 上运行。例如,看看呼叫中心解决方案——这是我的专业领域之一,我负责监督几十台服务器正是这样做的。这些机器可以有数百条线路同时处理语音识别和语音合成,与数据库和可编程呼叫路由系统进行通信。对电话公司设备的响应延迟会导致部分或全部呼叫掉线或呼叫质量严重下降。我们仍然必须实施防病毒和其他安全措施,这些系统才能运行。

The most important things you need to do are: * Eliminate periodic automated jobs and processes, like checking for and applying updates, disk maintenance (such as defrag operations and cleanup) and full scans, and move them to regularly scheduled downtime for maintenance. * Have enough memory so the system doesn't get bogged down with swapping * Put your swap on its own partition so fragmentation doesn't interfere with the swapfile (some of my systems don't have this and still work) * Work with the antivirus vendor to fine-tune their product such that it interferes with your server(s) as little as possible while still providing adequate protection - most antivirus software is meant for desktop use, not server use, and will require tuning * Tune your group / local security policies

您需要做的最重要的事情是: * 消除定期自动化作业和进程,例如检查和应用更新、磁盘维护(例如碎片整理操作和清理)和完整扫描,并将它们移到定期计划的停机维护时间。* 有足够的内存,这样系统就不会因为交换而陷入困境 * 把你的交换放在它自己的分区上,这样碎片就不会干扰交换文件(我的一些系统没有这个但仍然可以工作) * 使用防病毒供应商对他们的产品进行微调,使其在提供足够保护的同时尽可能少地干扰您的服务器 - 大多数防病毒软件是为桌面使用而设计的,而不是服务器使用,并且需要调整 * 调整您的组/本地安全策略

In the end, UN*X systems can have the same problems if you don't administer them properly: Scheduled jobs, inadequate swap configuration, and intrusive 3rd party security software. They also get overlooked when it comes to security so often that it's no more surprising when they are compromised than when a Windows server is compromised.

最后,如果您没有正确管理 UN*X 系统,它们可能会遇到同样的问题:计划作业、不适当的交换配置和侵入性的 3rd 方安全软件。当涉及到安全性时,它们也经常被忽视,以至于当它们受到损害时,与 Windows 服务器受到损害时相比,这并不奇怪。

You've got to have balance. Both platforms can be equally mismanaged, and both platforms can be well-tuned. If you're talking primarily to UN*X platform people, well, they have reasons they like their platform and have a lot of bias against Windows and you'll get answers that reflect that. If you're talking to Microsoft people, you'll get the same from their angle.

你必须保持平衡。两个平台都可能同样管理不善,两个平台都可以很好地调整。如果您主要与 UN*X 平台人员交谈,那么,他们有理由喜欢自己的平台并且对 Windows 有很多偏见,您会得到反映这一点的答案。如果您与 Microsoft 人员交谈,您将从他们的角度得到相同的结果。

The most important thing when you're choosing the platform should be vendor support for the APPLICATION you're running - which one are they more invested in, and which one have they favored in their development? What has been proven to work the best, and what will continue to be available in the future?

当您选择平台时,最重要的事情应该是供应商对您正在运行的应用程序的支持——他们在哪一个上投入更多,他们在开发中偏爱哪一个?哪些已被证明效果最好,哪些将在未来继续可用?

回答by jalf

If you want an answer, you should give us some facts to work with. Who says Windows isn't suitable for high performance servers? We have no clue, but you apparently do. So you're better qualified to answer it than we are, aren't you?

如果你想得到答案,你应该给我们一些可以参考的事实。谁说 Windows 不适合高性能服务器?我们不知道,但你显然知道。所以你比我们更有资格回答,不是吗?

As for realtime systems? It's true. Windows isn't suitable because it's not a realtime OS. The same is true for Linux and OSX, btw. Realtime systems need some pretty specialized OS'es. And mainstream OS'es aimed at performance, throughput and responsiveness aren't going to do the trick, whether they're written by Microsoft or anyone else.

至于实时系统?这是真的。Windows 不适合,因为它不是实时操作系统。顺便说一句,Linux 和 OSX 也是如此。实时系统需要一些非常专业的操作系统。以性能、吞吐量和响应能力为目标的主流操作系统不会成功,无论它们是由 Microsoft 还是其他任何人编写的。

回答by Mark Ransom

Real time systems typically have a requirement for a maximum response time. Windows can't provide such guarantees.

实时系统通常需要最大响应时间。Windows 无法提供此类保证。

As for Windows servers doing high performance, what do you think runs StackOverflow?

至于高性能的 Windows 服务器,你认为 StackOverflow 是什么?

回答by Steven Sudit

The answers you received were correct: Windows simply isn't a RTOS. To be one, it would have to be able to make specific guarantees regarding scheduling. The behavior needed to do that is not particularly compatible with what's appropriate for a regular server or workstation.

您收到的答案是正确的:Windows 根本就不是 RTOS。要成为其中之一,它必须能够对调度做出具体保证。这样做所需的行为与适用于常规服务器或工作站的行为并不特别兼容。

As for "high performance", that's just vague. Server editions of Windows can and do run high-performance systems.

至于“高性能”,那只是含糊其辞。Windows 的服务器版本可以并且确实运行高性能系统。