ma11hew28
ma11hew28

Reputation: 126327

Heroku Postgres Ruby Puma Workers & Threads

For a pure Rack app running on a Heroku hobby dyno with a Heroku Postgres hobby dev add-on, how do you know how many workers & threads to configure Puma to have?

Upvotes: 0

Views: 350

Answers (2)

gwcodes
gwcodes

Reputation: 5690

It depends greatly on how memory-hungry your application is. Given that it's a pure Rack app and most of the literature out there are for Rails apps - I'd imagine that your optimal values are higher.

The Librato add-on is really helpful here in letting you see your memory usage in near real-time, so you can quickly tweak and monitor how close you are to the 512MB limit. There's a free tier there, and it doesn't need any additional instrumentation either (I'm not affiliated with them in any way, but we do use their service!)

Upvotes: 1

Bobby Matson
Bobby Matson

Reputation: 1488

Based on this article it seems like you'd be safe running 2-4 processes within a single Heroku web dyno depending on your memory usage. For threads, I'd stick to the default (5) depending on the needs of your app.

I'd recommend tuning your app to use a particular config then keeping an eye on the Heroku logs for a few days to see if you get too many R14 errors. At that point, you know you've exhausted the dyno and should scale it back.

Upvotes: 1

Related Questions