When running GitLab, the default installation enables all services by default. This might result in a poor performance, especially when the server has limited resources like RAM or CPU power.
To improve the performance of your installation, you can follow the GitLab documentation which provides some useful settings. A detailed description is available at docs.gitlab.com.
In my case, the web server has “only” 6GB of RAM, which results in temporary timeouts – especially when GitLab Runner executed some jobs.
I started with the changes listed below and already saw a huge reduction of loading time and UI response time on my GitLab installation. The following steps have been copied from docs.gitlab.com as a reminder for future setups.
Disable monitoring
GitLab enables all services by default to provide a complete DevOps solution without any additional configuration. Some of the default services, like monitoring, are not essential for GitLab to function and can be disabled to save memory.
In /etc/gitlab/gitlab.rb
:
prometheus_monitoring['enable'] = false
We observed 200MB of memory usage reduction configuring GitLab this way.
Configure how GitLab handles memory
GitLab consists of many components (written in Ruby and Go), with GitLab Rails being the biggest one and consuming the most of memory.
GitLab Rails uses jemalloc as a memory allocator. jemalloc preallocates memory in bigger chunks that are also being held for longer periods in order to improve performance. At the expense of some performance loss, you can configure GitLab to free memory right after it is no longer needed instead of holding it for a longer periods.
In /etc/gitlab/gitlab.rb
:
gitlab_rails['env'] = { 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000' }
gitaly['env'] = { 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000' }
We observed much more stable memory usage during the execution of the application.
Disable additional in-application monitoring
GitLab uses internal data structures to measure different aspects of itself. These features are no longer needed if monitoring is disabled.
To disable these features you need to go to Admin Area of GitLab and disable the Prometheus Metrics feature:
- On the left sidebar, at the bottom, select Admin Area.
- Select Settings > Metrics and profiling.
- Expand Metrics – Prometheus.
- Disable Enable Prometheus Metrics.
- Select Save changes.
Leave a Reply