5

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?

Hauleth
  • 22,873
  • 4
  • 61
  • 112
Russell
  • 12,261
  • 4
  • 52
  • 75
  • What is the server load like? Ruby is pretty CPU-heavy, if there is already a heavy load it's going to be quite slow. – AboutRuby Nov 14 '11 at 22:50
  • 1
    Try benchmarking server vs. development with some third-party software. I.e. Phoronix. – Slotos Nov 28 '11 at 13:25

1 Answers1

1

Take a look at:

Speeding up Rails startup time

And:

GitHub - rdp / faster_require

Anne
  • 26,765
  • 9
  • 65
  • 71
Mike Jr
  • 1,789
  • 3
  • 14
  • 21
  • Thanks, but those links appear to be mainly about Rails' *startup* time. If you have a look at the test code in the question you can see I'm getting a 3x slowdown just repeatedly assigning a variable in irb - no loading Rails, no `require`s or anything. I'm coming to the conclusion that the VPS is just utter crap. – Russell Nov 28 '11 at 21:54
  • I don't use Rails. Take a second look. :-) – Mike Jr Nov 28 '11 at 22:17
  • I did look at them! They're about speeding up *load* time, especially by speeding up `require`. There are no `require`s in `n = Time.now ; x = 0 ; 10000000.times { x += 1 } ; puts Time.now - n` and irb is already loaded so I don't see how these links can possibly help. – Russell Nov 29 '11 at 10:09
  • Thanks for the suggstion though :-) – Russell Nov 29 '11 at 10:10