How to change the number of unicorns?

Hello,

I would like to know how to set the number of running unicorns. I need it to adjust the RAM consumption and failed to find any specific information about it on this forum and on the net.

I am looking for information such as the location of the correct file, the name of the line to change, if there is some precaution to take, etc.

I suppose that after the changes, it is necessary to restart/rebuild the software. How to do it properly?

Thank you for your time.

2 Likes

To edit these settings you can edit the app.yml

cd /var/discourse
nano containers/app.yml

Around the line 48 you should have this:

## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 8

I’m not an expert in this area but you might want to check the lines ~30 to reduce the number:

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "2048MB"

Save the file (CTRL+X then Y usually), then you indeed have to rebuild discourse to use the new settings, using:

./launcher rebuild app

Your forum will be offline around 10 minutes during the process

5 Likes

I think, but I haven’t tested, that the UNICORN_WORKERS is set in an env and not in any config file, so you don’t need to rebuild but can just

 ./launcher destroy app;./launcher start app

I’m pretty sure (but haven’t looked) that changes to db_shared_buffers to require a rebuild (or you could go an edit the corresponding settings file inside the container and then restart it).

3 Likes

My discourse install has been done via Yunohost and it seems that some things are different. I didn’t manage to find the app.yml file.

I am waiting for an answer from the Yunohost team. I’ll keep you in touch.

1 Like