Recommendation for number of workers: cores × 2?

So all the claims that the UNICORN WORKER should be 2*vCPU are wrong?
My server is Intel Xeon E5-2686 v4 @ 2.30GHz—24vCPU+32GB Ram
How many UNICORN WORKER do I need to set up?
8? or 48?
My site have more than 7k users and about 1k daily engaged users. users sending 3k-7k posts per day. our community has 120k-200k pageviews/day including crawlers and anonymous users.

That depends on a lot of factors. Like how big your database size is in comparison to your RAM, the ratio of logged-in to anonymous traffic, whether you have plugins that keep your Sidekiq queue busier, if you are running YJIT, etc.

What is simple is looking at the MiniProfiler data during your peak hour and browsing the forum to see if the performance is any worse and identifying the bottleneck.

Since this CPU is an older one, I’d start with more than the usual number of Unicorn workers, as every request will take longer than usual. But if you are running PostgreSQL and Redis on the same server, you can’t starve those off by running too many workers.

Try running 16 workers to start with, and evaluate how the site is performing.

Is there a simple human-friendly description of what Unicorn workers are doing? The impression I get is that every user page request has to go to a Unicorn worker to be dealt with. If you don’t have enough, the user has to wait. If you have too many… well maybe that costs you a little RAM?

They’re the application web servers.

1 Like

It’s not peak now, but I think there’s a problem with the loading time.

Looks like your 10 years old CPU is showing it’s age. Increasing Unicorn workers will allow you to serve more users simultaneously but won’t make an individual request any faster.

Can you try enabling YJIT?

2 Likes

With your hardware I would expect to get a mean logged-in list/latest time of around 150ms app, 80ms SQL.

I’d start with 12 workers and see how it behaves with that. The best thing you can do is track metrics; if you want to know if you should add more workers, check to see if requests are getting queued waiting for app workers.

Are you tracking the metrics that Discourse itself exports via the prometheus exporter? These will give you a good view on how the instance is performing, overall.

What are performance numbers like for anonymous and regular (not admin) users?

3 Likes