WebFaction
Community site: login faq

My account is limited to 300 process. As I turn on my rail app it ate up 100ps. Does anyone know how to reduce "Passenger Core" and PassengerAgent count?

This is my nginx config:

env GEM_HOME=/home/user/gems;
worker_processes  1;

events {
    worker_connections  256;        # default 1024
}

http {
    access_log  /home/user/logs/user/access_myapp.log  combined;
    error_log   /home/user/logs/user/error_myapp.log   crit;

    include         mime.types;
    passenger_root  /home/user/gems/gems/passenger-5.0.30;
    passenger_ruby  /home/user/bin/ruby;
    sendfile        on;

    passenger_max_instances_per_app  1;
    rails_spawn_method               conservative;
    passenger_max_pool_size 1;      # default 2

    server {
        listen             xxx;
        passenger_enabled  on;
        root               /home/user/myapp/public;
        server_name        localhost;
        rails_env          production;

        location ~* ^/assets/ {
            gzip_static on;
            expires max;
            add_header Cache-Control public;

            add_header Last-Modified "";
            add_header ETag "";
            break;
        }

    }
}

This is output of the ps list: http://pastebin.com/0DcrmxC4

Thanks

asked 23 Feb, 20:36

bliz20's gravatar image

bliz20
113
accept rate: 0%

edited 23 Feb, 20:40


Unfortunately, this is the default behavior for Passenger. It spawns a certain number of threads per CPU core on the server, and your server has 40 CPU cores, so it means a lot of threads are spawned.

The thread count can't be adjusted on the free version of Passenger that our installer uses, so if the high number of threads is causing you to bump up against the thread limit, then you can try deploying with a custom server stack, perhaps with Puma.

You can install Puma with the following commands:

cd ~/webapps/your_app
export GEM_HOME=$PWD/gems
export PATH=$PWD/bin:$PATH
gem install puma
gem install therubyracer

Next, edit your project's Gemfile to enable the therubyracer gem, eg:

gem 'therubyracer', platforms: :ruby

Then, stop your Nginx server:

~/webapps/your_app/bin/stop

Then, start Puma on your app's assigned port (eg 12345):

puma -d --port=12345 --dir=~/webapps/your_app/your_project

In my testing, the Puma process used only 18 threads.

I hope this helps! Please let us know if you need anything else.

permanent link

answered 24 Feb, 23:22

seanf's gravatar image

seanf ♦♦
11.7k21333
accept rate: 37%

edited 24 Feb, 23:25

Thanks, let me give this a try.

(27 Feb, 15:48) bliz20 bliz20's gravatar image

The configuration options are outlined here. Some debugging will have to show what those processes are, but it is possible they are open files.

permanent link

answered 23 Feb, 22:23

johns's gravatar image

johns ♦♦
4.8k29
accept rate: 22%

I captured the process list after restart and once more after a few hours the result look similar.

(24 Feb, 13:49) bliz20 bliz20's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×183
×105
×25

question asked: 23 Feb, 20:36

question was seen: 610 times

last updated: 27 Feb, 15:48

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM