git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/gitlab: Add options to control puma worker and threads numbers
commit6230936be276cd02e1e21e22ad0845582d098399 authortalyz <kim.lindberger@gmail.com> dateThu 1 Apr 2021, 19:47 (6 years ago) parent9af991a
1 file changed+63−1
nixos/modules/services/misc/gitlab.nix+63−1
nixos/modules/services/misc/gitlab.nix+63−1
@@ -652,6 +652,62 @@ in {
652652 description = "Extra configuration to merge into shell-config.yml";
653653 };
654654
655+ puma.workers = mkOption {
656+ type = types.int;
657+ default = 2;
658+ apply = x: builtins.toString x;
659+ description = ''
660+ The number of worker processes Puma should spawn. This
661+ controls the amount of parallel Ruby code can be
662+ executed. GitLab recommends <quote>Number of CPU cores -
663+ 1</quote>, but at least two.
664+
665+ <note>
666+ <para>
667+ Each worker consumes quite a bit of memory, so
668+ be careful when increasing this.
669+ </para>
670+ </note>
671+ '';
672+ };
673+
674+ puma.threadsMin = mkOption {
675+ type = types.int;
676+ default = 0;
677+ apply = x: builtins.toString x;
678+ description = ''
679+ The minimum number of threads Puma should use per
680+ worker.
681+
682+ <note>
683+ <para>
684+ Each thread consumes memory and contributes to Global VM
685+ Lock contention, so be careful when increasing this.
686+ </para>
687+ </note>
688+ '';
689+ };
690+
691+ puma.threadsMax = mkOption {
692+ type = types.int;
693+ default = 4;
694+ apply = x: builtins.toString x;
695+ description = ''
696+ The maximum number of threads Puma should use per
697+ worker. This limits how many threads Puma will automatically
698+ spawn in response to requests. In contrast to workers,
699+ threads will never be able to run Ruby code in parallel, but
700+ give higher IO parallelism.
701+
702+ <note>
703+ <para>
704+ Each thread consumes memory and contributes to Global VM
705+ Lock contention, so be careful when increasing this.
706+ </para>
707+ </note>
708+ '';
709+ };
710+
655711 extraConfig = mkOption {
656712 type = types.attrs;
657713 default = {};
@@ -1145,7 +1201,13 @@ in {
11451201 TimeoutSec = "infinity";
11461202 Restart = "on-failure";
11471203 WorkingDirectory = "${cfg.packages.gitlab}/share/gitlab";
1148− ExecStart = "${cfg.packages.gitlab.rubyEnv}/bin/puma -C ${cfg.statePath}/config/puma.rb -e production";
1204+ ExecStart = concatStringsSep " " [
1205+ "${cfg.packages.gitlab.rubyEnv}/bin/puma"
1206+ "-e production"
1207+ "-C ${cfg.statePath}/config/puma.rb"
1208+ "-w ${cfg.puma.workers}"
1209+ "-t ${cfg.puma.threadsMin}:${cfg.puma.threadsMax}"
1210+ ];
11491211 };
11501212
11511213 };