Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Ruby run so much slower on windows server than on windows dev machine?

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?

like image 458
Russell Avatar asked Nov 14 '22 14:11

Russell


1 Answers

Take a look at:

Speeding up Rails startup time

And:

GitHub - rdp / faster_require

like image 103
Mike Jr Avatar answered Mar 08 '23 23:03

Mike Jr