为什么 CGIHTTPServer 在 Windows 中这么慢?
几天前,我注意到在本地主机上运行的 Python 2.7 和 2.6 的 CGIHTTPServer 的服务请求在 Windows 上运行时有一个小但明显的延迟(约 2 秒),这种延迟在运行在同一主机上的 Linux 上不存在硬件(我正在编写的页面大量使用 AJAX,这种滞后会减慢测试速度)。我在其他几台计算机上尝试过这个方法,并尝试了一个非常简单的测试 CGI 脚本(print random.randint(...)),结果类似。
我有时听到人们说 Window 的 CreateProcess 比 Linux 的 fork-exec 慢得多,但我总是将它们视为 100 年前的论点,在现代硬件中的现代 Windows 中不再相关。现在我亲眼看到了这一点。
然而,我将表现出怀疑的态度。有人有其他解释来解释为什么 CGIHTTPServer 在 Windows 上比在 Linux 上慢得多吗?
A few days ago, I noticed that serving requests from Python 2.7's and 2.6's CGIHTTPServer running on localhost have a small but noticeable (~2 second) delay when running on Windows, this lag does not exist on Linux running on the same hardware (the page I'm writing is AJAX heavy and this lag is slowing down testing). I've tried this on a few other computer and tried a dead simple test CGI script (print random.randint(...)) with similar results.
I've sometimes heard people saying that Window's CreateProcess is much slower than Linux's fork-exec but I always dismissed them as 100-years-old arguments that is no longer relevant in modern Windows in modern hardware. Now I'm seeing this with my own eye.
However, I'm going to put on my skeptical spectacle. Anyone had any alternative explanation to explain why CGIHTTPServer is so much slower on Windows compared to on Linux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 cgihttpserver 为每个请求生成一个进程,这在 Windows 上要慢得多,
使用线程解决方案可能会更幸运(wsgi?)
I think cgihttpserver spawns a process for each request, this is a lot slower on windows,
you may have more luck by using a threaded solution instead (wsgi?)