Puma
Puma is the web server used for GitLab. It is responsible for handling incoming web requests.
Configuration:
- Puma config file:
config/puma.rb
- Environment variables:
RAILS_ENV
,RACK_ENV
,PUMA_ENV
- Command line arguments:
pumactl
Options:
workers
: The number of worker processes to start. This value should be set to the number of CPU cores available.threads
: The number of threads per worker process. This value should be set to the number of CPU cores available.bind
: The address and port to bind the server to. This can be a string, an array, or a hash.preload_app!
: Whether to preload the application before starting the server. This can improve performance by reducing the time it takes to serve the first request.
Example Configuration:
# config/puma.rb
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
# Specifies the `pidfile` location
pidfile ENV['PIDFILE'] || 'tmp/pids/puma.pid'
# Specifies the `log` location
stdout_redirect "#{Rails.root}/log/puma.stdout.log", "#{Rails.root}/log/puma.stderr.log", true
# Set the number of Puma workers
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
# Use the `threads` method to control the number of threads to use
threads Integer(ENV['RAILS_MAX_THREADS'] || 5), Integer(ENV['RAILS_MAX_THREADS'] || 5)
# Puma can be configured to use a different time zone than the default
# (which is the time zone of the server).
# time_zone 'UTC'
# Use `preload_app!` to load the application before the workers are started
preload_app!
# Allow puma to be restarted by `pumactl`
# (the `pumactl` command is used for managing Puma processes)
# restart_command 'pumactl -F config/puma.rb restart'
# Puma will attempt to stop gracefully within `shutdown_timeout` seconds.
# The default is 15 seconds.
shutdown_timeout 15
# Optional: Set the `control_app` that will be used by `pumactl` to control
# the worker processes.
control_app 'pumactl'
Example pumactl
command:
pumactl -F config/puma.rb restart
Source: