Spikes in CPU Utilization

I am using an AWS EC2 instance with 20 GB storage to deploy my discourse instance. Generally, it works fine with CPU usage under 10-20%. But sometimes, I notice there are huge CPU utilization spikes reaching 100% usage and thus crashes my instance. Can anyone suggest ways to solve this?

How much ram? Do you have swap? how big is you database (probably a new community?) database is in ec2 as well?

You can look at /var/discourse/shared/standalone/logs/rails/production.log when it’s happening. Probably a background task is kicking in.

I get this at the production log.

Job exception: UNBLOCKED force unblock from blocking operation, instance state changed (master → slave?) Job exception: UNBLOCKED force unblock from blocking operation, instance state changed (master → slave?) Job exception: UNBLOCKED force unblock from blocking operation, instance state changed (master → slave?) Job exception: UNBLOCKED force unblock from blocking operation, instance state changed (master → slave?) Job exception: READONLY You can’t write against a read only slave.

Is this a standard install, or are you using an external redis and/or postgres?

We did install it on our own.

Then we have little way of guessing just how you installed or what you might have done. If you folow How to install Discourse in production then we might help. Otherwise, you’re pretty much on your own.