Spinning up a stock GitLab Omnibus installation on a 2 GB or 4 GB virtual server ends the exact same way every time: within minutes of the first git push or merge-request diff render, kernel swap pins to 100%, SSH sessions freeze, and the Linux OOM-killer reaps Ruby puma or Go gitaly workers mid-transaction. Self-hosted GitLab Community Edition (CE) is not a single binary—it is an entire distributed platform packaged inside one /opt/gitlab tree, bundling Puma, Sidekiq, Gitaly, Workhorse, PostgreSQL, Redis, Nginx, and a full Prometheus observability stack that easily consumes 6.5 to 8.5 GB of resident RAM completely idle unless tuned explicitly.
Running self-managed GitLab reliably in production without paying inflated per-seat SaaS fees comes down to four architectural decisions: tuning /etc/gitlab/gitlab.rb process concurrency and jemalloc memory decay, isolating gitlab-runner CI executors onto a separate worker VM, offloading LFS/artifacts/backups to encrypted cloud object storage, and choosing 8 GB RAM (Linux Standard at $18/mo) as your absolute production floor—or selecting lightweight Go-based Forgejo/Gitea ($6–$8/mo) when you only need fast Git and pull requests.
Before editing configuration files, inspect what gitlab-ctl status actually launches inside a default Omnibus package:
puma cluster): Pre-forks multiple Ruby on Rails worker processes (400–950 MB RSS each as copy-on-write pages dirty over time) to serve web UI and REST/GraphQL requests.sidekiq): Background multi-threaded Ruby process executing webhook deliveries, merge-ability checks, pipeline creation, and email notifications (900 MB–1.6 GB RSS).gitaly + git subprocesses): RPC layer managing bare Git repositories on disk. Large git clone or git-pack-objects operations spawn transient multi-hundred-megabyte child processes.shared_buffers defaulting to 25% of RAM if uncapped) plus separate cache/queue state.prometheus, alertmanager, postgres_exporter, redis_exporter, node_exporter, gitlab-exporter): Enabled by default to scrape local metrics every 15 seconds, quietly consuming 650 MB–1.1 GB of RAM and constant disk write IOPS even if nobody ever opens a Prometheus graph!/etc/gitlab/gitlab.rb Tuning for 8–16 GB ServersApplying GitLab's memory-constrained environment settings alongside jemalloc dirty-page reclamation cuts idle Omnibus footprint from ~7.2 GB down to ~3.4–4.1 GB, leaving generous headroom for concurrent git-pack-objects bursts and Linux filesystem page cache on an 8 GB or 16 GB server:
# /etc/gitlab/gitlab.rb — Production-tuned GitLab CE for 8 GB (Linux Standard) to 16 GB (Linux Pro)
external_url 'https://git.example.com'
# 1. Automated Let's Encrypt TLS 1.3 + HTTP->HTTPS redirect
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['ops@example.com']
nginx['redirect_http_to_https'] = true
nginx['hsts_max_age'] = 63072000
# 2. Bound Puma workers & threads; recycle workers before Ruby heap fragmentation grows
puma['worker_processes'] = 2
puma['min_threads'] = 2
puma['max_threads'] = 4
puma['per_worker_max_memory_mb'] = 1024
# 3. Bound Sidekiq background concurrency (10 threads handles ~25-80 active developers smoothly)
sidekiq['concurrency'] = 10
# 4. Return freed Ruby/Gitaly native pages to Linux kernel within 1000ms via jemalloc
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',
'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '4'
}
# 5. Cap bundled PostgreSQL shared_buffers explicitly
postgresql['shared_buffers'] = "1024MB"
postgresql['max_connections'] = 200
# 6. Disable bundled Prometheus TSDB if scraping metrics externally (saves ~800 MB RAM)
prometheus_monitoring['enable'] = false
# 7. Consolidate LFS, CI artifacts, uploads, and packages onto off-host Cloud Storage
gitlab_rails['object_store']['enabled'] = true
gitlab_rails['object_store']['proxy_download'] = true
gitlab_rails['object_store']['connection'] = {
'provider' => 'AzureRM',
'azure_storage_account_name' => 'sauprodgitblobs',
'azure_storage_access_key' => File.read('/etc/gitlab/secrets/azure_storage_key').strip
}
gitlab_rails['object_store']['objects']['artifacts']['bucket'] = 'gitlab-artifacts'
gitlab_rails['object_store']['objects']['lfs']['bucket'] = 'gitlab-lfs'
gitlab_rails['object_store']['objects']['uploads']['bucket'] = 'gitlab-uploads'
gitlab_rails['object_store']['objects']['packages']['bucket'] = 'gitlab-packages'
# 8. Stream gitlab-backup archives directly to Managed Cloud Storage (/cloud-storage)
gitlab_rails['backup_upload_connection'] = {
'provider' => 'AzureRM',
'azure_storage_account_name' => 'sauprodgitblobs',
'azure_storage_access_key' => File.read('/etc/gitlab/secrets/azure_storage_key').strip
}
gitlab_rails['backup_upload_remote_directory'] = 'gitlab-dr-vault'
gitlab_rails['backup_keep_time'] = 604800
After editing /etc/gitlab/gitlab.rb, converge Omnibus cleanly with sudo gitlab-ctl reconfigure and verify resident memory per child service via systemd-cgtop or ps -eo rss,comm --sort=-rss | head -n 15.
gitlab-runner onto a Dedicated Worker VMThe fastest way to crash a healthy GitLab server is installing gitlab-runner on the exact same VM that hosts Gitaly and PostgreSQL. A single merge request triggering parallel npm ci && next build, Rust cargo test, or multi-stage container builds spikes CPU to 100% and consumes 3–6 GB of transient compiler RAM, starving Git SSH clones and web UI requests immediately.
Always deploy gitlab-runner on a separate, disposable $6/mo (Linux Starter) or $10/mo (Linux Basic) worker VM! Equally important for security: never set privileged = true (Docker-in-Docker) on runners building untrusted branches or developer forks, because a privileged container can mount the runner host's root filesystem and steal runner registration tokens. Build OCI images safely without root privileges using BuildKit rootless or Kaniko, and enforce explicit memory and PID limits on every CI job container in /etc/gitlab-runner/config.toml:
# /etc/gitlab-runner/config.toml — Dedicated CI Runner VM (isolated from GitLab server!)
concurrent = 3
check_interval = 3
[[runners]]
name = "sau-isolated-docker-runner-01"
url = "https://git.example.com"
token = "glrt-REDACTED_RUNNER_AUTHENTICATION_TOKEN"
executor = "docker"
output_limit = 8192
[runners.docker]
image = "debian:bookworm-slim"
# NEVER set privileged = true on shared runners; use rootless BuildKit/Kaniko for image builds
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
# Bound every CI job container so runaway test suites never kill the runner host
memory = "2048m"
memory_swap = "2048m"
cpus = "2.0"
pids_limit = 512
pull_policy = ["if-not-present"]
volumes = ["/cache"]
shm_size = 268435456
Configure automated weekly runner cache/image pruning (docker system prune -af --filter "until=168h") via a systemd timer on the runner VM so stale CI build layers never fill /var/lib/docker.
gitlab-secrets.json!)Running gitlab-backup create archives PostgreSQL tables and bare Git repositories—but it deliberately excludes /etc/gitlab/gitlab.rb and /etc/gitlab/gitlab-secrets.json. That omission catches countless teams during disaster recovery drills: gitlab-secrets.json holds the symmetric db_key_base and otp_key_base encryption keys used to encrypt CI/CD secret variables, runner tokens, and user 2FA TOTP seeds inside PostgreSQL. Restoring a database tar archive without the matching gitlab-secrets.json renders every CI pipeline variable permanently unreadable!
Automate nightly repository/DB dumps alongside an age- or openssl-encrypted archive of /etc/gitlab, streaming both off-host to Managed Cloud Storage hosted via Microsoft Azure (5 GiB free developer sandbox, 250 GiB at $9/mo up to 25 TiB at $399/mo with AES-256-GCM + Azure storage encryption):
#!/usr/bin/env bash
# /etc/cron.daily/gitlab-offsite-backup — DB + Gitaly backup + encrypted gitlab-secrets.json
set -euo pipefail
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
SECRETS_ENC="/tmp/gitlab-etc-${STAMP}.tar.zst.enc"
trap 'rm -f "$SECRETS_ENC"' EXIT
# 1. Create consistent GitLab application backup (skips artifacts/LFS already in object storage)
/usr/bin/gitlab-backup create SKIP=artifacts,lfs,packages,uploads CRON=1
# 2. Encrypt /etc/gitlab (including gitlab-secrets.json & gitlab.rb!) with AES-256-CBC + PBKDF2
tar -C /etc -cf - gitlab \
| zstd -T0 -9 \
| openssl enc -aes-256-cbc -pbkdf2 -iter 250000 \
-pass file:/root/.backup_passphrase -out "$SECRETS_ENC"
# 3. Upload both application tar and encrypted secrets archive to off-host Cloud Storage
LATEST_TAR="$(ls -1t /var/opt/gitlab/backups/*_gitlab_backup.tar | head -n 1)"
az storage blob upload \
--connection-string "${AZURE_MANAGED_STORAGE_CONN}" \
--container-name "gitlab-dr-vault" \
--name "backups/$(basename "$LATEST_TAR")" \
--file "$LATEST_TAR" --overwrite false
az storage blob upload \
--connection-string "${AZURE_MANAGED_STORAGE_CONN}" \
--container-name "gitlab-dr-vault" \
--name "config/gitlab-etc-${STAMP}.tar.zst.enc" \
--file "$SECRETS_ENC" --overwrite false
Also schedule a pre-upgrade gitlab-ctl pg-upgrade check and verify GitLab's required upgrade path stops before jumping major versions:
# Audit current GitLab version, active background migrations, and config validity before apt upgrade
sudo gitlab-rake gitlab:env:info
sudo gitlab-rake gitlab:background_migrations:status | grep -v 'finished' || true
sudo gitlab-ctl check-config
Before provisioning an 8 GB or 16 GB GitLab Omnibus server, ask an honest architectural question: does your team actually use GitLab's integrated Epics, SAST/DAST security dashboards, package registries, and Kubernetes agents—or do you just want fast self-hosted Git, pull requests, and GitHub Actions-compatible workflows?
~140–220 MB of RAM—over $30\times$ lighter than GitLab Omnibus—running effortlessly on a $6/mo Linux Starter VPS (available as a free 1-click installer in the server Apps tab) or as a standalone $8/mo Instant App at /self-hosted.Linux Standard ($18/mo, 4 vCPU / 8 GB RAM) as the minimum serious floor for small teams, or Linux Pro ($28/mo, 8 vCPU / 16 GB RAM) for active engineering orgs:| Self-Hosted Git Architecture | Servers Are Up Tier | Allocation | Monthly Price | Recommended Team & Workload Profile |
|---|---|---|---|---|
| Forgejo / Gitea (Lean Go Git) | Linux Starter (free 1-click app) or Instant App | 2 vCPU, 2 GB RAM, 50 GB persistent storage | $6/mo ($8/mo Instant App) |
Solo devs & 2–25 engineer teams wanting fast Git, PRs, and <250 MB RAM footprint |
| GitLab CE — Small Team Floor | Linux Standard (or GitLab Instant App at $24/mo) |
4 vCPU, 8 GB RAM, 160 GB persistent storage | $18/mo ($24/mo Instant App) |
1–15 active users with tuned /etc/gitlab/gitlab.rb (prometheus off, 2 Puma workers) |
| GitLab CE — Active Engineering Org | Linux Pro | 8 vCPU, 16 GB RAM, 320 GB persistent storage | $28/mo |
15–100 active engineers, full merge-request diff caching, and bundled observability |
Dedicated Isolated gitlab-runner VM |
Linux Starter or Linux Basic | 2 vCPU, 2–4 GB RAM, 50–80 GB persistent storage | $6 – $10/mo |
Separate CI/CD Docker build executor isolated from GitLab DB & Gitaly |
| Complete Dev Platform Pool | VDC Team Workspace | Pooled 24 vCPU, 64 GB RAM, 1 TB persistent storage (up to 40 VMs) | $95/mo |
GitLab Pro server + 3 isolated CI runner VMs + staging environments in one pool |
Pair your GitLab instance with private access controls using our WireGuard private infrastructure guide or cloud developer workspaces in our cloud development environment guide.
Do not run GitLab CE in production on 4 GB of physical RAM. Ruby's garbage collector periodically traverses object graphs across Puma and Sidekiq heaps; once parts of those heaps page out to disk swap, every garbage-collection sweep stalls on random disk reads, causing 502 Whoops, GitLab is taking too much time to respond errors. Start GitLab on at least 8 GB RAM (Linux Standard at $18/mo)—or pick Forgejo/Gitea on $6/mo if budget is tight.
Yes. GitLab CE is MIT-licensed open-source software with zero user-seat caps, unlimited private repositories, and full CI/CD pipeline execution on your own runners. You can also install the GitLab Enterprise Edition (gitlab-ee) package without a license key—it runs the exact same free tier features while allowing future in-place license activation without reinstalling.
gitlab-backup create backs up PostgreSQL and Git repositories, not /etc/gitlab/gitlab-secrets.json. Without the original db_key_base from gitlab-secrets.json, Rails cannot decrypt encrypted columns in PostgreSQL (CI variables, runner tokens, deploy keys, 2FA secrets). Always archive and encrypt /etc/gitlab/gitlab-secrets.json alongside every daily backup.
For internal engineering teams that do not host public open-source mirrors or receive external unauthenticated webhooks, binding GitLab strictly behind a WireGuard VPN (and relaying GitHub/Stripe webhooks through a minimal edge proxy if needed) eliminates unauthenticated exploit scanning entirely. If exposed publicly ($5/mo public IPv4), disable public sign-ups immediately, enforce 2FA/WebAuthn for all accounts, and disable Git-over-HTTPS password authentication in favor of Ed25519 SSH keys and scoped access tokens.
Explore With AI & Cite This Page
Open a grounded prompt in your AI assistant or copy a clean Markdown, HTML, or APA reference link.
Validate protocols and subnets directly in your browser or continue reading related architecture notes.
Free IP Subnet Calculator & CIDR Cheat Sheet
Unix Timestamp Converter & Ms to Minutes
SSH Keygen Generator & Cloud-Init YAML Builder
High-Concurrency CMS Hosting: PHP-FPM Memory Math, Nginx Microcaching, Headless Node, and Object Offload
Scale Ghost, WordPress, Strapi, Directus, and Payload CMS: PHP-FPM worker sizing, Nginx stale-while-revalidate microcaching, Redis, and Azure media offload.
Docker Container Hosting in Production: Daemon Hardening, UFW Port Traps, Compose Limits, and Security
Run Docker containers safely in production: compose.yaml cgroup limits, daemon.json live-restore, fixing the UFW 0.0.0.0 port-binding bypass, and non-root builds.
Docker Hosting Providers Compared (2026): Dedicated KVM Container Hosts vs. Multi-Tenant PaaS and Linux VPS
An engineering comparison of Docker hosting architectures in 2026: per-customer KVM Managed Docker ($6/$10/$18), Custom GitHub Apps ($10), Single App Containers ($8-$46), Linux VPS ($6+), and metered PaaS.
Coolify v4 Architecture & Production Review (2026): Traefik Routing, Build-Server OOM Traps, and VPS Sizing
An engineering review of Coolify v4+ in production: dynamic Traefik/Caddy container labels, why Next.js Nixpacks builds OOM-kill Postgres on 2 GB nodes, and Coolify vs Managed Docker ($6-$18/mo).