Puma was built for speed and parallelism. Puma is a small library providing a fast and concurrent HTTP 1.1 server for Ruby web applications.
The AppSignal Ruby gem automatically inserts a listener into the Puma server; no manual setup is required.
Puma metrics plugin
To enable the metrics collection, add the AppSignal plugin to your Puma configuration:
# puma.rb (or config/puma.rb) plugin :appsignal
Puma may require additional configuration to load your application's secrets, which may be necessary for AppSignal to start.
prune_bundler, you must add AppSignal as a runtime dependency.
# puma.rb (or config/puma.rb) prune_bundler plugin :appsignal extra_runtime_dependencies ["appsignal"]
AppSignal runs a background process in Puma's main process when using the Puma plugin. The rest of your app is not loaded by default in Puma's main process (unless you use
preload_app!, which may not be suitable for your app). Without additional configuration, the AppSignal config will fail to load, and AppSignal will not start.
No "on boot" hook is available in Puma to load your extra config in the main process. To load your configuration, add it to the root of your
puma.rb configuration file, as in the example below.
# puma.rb (or config/puma.rb) plugin :appsignal # Add this plugin # Rails secrets # Add this line when using Rails secrets in your `config/appsignal.yml` file. require "rails" # Add this section when using dotenv for secrets management require "dotenv" Dotenv.load # or for Rails apps: require "dotenv/rails-now" Dotenv.load # Rest of your Puma config...
This probe listens to the
APPSIGNAL_HOSTNAME config option from the environment variable for the hostname tag added to all its metrics. If none is set, it will try to detect it automatically. Use the
APPSIGNAL_HOSTNAME system environment variable to set the hostname if you want to change the detected hostname.
This probe listens to the
APPSIGNAL_STATSD_PORT config option from the environment variable for the configuration of non-default StatsD ports. If the environment variable is not set, it defaults to 8125. For the Puma main process, it is required to use the environment variable; it will not read the AppSignal file configuration.
Puma phased restarts don't restart the main Puma process, meaning that the AppSignal background process does not get restarted either on a phased restart. If you have made changes to the AppSignal config, you will need to fully restart your Puma app afterward to have the configuration change take effect.
# After changing the AppSignal config, restart using: pumactl restart # instead of: pumactl phased-restart
When AppSignal receives MongoDB metrics, it will create a MongoDB automated dashboard, available from the dashboard section of the AppSignal app.
The MongoDB automated dashboard will have the following graphs:
Tags give you a contextual breakdown of Active job performance information. AppSignal reports the following tags for Active Job jobs:
|Total number of currently booted workers for this server.
|Number of currently running threads for this server.
|Name of the host the metric was reported from.
|Maximum number of configured threads for this server.
|Number of workers running the previous configuration/code of the server at the moment in time. Puma will phase these out as new workers start.
|Number of currently running threads for this server
Graphs allow you to monitor your application's metrics visually. You can add markers to graphs and click on any data point to gain insights into your application's state at that time.
Connection backlog graph
The Connection backlog graph shows the amount of incoming connections to the server that are waiting to be served in the server's backlog queue.
You can use the Connection backlog graph to monitor how many requests are waiting to be handled and spot Puma bottlenecks.
Pool capacity graph
The Pool capacity graph shows the amount of Puma threads available to receive requests, including Puma threads that have yet to be spawned.
You can use the Pool capacity graph to monitor the availability of Puma threads and optimize workers.
The Threads graph shows information about the threads spawned by Puma to serve web requests aggregated across all Puma workers. To serve web requests, Puma will spawn more threads when needed. The graph will show you the amount of threads running against the max available number of threads.
You can use the Threads graph to monitor the demand and supply of Puma threads and optimize workers.
Worker info graph
The Worker info graph shows how many Puma workers are working and what version of your website they are using. The count line shows how many workers are working in total, while the booted and old lines show how many workers are using the new version and how many workers are using the old version of your application.
You can use the worker info graph to monitor the status and performance of your Puma workers and see how many workers are running on an outdated configuration of your application.