LoginSignup
3
1

More than 1 year has passed since last update.

GitLabのPumaのメモリーリークをPuma Worker Killerで対応した話

Last updated at Posted at 2021-07-13

毎度、ググっても出てこない小ネタを取り扱っております。
本記事は個人的な見解であり、筆者の所属するいかなる団体にも関係ございません。

0. はじめに

弊社では、GitLabをオンプレで動かしています。
そのGitLabもUnicronからPumaに切り替わりまして、もう1年になります。
参考記事:GitLab 12.9のUnicornをPumaに変更する - Qiita
Pumaはスピードも早く、快適なレスポンスを実現してくれています。

しかし、Pumaはメモリーの利用量がなかなかに激しいです。
以下はとある日のhtopのスクリーンショットです。
image.png

見ていただければ分かるとおりSWAPファイルを2.1GB使っています。
VMwareで仮想化されており、SWAPファイルもストレージが早いことから遅くなって困るということはありませんが、サーバー管理者としてはあまり気持ちのよいものではありません。

そこで、Puma Worker Killerを導入した話になります。

GitLabの情報は以下にあります。

Configure the bundled Puma instance of the GitLab package | GitLab
https://docs.gitlab.com/ee/administration/operations/puma.html#change-the-memory-limit-setting

1. 前提

GitLabのバージョン: 14.0.5-ee(Community Editionでもおそらく同じ)
OS: Ubuntu 20.04 LTS
Memory: 8GB
インストール方式: omnibus-gitlab

■使用上の注意点

以下のGitHubの注意事項にあるように副作用が発生します。
その辺りを理解してご利用時ください。

schneems/puma_worker_killer: Automatically restart Puma cluster workers based on max RAM available
https://github.com/schneems/puma_worker_killer

2. 設定方法

2-1. gitlab.rbファイルに追記

/etc/gitlab/gitlab.rb
puma['per_worker_max_memory_mb'] = 1024

2-2. reconfigure

$ sudo gitlab-ctl reconfigure

reconfigureしたら、自動的にpumaが再起動されます。
ご注意ください。

3. 結果

SWAPファイルの使用はなくなりました。

image.png

今のところ深刻な問題は報告されていないようです。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1