0
votes

I've deployed a rails app 3.2.22.2 running on ruby 2.2.0p0 on heroku with puma as web server.

Heroku loves puma and advice new apps to use it:

https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server

Puma uses threads, in addition to worker processes, to make more use of available CPU. You can only utilize threads in Puma if your entire code-base is thread safe. Otherwise, you can still use Puma, but must only scale out through worker processes.

I can't ensure my rails app (my code in fact) and the gems are threadsafe, so my only option is to add some workers and configure my Procfile like this:

web: bundle exec puma -t 1:1 -p ${PORT:-3000} -e ${RACK_ENV:-development}
worker: bundle exec rake jobs:work

Just in case, I've also set the config vars as:

=== myapp-staging Config Vars
DATABASE_URL:          postgres://this:that@addresse:port/more
LANG:                  en_US.UTF-8
MIN_THREADS:           1
NEW_RELIC_LICENSE_KEY: key
NEW_RELIC_LOG:         stdout
PAPERTRAIL_API_TOKEN:  key
RACK_ENV:              staging
RAILS_ENV:             staging
RAILS_MAX_THREADS:     1
SENSIBLE_DEFAULTS:     enabled
WEBSOLR_URL:           https://index.websolr.com/solr/index
WEB_CONCURRENCY:       1

So... if I can only use only 1 thread, is puma the right solution for my app?

Thank you!

ps: please have a look at that question What configuration for Rails 3.2.22.2 + Puma + Heroku?

1

1 Answers

0
votes

There's no point using puma on a rails app not threadsafe (version < 4.x), but to handle the slow clients problem.

Besides that, the only choice is to set the web concurrency to 1.