Look at this picture showing gitlab ce memory consumption.
I really dont need all of those workers, sidekiq or unicorn or all of those daemon. This is on IDLE. I mean, I installed this to manage 1 project, with like 4 people, I dont need all those daemon. Is there any way to reduce this ?
Memory. You need at least 2GB of addressable memory (RAM + swap) to install and use GitLab! With less memory GitLab will give strange errors during the reconfigure run and 500 errors during usage. 512MB RAM + 1.5GB of swap is the absolute minimum but we strongly advise against this amount of memory.
GitLab supports only PostgreSQL database management system.
You can find the config. toml file in: /etc/gitlab-runner/ on *nix systems when GitLab Runner is executed as root (this is also the path for service configuration)
I also had problems with gitlab's high memory consumption. So I ran the linux tool htop
.
In my case I found out that the postgresl service used most of the memory.
With postgres service running 14.5G of 16G were used
I stopped one gitlab service after the other and found out that when I stop postgres a lot of memory was freed.
You can try it
gitlab-ctl stop postgresql
and start the service again with
gitlab-ctl start postgresql
Finally I came across the following configuration in /etc/gitlab/gitlab.rb
##! **recommend value is 1/4 of total RAM, up to 14GB.**
# postgresql['shared_buffers'] = "256MB"
I just set the shared buffers to 256MB by removing the comment #
, because 256MB is sufficient for me.
postgresql['shared_buffers'] = "256MB"
and executed gitlab-ctl reconfigure
. gitlab-ctl restarts the affected services and the memory consumption is now very moderate.
Hopefully that helps someone else.
From your image it looks like Sidekiq and all its workers are using a total sum of 257mb of memory, which is normal. Remember that all the Sidekiq workers use the same memory pool, so they're using 257mb total, not 257mb each. As you've seen from your own answer, decreasing the number of Sidekiq workers will not drastically decrease the memory usage, but will cause background jobs to take longer because they have to wait around for a Sidekiq process to be available. I would leave this value at the default, but if you really want to decrease it then I wouldn't decrease it below 4 since you have 4 cores.
The Unicorn processes also share a memory pool, but each worker has 1 pool that is shared between its 2 processes. In your original image it looks like you have 5 workers, which is recommended for a 4 core system, and each is using about ~250mb of memory. You shouldn't notice any performance differences if you decreased the number of workers to 3.
Also, you might want to read this doc on how to configure Unicorn. You definitely don't want the number of workers to be less than 2 because it causes issues when editing files from within the GitLab UI, as discussed here, and it also disables cloning over HTTPS according to this quote from the doc I linked:
With one Unicorn worker only git over ssh access will work because the git over HTTP access requires two running workers (one worker to receive the user request and one worker for the authorization check).
Finally, recent versions of GitLab seem to allocate more memory to the postgresql database cache. I'd recommend configuring this property postgresql['shared_buffers']
in /etc/gitlab/gitlab.rb
to be 1/4 of your total free RAM. See René Link's answer below for more information on that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With