Phusion Passenger Memory Stats

What is Phusion Passenger?

Phusion Passenger is the software we use to connect our Apache webserver to our Ruby On Rails applications; it is similar to mod_perl.


What is Passenger Memory Stats?

The passenger-memory-stats command prints diagnositic messages about a Phusion Passenger setup.

The command tells us how many Passenger processes are running, how much RAM each uses, and more.


  # passenger-memory-stats
  ------------- Apache processes --------------.
  PID    PPID  Threads  VMSize   Private  Name
  5947   1     9        90.6 MB  0.5 MB   /usr/sbin/apache2 -k start
  5948   5947  1        18.9 MB  0.7 MB   /usr/sbin/fcgi-pm -k start
  6029   5947  1        42.7 MB  0.5 MB   /usr/sbin/apache2 -k start
  6030   5947  1        42.7 MB  0.5 MB   /usr/sbin/apache2 -k start
  ### Processes: 4
  ### Total private dirty RSS: 2.20 MB

  --------- Passenger processes ---------.
  PID    Threads  VMSize   Private  Name
  6026   1        10.9 MB  4.7 MB   Passenger spawn server
  23481  1        26.7 MB  3.0 MB   Passenger FrameworkSpawner: 2.0.2
  23791  1        26.8 MB  2.9 MB   Passenger ApplicationSpawner: /var/www/projects/app1-foobar
  23793  1        26.9 MB  17.1 MB  Rails: /var/www/projects/app1-foobar
  ### Processes: 4
  ### Total private dirty RSS: 27.76 M

How to parse Passenger Memory Stats?

We parse the passenger-memory-stats command using shell scripts.

To run the command:


Delete color

To delete any problematic color characters:

  passenger-memory-stats \
  | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g"

Apache processes

To print just the section of Apache processes:

  passenger-memory-stats \
  | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" \
  | sed -n '/^-* Apache processes -*$/,/^$/p'

Total private dirty

To print the Apache total private dirty line:

  passenger-memory-stats \
  | sed -n '/^-* Apache processes -*$/,/^$/p'
  | grep "Total private dirty" 

VMSize max

To print the apache2 VMSize maximum:

  passenger-memory-stats \
  | grep "/apache2 " \
  | awk '$3 > max { max=$3 } END { print max }'

VMSize sum

To print the apache2 VMSize sum:

  passenger-memory-stats \
  | grep "/apache2 " \
  | awk '{ sum += $3 }; END { print sum }'

Related scripts

We have similar scripts for the Passenger processes section.

Your own systems may need some different parsing, depending on which webservers you have, which version of Phusion Passenger you have, and how your system runs processes.

For example, if you have Nginx then passenger-memory-stats will also have an Nginx processes section, and you can parse it by creating similar parsing scripts.


To download our Passenger Memory Stats scripts:

You may need to customize these scripts for your own systems, depending on which version of Phusion Passenger you're using, and how your system runs Apache and Passenger.

If you know GitHub and Git, feel free to fork and clone as you like. If you want to improve these scripts, or add to them, feel free to send us a pull request.

What's Next?

blog comments powered by Disqus