This forum is no longer active. Please post your questions to our new community site

Using Mongrel in RubyStack to serve pages in windows

Subscribe to Using Mongrel in RubyStack to serve pages in windows 4 post(s), 2 voice(s)

 
Avatar benmute 2 post(s)

Hi all,

Am new to Rubystack and I have succeeded in installing it on my Windows box. Its running and I can access my site. The problem however is that its abit slow and every time I access a page, the webserver takes up all my computer resources (Processor usage goes to 100%). I think am serving the pages in webrick as apache is not running even after ‘servicerun.bat start’. What could be the problem? How do I use the mongrel cluster I have learnt about in my research?

Any assistance will be greatly appreciated.

Thanks

 
Avatar Beltrán Rueda Administrator 3,714 post(s)

Hi,

You can find more information about how to create mongrel cluster and how to install mongrel as services at BitNami Quick Start Guide

If you select “production mode” during the RubyStack installation the Stack will create an Apache configuration file to load balance between several mongrels but I don’t know if this configuration resolve your resources problem. Why do you think that you are serving pages with webrick? When you start the server you can see a message similar to this:

=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

  • Starting Mongrel listening at 0.0.0.0:3000
  • Starting Rails with development environment…
  • Rails loaded.
  • Loading any Rails specific GemPlugins
  • Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
  • Rails signals registered. HUP => reload (without restart). It might not work well.
  • Mongrel 1.1.4 available at 0.0.0.0:3000
  • Use CTRL-C to stop.

I hope it helps you.

 
Avatar benmute 2 post(s)

Hi,
Thanks for your assistance.

Here is what i get when I start the server:

=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

Starting Mongrel listening at 0.0.0.0:3000
Starting Rails with development environment…
GLoc v1.1 running in development mode. Strings can be modified at runtime.
Rails loaded.
Loading any Rails specific GemPlugins
Signals ready. INT => stop (no restart).
Mongrel 1.1.2 available at 0.0.0.0:3000
Use CTRL-C to stop.

The server seems to be running in development mode: does this havee any effect on the resources it uses?
I set 4 mongrel clusters on ports 3001,3002,3003,3004 – do I need to start the server on all these ports for load balancing to apply?

The reason I think am serving pages with webrick is because I can find apache running under processes (task manager) and the fact that am starting the server the same way I start webrick.

Also if possible could you explain abit to me how load balancing is used in this case (use my 4 ports).

Regards.

 
Avatar Beltrán Rueda Administrator 3,714 post(s)

Hi, I will try to do it.

You can use Apache 2.2 to handle all incoming requests. Apache 2.2 uses mod_proxy to redirect the incoming HTTP requests to the mod_proxy_balancer cluster. The cluster consists of several Mongrel processes on each application server and distributes the requests.

To create this setup you only have to start mongrels and configure Apache to run as a proxy balancer. The next file is an example which configures Apache to balance load with two Mongrel servers. If you want to add mongrels you only have to include more balancer members on different ports. This file is created during the RubyStack installation on production mode selection, depending of the number of mongrels and the ports chosen to Apache and Mongrel servers.


<VirtualHost *:8080>
  ServerAdmin <a href="mailto:info@example.com">info@example.com</a>
  ServerName <a href="http://www.example.com">www.example.com</a>
  ServerAlias example.com
  ErrorLog "logs/rubystack_apache_error_log" 
  CustomLog "logs/rubystack_apache_access_log" combined
 # this not only blocks access to .svn directories, but makes it
 # appear as though they aren't even there, not just that they are 
 # forbidden
 <DirectoryMatch "^/.*/\.svn/">
    ErrorDocument 403 /404.html
    Order allow,deny
    Deny from all
    Satisfy All
  </DirectoryMatch>
  # This passes through remote_user to mongrel
  RewriteEngine On
  # Redirect non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://rubystackcluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>
<Proxy balancer://rubystackcluster>
  BalancerMember <a href="http://127.0.0.1:3001">http://127.0.0.1:3001</a>
  BalancerMember <a href="http://127.0.0.1:3002">http://127.0.0.1:3002</a>
</Proxy>

To Apache can load the redmine-mongrel-cluster.xml file you have to enable these modules into httpd.conf (RubyStack will be do automatically):

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Using this configuration, you only have to start the mongrels and launch your web browser at http://your_ip:port/ and you will be redirected to one of them.

=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)

As you can see, you are running Mongrel by default. Webrick is different to Apache, both are independent servers. There is not relation between Apache processes and ruby on rails servers (webrick or mongrel).