I’ve been using Gitlab for 4+ years now, with 100+ repositories. Due to the relatively high number of repositories, the memory usage of the Gitlab server has been increasing over time, reaching a maximum of 8GB of RAM.

I needed to find a way to reduce the memory usage. FAST!

I searched online and found a official Gitlab documentation that explains how to do it. But these changes come with a lot of comprimises, please read the documentation carefully, they may impact performance and stability, specially if you have a lot of traffic on your Gitlab server.

This post is a summary of the steps I took to reduce the memory usage.

Original post:

https://docs.gitlab.com/omnibus/settings/memory_constrained_envs/

  1. Adjust Swap configuration
sudo sysctl vm.swappiness=10
vim /etc/sysctl.conf

# Add/change the following line
vm.swappiness=10
  1. Optimize Puma

Gitlab warns that this configuration is in Alpha state, it may change in the future.

vim /etc/gitlab/gitlab.rb

# Change the following line
puma['worker_processes'] = 0
  1. Optimize Sidekiq

The default value for this configuration is 20, Gitlab says that it can be reduced to 5 or 10.

vim /etc/gitlab/gitlab.rb

# Change the following line
sidekiq['concurrency'] = 10
  1. Disabling Prometheus Monitoring

Prometheus is not necessary for Gitlab to function. Make sure you to disable it if you don’t need it.

vim /etc/gitlab/gitlab.rb

# Change the following line
prometheus_monitoring['enable'] = false

Make sure to restart the Gitlab server after making these changes.

gitlab-ctl reconfigure

I haven’t listed all the configuration changes Gitlab suggests, I’ve only listed the ones it that I applied and worked for me. Please make sure read the docs and test them yourself.

With these changes, I was able to drop the memory usage to about 3.6GB!

If your Gitlab server instance is used only by a handful of users, these configuration changes work great!