为什么 Ruby 在 Windows 服务器上的运行速度比在 Windows 开发机器上慢得多?

发布于 2024-12-15 13:24:22 字数 957 浏览 3 评论 0原文

首先,如果可以的话,我会切换到 Linux,但由于对第三方的依赖,我不能。

我正在完成 Rails 应用程序并将其部署到 Windows 2008 服务器上。在服务器上进行测试时,该应用程序被证明速度非常慢,每个请求需要 2-5 秒。在我的开发机器上,速度远没有这么慢,据我所知,速度慢是在 Rails 本身内部,即。我在服务器上看到诸如 Completed 200 OK in 1859ms (Views: 1687.5ms) 之类的日志记录,而在我的开发计算机上则看到 Completed 200 OK in 347ms (Views: 298.0ms)

我知道 Rails 在 Windows 上应该比在 Linux 上慢,但是为什么它在 Windows 服务器上会比在我的 Windows 7 开发机器上慢呢?

在开发中,我运行 WEBrick,在服务器上我在 apache 下运行。我也尝试过在我的开发机器上运行瘦程序,它比 WEBrick 更快。有没有人对可能导致如此大的减速的原因或需要调查的内容有任何建议?任何事情都会非常感激。

更新: 看来是 Ruby 本身在服务器上速度明显慢了。在我的开发机器上,在 irb 中运行以下命令需要 0.6 秒,但在服务器上平均需要 3 秒以上:

n = Time.now ; x = 0 ; 10000000.times { x += 1 } ; puts Time.now - n

是什么导致 Ruby 在服务器上运行速度如此之慢(超过 3 倍)?可以是windows版本吗?或者其他什么? Ruby 版本完全相同:ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

再次更新:

因为没有早点提到这一点而感到愚蠢,但它是一个 VPS。然而,尽管我愿意接受这会减慢速度——慢 3 倍以上现实吗?

First of all, I would switch to Linux if I could, but I can't, due to a 3rd party dependency.

I'm in the process of finishing and deploying a rails app onto a windows 2008 server. While testing on the server the app is proving to be painfully slow, with requests taking between 2-5 seconds each. It's nowhere near this slow on my development machine, and as far as I can tell the slowness is within Rails itself, ie. I see logging such as Completed 200 OK in 1859ms (Views: 1687.5ms) on the server compared to Completed 200 OK in 347ms (Views: 298.0ms) on my dev machine.

I know Rails is supposed to be slower on Windows than it is on Linux, but why would it be slower on a windows server than it is on my windows 7 dev machine?

In development I'm running WEBrick, on the server I'm running thin under apache. I've also tried running thin on my dev machine and it is faster if anything than WEBrick. Has anyone got any suggestions on what could be causing such a large slowdown or what to look into? Anything at all would be much appreciated.

Update: It seems that it is Ruby itself that is dramatically slower on the server. Running the following in irb takes 0.6 of a second on my dev machine but on average more than 3 seconds on the server:

n = Time.now ; x = 0 ; 10000000.times { x += 1 } ; puts Time.now - n

What could be causing Ruby to run so much slower (more than 3x) on the server? Could it be the windows version? Or something else? The Ruby version is exactly the same: ruby 1.9.2p290 (2011-07-09) [i386-mingw32].

Update again:

Feel stupid for not mentioning this earlier, but it's a VPS. However, although I'm willing to accept this would slow it down a bit - is more than 3 times slower realistic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文