I am using rails 4.2.8 with ruby 2.6.2 with puma and nginx. I am currently hosting it on Digital Ocean with 4 GB Memory / 30 GB Disk. I have currently set the number of puma threads to max 16 and the number of database pool to 18.
The server sometimes stops responding. When I check puma.access.log it shows a lot of lines of "log writing failed. deadlock; recursive locking".
When I check the Digital Ocean dashboard, there is usually a spike of CPU usage to about 70% (normally it's about 15%) and a spike of Disk I/O.
Please kindly guide me how to debug the issue.