debian-mirror-gitlab/doc/administration/operations/puma.md

70 lines
3.6 KiB
Markdown
Raw Normal View History

2021-01-03 14:25:43 +05:30
---
stage: none
group: unassigned
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
2020-03-13 15:44:24 +05:30
# Switching to Puma
2020-11-24 15:15:51 +05:30
As of GitLab 12.9, [Puma](https://github.com/puma/puma) has replaced [Unicorn](https://yhbt.net/unicorn/)
2020-07-28 23:09:34 +05:30
as the default web server. From GitLab 13.0, the following run Puma instead of Unicorn unless
explicitly configured not to:
- All-in-one package-based installations.
- Helm chart-based installations.
2020-03-13 15:44:24 +05:30
## Why switch to Puma?
Puma has a multi-thread architecture which uses less memory than a multi-process
2020-06-23 00:09:42 +05:30
application server like Unicorn. On GitLab.com, we saw a 40% reduction in memory
consumption.
2020-03-13 15:44:24 +05:30
Most Rails applications requests normally include a proportion of I/O wait time.
During I/O wait time MRI Ruby will release the GVL (Global VM Lock) to other threads.
Multi-threaded Puma can therefore still serve more requests than a single process.
2020-05-24 23:13:21 +05:30
## Configuring Puma to replace Unicorn
2020-06-23 00:09:42 +05:30
Beginning with GitLab 13.0, Puma is the default application server. We plan to remove support for
Unicorn in GitLab 14.0.
When switching to Puma, Unicorn server configuration
will _not_ carry over automatically, due to differences between the two application servers. For Omnibus-based
deployments, see [Configuring Puma Settings](https://docs.gitlab.com/omnibus/settings/puma.html#configuring-puma-settings).
For Helm based deployments, see the [Webservice Chart documentation](https://docs.gitlab.com/charts/charts/gitlab/webservice/index.html).
2020-10-24 23:57:45 +05:30
Additionally we strongly recommend that multi-node deployments [configure their load balancers to utilize the readiness check](../load_balancer.md#readiness-check) due to a difference between Unicorn and Puma in how they handle connections during a restart of the service.
2020-05-24 23:13:21 +05:30
2020-03-13 15:44:24 +05:30
## Performance caveat when using Puma with Rugged
For deployments where NFS is used to store Git repository, we allow GitLab to use
2020-07-28 23:09:34 +05:30
[direct Git access](../gitaly/index.md#direct-access-to-git-in-gitlab) to improve performance using
[Rugged](https://github.com/libgit2/rugged).
2020-03-13 15:44:24 +05:30
2020-07-28 23:09:34 +05:30
Rugged usage is automatically enabled if direct Git access
2020-11-24 15:15:51 +05:30
[is available](../gitaly/index.md#how-it-works)
and Puma is running single threaded, unless it is disabled by
2020-07-28 23:09:34 +05:30
[feature flags](../../development/gitaly.md#legacy-rugged-code).
2020-03-13 15:44:24 +05:30
MRI Ruby uses a GVL. This allows MRI Ruby to be multi-threaded, but running at
most on a single core. Since Rugged can use a thread for long periods of
time (due to intensive I/O operations of Git access), this can starve other threads
that might be processing requests. This is not a case for Unicorn or Puma running
in a single thread mode, as concurrently at most one request is being processed.
We are actively working on removing Rugged usage. Even though performance without Rugged
is acceptable today, in some cases it might be still beneficial to run with it.
Given the caveat of running Rugged with multi-threaded Puma, and acceptable
2020-11-24 15:15:51 +05:30
performance of Gitaly, we disable Rugged usage if Puma multi-threaded is
2020-03-13 15:44:24 +05:30
used (when Puma is configured to run with more than one thread).
This default behavior may not be the optimal configuration in some situations. If Rugged
plays an important role in your deployment, we suggest you benchmark to find the
optimal configuration:
- The safest option is to start with single-threaded Puma. When working with
2020-11-24 15:15:51 +05:30
Rugged, single-threaded Puma works the same as Unicorn.
- To force Rugged to be used with multi-threaded Puma, you can use
[feature flags](../../development/gitaly.md#legacy-rugged-code).