[SOLVED] High server CPU & RAM load

Our server (free tier) load is currently high. CPU is at ~80-90% 100% and RAM around ~75%.

We syncing a bunch of blockchain events with our database, performing some more additional requests under that data and deleting it a bit later.

Since blockchain events always trigger database write operations, performing requests I assume that’s the reason why we have such a big load.

If you guys could elaborate on this, it would be really nice.
Is there anything we can do on our side, or maybe we just need to upgrade our server?

Server sub-domain: c8xqc8h2vitm

Can you describe what are you doing with those blockchain events that you sync to database?
How is that you are syncing so many events? what event are you syncing? can you sync another event that has fewer events emitted?

Soon as new event happens we saving event data it in to our database.
Before actual save we performing another request to get additional data.
After every write we also checking rows amount and deleting last row asynchronously if rows total hits specific amount (let’s say 100).

There’s multiple events which we are listening, whole lifecycle is mostly same.

My guess for now it was shortest path to get all needed data from sources, so not sure if we could optimize something here without changing actual approach.

On client-side we listening for database changes by subscribing to them and in that way achieving “real-time” experience to end-user.

Not sure if this is issue here but I made mistake of performing saving to same table as beforeSave is listening to. This can cause an infinite loop without further validations.

Just a head ups for anyone that may be reading and made same mistake.

1 Like

@cosmos thanks, we double checked that too, but wasn’t the case.

Seems to be our logic was giving huge load itself, which totally makes sense, there was no issues on Moralis side besides weak free tier server which wasn’t able to deal with it.

We reviewed, refactored and a bit optimized data lifecycle and was able to lower load from 100% CPU to like 5-10% and RAM load up to 50%.