PassengerMaxPoolSize

Published by: Gianluigi Di Donato on May 02, 2009 0 Comments

PassengerMaxPoolSize is a config parameter of modrails .

My production environment runs many tiny applications. I’m a greedy sysadmin, always trying to save resources, so i’d like to save even one clock-cycle or a single bit of my RAM. It’s an ordinary way of doing it, isn’t it? ;)

Let me explain better my test…

On my test lab, i’ve a Ubuntu Vps Xen based with 256MB RAM, and i’m going to test PassengerMaxPoolSize, setting it to 10 in spite of the Passenger’s team piece of advice.

I want to do it because i’ve many tiny applications with light performance requirements, giving them too much resources doesn’t sound such a good idea then i’ve decided to test the modrails & Ruby Enterprise couple in the context of lightweight applications too.

PassengerMaxPoolSize default value is 6. Passenger’s team recommend to set the value to 30 if your system has 2GB of RAM but if you have a very small system, provided by a Virtual Private Server with 256MB RAM and is also running other services such as MySQL, then we recommend a value of 2.

Actually, the results i got aren’t so comfortable, my little vps went wrong, i had to setup PassangerMaxPoolSize to a lower value. using the bit of advice of the modrails’team is too much careful, a right compromise in order to run many small applications on a tiny vps is to set PassangerMaxPollSize to 4.

Obviously setting the parameter to 4 is the result of experiments on test environments, it could be useful to work out the very right value considering the following parameters:

  1. HW features of your VPS (CPU, RAM, Swap)
  2. HTTP requests
  3. Running Application features
  4. Running Services on VPS (MySQL, sendmail, etc.)

and furthermore all you think it can be related to the resources management of your VPS.

Remarks like that we have just written about will be followed by others on the same subject. So, as always, stay tuned.

The gem server command

Published by: Luca Pette on Apr 28, 2009 0 Comments

We all know the gem server command, don’t we?

By the way, if you don’t know it, you can try something like the following:

1 lucapette@hal9000$gem server

This command starts an instance of webrick listening to the port 8808 by default.So, you can browse http://localhost:8808 and will see something very useful. A list of all gems installed on your machine with a section for each gem and links to documentation. Everybody needs something like that, i think. Because i love to dig a bit into all i run into i’ve taken a look at the options provided by server command. I’ve found out that gem server, when launched, assumes the followings defaults:

1 gem server  --port 8808 --dir /usr/lib/ruby/gems/1.8 --no-daemon
So we can use gem server as a daemon and, obviously, we can choose the port where the webrick server will listen to requests.

Just a few days ago, i was thinking about the possibility to demonize gem server in order to run it at the startup on my server and i’ve simply added to the very bottom of mine /etc/rc.local the following line:

1 gem server --daemon

Multiple istances of Ferret server on the same machine

Published by: Algweb on Apr 20, 2009 0 Comments

It can happen than variours Rails applications, running on the same server, need a private Ferret Server instance.

To get this done, you need to set a particular configuration up within your applications. A Rails applcation that needs ferret come with a configuration file located at config/ferret_server.yml. It should contain something like the following:

 1 # configuration for the acts_as_ferret DRb server
 2 # host: where to reach the DRb server (used by application processes to contact the server)
 3 # port: which port the server should listen on
 4 # pid_file: location of the server's pid file (relative to RAILS_ROOT)
 5 # log_file: log file (default: RAILS_ROOT/log/ferret_server.log
 6 # log_level: log level for the server's logger
 7 production:
 8   host: app_host
 9   port: 9011
10   pid_file: log/ferret.pid
11   log_file: log/ferret_server.log
12   log_level: warn
13 # aaf won't try to use the DRb server in environments that are not
14 # configured here.
15 development:
16   host: app_host
17   port: 9011
18   pid_file: log/ferret.pid
19 test:
20   host: app_host
21   port: 9009
22   pid_file: log/ferret.pid

As you can see reading that file, ferret will listen to a particular port based on the running environment. So in order to run mutiple ferret instances you just have to config each ferret instance on a specific port.

Let look at a little example:

Application 1

path-to-www/MyApplication1/config/ferret_server.yml
1 production:
2 host: app1_host
3   port: 9011
4   pid_file: log/ferret.pid
5   log_file: log/ferret_server.log
6   log_level: warn

Application 2

path-to-www/MyApplication2/config/ferret_server.yml

1 production:
2 host: app2_host
3   port: 9012
4   pid_file: log/ferret.pid
5   log_file: log/ferret_server.log
6   log_level: warn
So, as you can see, it is very simple to get a mutiple ferret server instances configuration.

Happy Birtday "Phusion Passenger"

Published by: Algweb on Apr 18, 2009 0 Comments

This is Phusion ’s first year anniversary as a company.

Linux for Rails and its staff wish you an Happy Birtday.

Thank you Phusion for your job done.

Handling the gem sources command

Published by: Algweb on Apr 16, 2009 0 Comments

Very often it can happen you need to install a gem that isn’t published on the rubyforge repository .

Surely, you ran into a gem from the github repository .

In case like that, you have to add a source repository to your gem sources installation then you have done something like the following:

gem sources -a http://path-to-gem-repository

Yep, good enough to get your job done but if you run the help command for sources (as in the following example) you will see that the sources command comes with a rich number of options as add, list, remove…

 1 algweb@linux4rails:~$ gem  help sources
 2 Usage: gem sources [options]
 3 
 4   Options:
 5     -a, --add SOURCE_URI             Add source
 6     -l, --list                       List sources
 7     -r, --remove SOURCE_URI          Remove source
 8     -c, --clear-all                  Remove all sources (clear the cache)
 9     -u, --update                     Update source cache
10 
11   Common Options:
12     -h, --help                       Get help on this command
13     -V, --[no-]verbose               Set the verbose level of output
14     -q, --quiet                      Silence commands
15         --config-file FILE           Use this config file instead of default
16         --backtrace                  Show stack backtrace on errors
17         --debug                      Turn on Ruby debugging
18 
19 
20   Summary:
21     Manage the sources and cache file RubyGems uses to search for gems
22 
23   Defaults:
24     --list

As usual, gem is very simple and can show some beautiful surprises if you dig into it.

Stay tuned

A Rails demo from the scratch in 10 minutes

Published by: Algweb on Apr 10, 2009 0 Comments

I’m going to write about a quick experience that it makes possible to run into an important situation.

I was in hurry and need to create a RoR application demo for a not very nice Client. I was asking for run an application on their private network and i had few time to get it done.

Surely i couldn’t set up a server to run a demo, my Client didn’t own a Rails environment

So i thought about a virtual environment, i needed a VPS, then i started a search in the VMWARE’s Virtual Marketplace Appliance and i ran into:

www.turnkeylinux.org

Very interesting, very useful. I’ve just found out an appliance that fits perfectly my requirements:

Ubuntu HardyHeron 8.04×86TurnKey Rails Appliances

I dug into it and looking at the official site of Turkey Linux i found out that it’s possible to download a very small ISO, circa 169mb.

In a few minutes, i was able to install a minimal distribution that seems to exist exactly to solve the kind of problem i was trying to solve. It was perfect to make happy my uneasy Client.

In the following lines i report some of the featueres included in the ISO:

This appliance includes all the standard features in TurnKey Core, and on top of that:

  • SSL support out of the box
  • Webmin modules for configuring Apache2, and MySQL. (webmin is listening on port=12321)
  • Preconfigured example Rails application located at /var/www/railsapp

    o Apache2 configured as a load-balancing reverse proxy to a 3-node mongrel cluster. o MySQL databases setup for production, development and testing. o The Rails application secret and database password will be regenerated during installation (security).

  • RubyGems package manager installed from upstream tarball

    o APT and RubyGems are both package management systems and may potentially conflict. o We recommend using RubyGems for managing Rails components (called gems), and APT for everything else. o Essential build packages (build-essentials) are included to aid in building gems

  • Default credentials

    o Webmin, SSH, and MySQL: username root, no password o user sets passwords during installation

Installed gems are:
 1 root@rails:~# gem list
 2 
 3       *** LOCAL GEMS ***
 4 
 5       actionmailer (2.3.2)
 6       actionpack (2.3.2)
 7       activerecord (2.3.2)
 8       activeresource (2.3.2)
 9       activesupport (2.3.2)
10       cgi_multipart_eof_fix (2.5.0)
11       daemons (1.0.10)
12       fastthread (1.0.5)
13       gem_plugin (0.2.3)
14       mongrel (1.1.5)
15       mongrel_cluster (1.0.5)
16       mysql (2.7)
17       rails (2.3.2)
18       rake (0.8.4)

It is really essential and maybe mongrel is too much good for a demo :D

A brand-new look Linux for Rails

Published by: Algweb on Apr 08, 2009 0 Comments

After just over a month since its first release linux for rails changes look.

The new look comes from the generous donation of Luca Pette (one of the authors of Linux for rails), this layout is a custom implementation of Acts as my self (lucapette’s blog).

Thank you very much Luca

Install gem by version

Published by: Gianluigi Di Donato on Mar 05, 2009 0 Comments

Question:

Hi Gianluigi, I have a problem in my production environment I need to install rails 2.1.0 to run an old application, but I have Rails 2.2.0, i’ve already read man page for ruby gem but … :-( .... what can I do? Please help me

Answer:

Hi Andrew, Don’t worry you can use -v option. You can run this command:

1 gem install -v=2.1.0 rails
:-)

First Steps with Rails

Published by: Algweb on Mar 05, 2009 0 Comments

When i started to develop my first rails applications, on an Ubuntu machine, i had to set up my toolbox.

The first step was trying to understand what i really needed and then i asked myself:

Do i need to install Rails?

Following the tutorial on Rails official wiki http://wiki.rubyonrails.org/getting-started/installation/linux i found my way.

Do i need an IDE?

Honestly i’m in love with VI but, maybe, it’s better to download NetBeans Ruby Version (not far from today it was released a very interesting version, actually the 6.5?

Well, How can i set up a brand-new project?

I choose to use the shell, altougth i like netbeans. So i type:
 1 l4r@linux4rails:~$rails MyRails
 2  create  
 3       create  app/controllers
 4       create  app/helpers
 5       create  app/models
 6       create  app/views/layouts
 7       create  config/environments
 8       create  config/initializers
 9       create  config/locales
10       create  db
11       create  doc
12       create  lib
13       create  lib/tasks
14       create  log
15       create  public/images
16       create  public/javascripts
17       create  public/stylesheets
18       create  script/performance
19       create  script/process
20       create  test/fixtures
21       create  test/functional
22       create  test/integration
23       create  test/performance
24       create  test/unit
25       create  vendor
26       create  vendor/plugins
27       create  tmp/sessions
28       create  tmp/sockets
29       create  tmp/cache
30       create  tmp/pids
31       create  Rakefile
32       create  README
33       create  app/controllers/application.rb
34       create  app/helpers/application_helper.rb
35       create  test/test_helper.rb
36       create  test/performance/browsing_test.rb
37       create  config/database.yml
38       create  config/routes.rb
39       create  config/initializers/inflections.rb
40       create  config/initializers/mime_types.rb
41       create  config/initializers/new_rails_defaults.rb
42       create  config/locales/en.yml
43       create  config/boot.rb
44       create  config/environment.rb
45       create  config/environments/production.rb
46       create  config/environments/development.rb
47       create  config/environments/test.rb
48       create  script/about
49       create  script/console
50       create  script/dbconsole
51       create  script/destroy
52       create  script/generate
53       create  script/performance/benchmarker
54       create  script/performance/profiler
55       create  script/performance/request
56       create  script/process/reaper
57       create  script/process/spawner
58       create  script/process/inspector
59       create  script/runner
60       create  script/server
61       create  script/plugin
62       create  public/dispatch.rb
63       create  public/dispatch.cgi
64       create  public/dispatch.fcgi
65       create  public/404.html
66       create  public/422.html
67       create  public/500.html
68       create  public/index.html
69       create  public/favicon.ico
70       create  public/robots.txt
71       create  public/images/rails.png
72       create  public/javascripts/prototype.js
73       create  public/javascripts/effects.js
74       create  public/javascripts/dragdrop.js
75       create  public/javascripts/controls.js
76       create  public/javascripts/application.js
77       create  doc/README_FOR_APP
78       create  log/server.log
79       create  log/production.log
80       create  log/development.log
81       create  log/test.log

WoW… interesting stuff…

How can i launch my brand-new project?
1 l4r@linux4rails:~$cd MyRails
2 l4r@linux4rails:~/MyRails/$ script/server start

At least i open my browser and type http://localhost:3000 then i take a look at the browser… wow. Awesome.

Hello World Linux4Rails.com

Published by: Algweb on Feb 24, 2009 0 Comments

The reason why we have decided to create this site is the idea of sharing our experiences and our experiments.

Googling on the net it’s enough easy to find tutorials, guides, how-to and solutions, so we are going to collect various stuff related to integration between the Linux OS and Ruby on Rails .

Linux For Rails (Linux4Rails) will be a collection-point where we can discuss our problems and our solutions about Rails running on a Linux Server.

We will focus on many Linux distributions and all Rails environments.

We will very happy if you will send us yours stories.

Feel free to get in touch with us at linux4rails[ A-T ]algweb[ D-O-T ]it