Recommendations
Give the external PostgreSQL server at least 12 CPU cores and set max_connections to at least 800 (see PostgreSQL).
Web service autoscaling
In the high availability variant, the HorizontalPodAutoscaler of the web service uses two metrics and follows the one that asks for more pods:
- CPU usage per pod;
puma-queued, the average number of requests waiting in the Puma queue of a pod.
Requests start to queue once every Puma worker of a pod is busy. CPU usage of a pod stops growing at about one core per worker, so CPU alone reacts to an overload late.
puma-queued is a custom metric. Kubernetes does not provide it: the HorizontalPodAutoscaler reads it from the custom metrics API (custom.metrics.k8s.io), which a metrics adapter serves. In Deckhouse Kubernetes Platform the adapter is built in. In other clusters, install prometheus-adapter.
Warning. If the API does not serve puma-queued, the HorizontalPodAutoscaler still adds web service pods under CPU load but never removes them, and the web service stays at maxReplicas after the load drops. If the cluster has no metrics adapter, keep only the Resource item in gitlab.webservice.hpa.customMetrics.
To make the metric available:
Make Prometheus scrape the web service metrics, for example with
gitlab.webservice.metrics.serviceMonitor.enabled: trueor with the objects from Monitoring. The following query must return one series per web service pod:count by (pod) (puma_queued_connections{namespace="<namespace>"})Declare the metric:
in Deckhouse Kubernetes Platform, create a PodMetric object in the release namespace:
apiVersion: deckhouse.io/v1beta1 kind: PodMetric metadata: name: puma-queued namespace: <namespace> spec: query: sum by (<<.GroupBy>>) (avg_over_time(puma_queued_connections{<<.LabelMatchers>>}[1m]))in other clusters, install the
prometheus-community/prometheus-adapterchart pointed at your Prometheus (prometheus.url,prometheus.port) and add a rule to its values:rules: custom: - seriesQuery: 'puma_queued_connections{namespace!="",pod!=""}' resources: overrides: namespace: {resource: namespace} pod: {resource: pod} name: matches: ^puma_queued_connections$ as: puma-queued metricsQuery: sum by (<<.GroupBy>>) (avg_over_time(<<.Series>>{<<.LabelMatchers>>}[1m]))Only one provider can serve
custom.metrics.k8s.ioin a cluster. If another adapter already serves it, declare the metric in that adapter.
Check that the API returns a value for each web service pod:
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/<namespace>/pods/*/puma-queued"
Ingress-nginx
The web service pods get equal shares of requests only when ingress-nginx sends requests straight to the pods. With the annotation nginx.ingress.kubernetes.io/service-upstream: "true" on the web service Ingress, ingress-nginx sends them to the ClusterIP of the Service instead. The cluster then picks a pod once per TCP connection, and ingress-nginx reuses each connection for up to 10000 requests, so the pods added by the HorizontalPodAutoscaler get almost no requests. The high availability values turn the annotation off with gitlab.webservice.ingress.serviceUpstream: false.
If the annotation has to stay on, make ingress-nginx close its connections to the web service sooner. Set the following keys in the ingress-nginx ConfigMap, or in spec.config of the IngressNginxController object in Deckhouse Kubernetes Platform:
upstream-keepalive-requests: "100"
upstream-keepalive-timeout: "10"New pods then start to get requests within seconds, but the requests are spread less evenly than without the annotation.
Values
Save the chosen variant to a file and pass it to the install command as described in Applying the values.
- Standalone
- High availability
global:
codeHelm:
loadbalancer:
resources:
limits:
cpu: 1500m
memory: 1Gi
requests:
cpu: 750m
memory: 512Mi
gitlab:
webservice:
workerProcesses: 10
puma:
threads:
min: 8
max: 8
resources:
limits:
memory: 16G
requests:
cpu: 10
memory: 16G
sidekiq:
resources:
limits:
memory: 3G
requests:
cpu: 1
memory: 1500Mi
gitlab-shell:
resources:
limits:
cpu: 384m
memory: 250Mi
requests:
cpu: 32m
memory: 50Mi
gitlab-pages:
resources:
limits:
memory: 4G
requests:
cpu: 900m
memory: 2G
gitaly:
resources:
limits:
cpu: 6000m
memory: 16000Mi
requests:
cpu: 6000m
memory: 16000Mi
cgroups:
memoryBytes: 16777216000
cpuQuotaUs: 600000
repositories:
memoryBytes: 8388608000
cpuQuotaUs: 300000
praefect:
resources:
limits:
cpu: 1200m
memory: 1200Mi
requests:
cpu: 500mglobal:
codeHelm:
loadbalancer:
replicas: 3
resources:
limits:
cpu: 1500m
memory: 1Gi
requests:
cpu: 750m
memory: 512Mi
hpa:
enabled: true
minReplicas: 3
maxReplicas: 4
cpuUtilization: 80
memoryUtilization: 80
pdb:
enabled: true
praefect:
virtualStorages:
- name: default
gitalyReplicas: 3
maxUnavailable: 1
gitlab:
webservice:
workerProcesses: 8
puma:
threads:
min: 8
max: 8
resources:
limits:
memory: 13G
requests:
cpu: 8
memory: 13G
ingress:
serviceUpstream: false
hpa:
enabled: true
customMetrics:
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageValue: 6000m
- type: Pods
pods:
metric:
name: puma-queued
target:
type: AverageValue
averageValue: "1"
minReplicas: 2
maxReplicas: 5
maxUnavailable: 1
deployment:
readinessProbe:
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
workhorse:
resources:
limits:
memory: 2Gi
requests:
cpu: 500m
memory: 500M
sidekiq:
resources:
limits:
memory: 3G
requests:
cpu: 1
memory: 1500Mi
hpa:
enabled: true
cpu:
targetAverageValue: 700m
minReplicas: 6
maxReplicas: 12
maxUnavailable: 1
gitlab-shell:
resources:
limits:
cpu: 384m
memory: 250Mi
requests:
cpu: 32m
memory: 50Mi
hpa:
enabled: true
cpu:
targetAverageValue: 100m
minReplicas: 6
maxReplicas: 12
maxUnavailable: 2
gitlab-pages:
resources:
limits:
memory: 4G
requests:
cpu: 900m
memory: 2G
hpa:
enabled: true
minReplicas: 2
maxReplicas: 6
cpu:
targetAverageValue: 100m
maxUnavailable: 1
gitaly:
resources:
limits:
cpu: 6000m
memory: 16000Mi
requests:
cpu: 6000m
memory: 16000Mi
cgroups:
memoryBytes: 16777216000
cpuQuotaUs: 600000
repositories:
memoryBytes: 8388608000
cpuQuotaUs: 300000
praefect:
replicas: 3
resources:
limits:
cpu: 1200m
memory: 1200Mi
requests:
cpu: 500m
registry:
hpa:
enabled: true
minReplicas: 4
maxReplicas: 8
cpu:
targetAverageUtilization: 75
maxUnavailable: 4Load test
The high availability variant of this size was tested under a synthetic load for 30 minutes on Deckhouse Code installed as the Deckhouse Platform module. The load followed the request mix of the GitLab reference architecture for up to 5000 users: REST API calls, web interface pages, and Git clone, pull and push over HTTPS and SSH. Git clones were shallow, with a depth of 3 commits.
Throughput:
| Traffic | Target, RPS | Measured, RPS |
|---|---|---|
| REST API | 100 | 112.5 |
| Web interface | 10 | 12.5 |
| Git clone and pull over HTTPS and SSH | 10 | 7.3 |
| Git push over HTTPS and SSH | 2 | 1.6 |
Response times and failed requests; a range runs from the fastest to the slowest request of the group:
| Requests | Median | 95th percentile | Failed |
|---|---|---|---|
| REST API | 0.21–0.98 s | 0.54–3.0 s | 0.01% |
| Web interface pages | 0.41–4.1 s | 0.9–5.5 s | 0% |
| Git clone over HTTPS | 20 s | 145 s | 0% |
| Git pull over HTTPS | 2.3 s | 14 s | 0.02% |
| Git push over HTTPS | 4.3 s | 11 s | 0% |