This post describes steps to monitor and control the puma service in production environment on RPM based distribution. It is working with Foreman 3.0 and newer. Tested on CentOS 7 and CentOS 8 Stream distributions. On CentOS 7 you need to wrap up commands in scl enable tfm '$command'
.
Using pumactl for gettings stats or gc-stats
# RHEL 7 like system
scl enable tfm 'pumactl stats -S /usr/share/foreman/tmp/puma.state'
# RHEL 8 / CentOS 8 Stream like
pumactl stats -S /usr/share/foreman/tmp/puma.state
pumactl gc-stats -S /usr/share/foreman/tmp/puma.state
example outpus:
stats
{
"started_at":"2021-09-02T07:39:16Z",
"workers":2,
"phase":0,
"booted_workers":2,
"old_workers":0,
"worker_status":[
{
"started_at":"2021-09-02T07:39:16Z",
"pid":10473,
"index":0,
"phase":0,
"booted":true,
"last_checkin":"2021-09-23T10:44:19Z",
"last_status":{
"backlog":0,
"running":0,
"pool_capacity":16,
"max_threads":16,
"requests_count":5582
}
},
{
"started_at":"2021-09-02T07:39:16Z",
"pid":10476,
"index":1,
"phase":0,
"booted":true,
"last_checkin":"2021-09-23T10:44:17Z",
"last_status":{
"backlog":0,
"running":0,
"pool_capacity":16,
"max_threads":16,
"requests_count":5282
}
}
]
}
gc-stats
{
"count":148,
"heap_allocated_pages":5365,
"heap_sorted_length":5365,
"heap_allocatable_pages":0,
"heap_available_slots":2186774,
"heap_live_slots":2186537,
"heap_free_slots":237,
"heap_final_slots":0,
"heap_marked_slots":1568935,
"heap_eden_pages":5365,
"heap_tomb_pages":0,
"total_allocated_pages":5365,
"total_freed_pages":0,
"total_allocated_objects":49608573,
"total_freed_objects":47422036,
"malloc_increase_bytes":71808,
"malloc_increase_bytes_limit":16777216,
"minor_gc_count":128,
"major_gc_count":20,
"compact_count":0,
"remembered_wb_unprotected_objects":37228,
"remembered_wb_unprotected_objects_limit":74036,
"old_objects":1477246,
"old_objects_limit":2785436,
"oldmalloc_increase_bytes":82064,
"oldmalloc_increase_bytes_limit":62801294
}
To display puma user friendly status, run this
/usr/sbin/foreman-puma-status
this gives you info about the CPU and memory usage, number of requests, current load
It works on both 7 and 8 Stream. It does not have execution permission by default, that’s why you need to add sh
to the command.
For continuous monitoring, you can use watch like this
watch --color --interval 1 sh ~foreman/script/foreman-puma-status
For the historical reasons I’m also keeping pre 3.0 notes which may work to some degree
For version with Foreman older than 3.0 see previous versions of this wiki