Puma not outperforming Unicorn (Rails 5.0 app) - is this normal?

445 Views Asked by At

Trying to make better uses of an AWS server that serves roughly 30,000 users/day. Current server:

  • AWS EC2, t3.xlarge, 4 vCPUs, 16GB memory
  • Rails 5.0 app, Ruby 2.6.7, web server is nginx

I was previously using Unicorn with the following config:

- 1 master process, 4 worker processes

I had database pool set to 5, and the app also uses Sidekiq with a concurrency of 5.

CPU usage would hover around 35-40%, and memory usage would be in the 90% range. I know Ruby processes are memory hogs, but even still memory usage seemed a little high.

I did all this reading about Puma being much more memory efficient than Unicorn, thus having become the default server for Rails apps. So I did the slightly painful conversion process, and a couple days later the system has stabilized. Puma config I settled on:

- Puma 5.3.2 in cluster mode, 3 workers, threads 1 min & 5 max.

My app's response times seem largely the same as before. But here's the thing, memory usage is the same if not higher than Unicorn, hovering around 90% (and climbing slowly which seems like a memory leak, but that's a different story):

Here's 12 hr CPU and memory usage from New Relic

From top

From top

I'm likely going to roll back and return to Unicorn, but I wanted to post here to see if anyone can see any possible red flags about my configuration. Happy to share more details.

Things I've tried:

  • Number of Puma workers & threads, I tried with the 2 workers and 5 threads default config
  • Installing Ruby 2.6.7 with jemalloc (didn't really do anything)
0

There are 0 best solutions below