3

Windows 7, Rails 3 here. I local/development mode, rails server does not handle multiple request at the same time. The process crash and the cmd prompt comes in front.

I've noticed this behaviour when :

  • having too much ajax request, too close from one another
  • loading a simple page on 2 browsers

Is there a way workaround that ? Change the local server (default is webrick) ? How is that done ?

Thanks.

Marcel Falliere
  • 1,884
  • 21
  • 39
  • How are you loading this simple page? What does your page's view and controller code look like? – acconrad Apr 22 '11 at 17:27
  • 1
    In development mode, by default, the mongrel server run in single threaded mode. You can add config.threadsafe! in development.rb to make it run in multi-threaded mode. – so_mv Jun 27 '13 at 01:40

2 Answers2

7

I don't know if this still needs an answer but I did this by adding gem 'puma' to the Gemfile then you'll need to add config.threadsafe! to either your config/application.rb or the environment file you're running on (like config/environments/development.rb.

Sometimes you might not want threadsafe on so I so did this in my development.rb:

if ENV["THREADS"]
  config.threadsafe!
end

Now (with what I did in my development.rb) I can do rails s Puma and it will run with a max of 16 threads and can handle multiple requests. You can also up the thread pool and configure more with Puma, docs are here

Update

Note that the use of config.threadsafe! is not needed in Rails 4+ and is deprecated I believe.

Jon Phenow
  • 3,974
  • 5
  • 26
  • 30
  • Webrick can also serve mutliple requests, so it's not necessary to replace it with Puma. – Slobodan Kovacevic Dec 12 '13 at 18:19
  • Indeed, though seem to avoid using WEBrick in production and if you do choose to go with Puma for production, this brings your development environment a little closer to your production configuration. You're right though, that's not the discussion at hand, I didn't know that at the time of writing this. – Jon Phenow Dec 18 '13 at 16:44
0

You need to install the mongrel gem and this specify which server you want to use when you rails s

I don't know how you guys do it on win systems. Why not run a virtual Unix box? isn't rails just much easier with it? So with Unix it would be something like:

Install mongrel gem:

gem install mongrel

Then specify which server you want to run:

rails server mongrel
thenengah
  • 42,557
  • 33
  • 113
  • 157