Identifying CPU spike on DigitalOcean server

I have a WebApp that runs fine most of the time.

The app is hosted on a DigitalOcean server running Debian 12 x64.
The app was installed through LifeBoat by @Tim_Parnell

For the second time in two weeks, I had to restart the server after a CPU spike.
The DigitalOcean graphs for this morning look like this:

I was in a hurry to fix the issue so I restarted the server without connecting to it and checking which process was using all CPU.

Next time this happens, I plan on connecting to the server and running htop command.
Would you have any other recommendation on what to do next time it happens?

You may simply have an endless loop in your code somewhere.
So you could go on the server and try to get a stack trace from the threads.

There’s a brief memory spike to 100%:
image
I wonder if a process ran out of memory and then got stuck?

2 Likes

I’ll need to figure that out next time it happens.

Thank you for the suggestion.

Could it be the socket pool creation? What minsockets and maxsockets values you have set?

@Jeremie_L , I used to see this kind of behavior before I required Lifeboat install a swapfile. I haven’t seen it on my instances since. This makes me fear some kind of regression in the framework, what version of Xojo did you use?

FWIW, Amazon EC2 instances can be watched by a service called CloudWatch that will reboot the instance automatically if it gets stuck at 100% CPU like this. It was an unfortunate solution I had in place until the swapfile fixed the issue.

Do your nginx logs show some kind of heavily increased traffic in that time? I can help you with this privately if you need.

Long ago a staff member said that adjusting these values is almost never necessary, so Lifeboat leaves the default values.

Thank you for your input Tim.

I am using Xojo 2024r3 since a couple weeks.

I prefer staying on digitalocean as the MySQL database is stored in the same region as the instance running the web app. And I would need to reconfigure all my apps if I changed hosting service.

I will contact you privately.