Cpu % maxing out

Cpu % maxing out

Alex

Member
Local time
04:42
Joined
Oct 5, 2019
Messages
14

Any folks that know how to find offending processes that are eating up CPU in a digital ocean droplet?

 

Adam

Mr. Webwide
Administrator
Local time
11:42
Joined
Sep 24, 2019
Messages
1,246
Pronouns
he/him

I think if you run the top command it should give you a list of all processes and their usage.

 

Alex

Member
Local time
04:42
Joined
Oct 5, 2019
Messages
14

Thanks, I get MySQL %86..
This means it has to be the darn queries. I am running a Laravel app.
Any way the particularly slow query can be found?

 

Adam

Mr. Webwide
Administrator
Local time
11:42
Joined
Sep 24, 2019
Messages
1,246
Pronouns
he/him

Paging @Gummibeer Laravel guru. I know we have a few other Laravel pros here but can’t remember names. 😇

If nobody gets back to you on this thread may be worth making a new one specifically about slow laravel queries.

 

Alex

Member
Local time
04:42
Joined
Oct 5, 2019
Messages
14

I have a hint about one initial page load. It's an initial list that requires paging. But I rather use a tool that tells me exactly where the issue lies.

 

Gummibeer

Astroneer
Moderator
Local time
12:42
Joined
Oct 5, 2019
Messages
1,155
Pronouns
he/him

Search for MySQL slow query log. It will slow your DB more down but logs you EVERY slow query. There's also a tool, forgot the name, that analyses the log and gives recommendation to improve - add/remove indices, split queries and so on.

Some general things:
Laravel queries (MySQL at all) gets slow with joins, n+1 queries and really large result sets.

Ideas to fix: check if you can use subqueries instead of joins. Use eager loading instead of n+1 loading, paginate in DB not PHP.
You should also check if you Aggregate any values that you can store in cache/redis.

Deep relation loading via too complex accessors/mutators is a very common issue.

If you have any code or query I can try to help with more detailed recommendations.


 
Last edited:

Alex

Member
Local time
04:42
Joined
Oct 5, 2019
Messages
14

A top command in shell showed me the pain the processor gets when I hit a specific route and DB query.
Can you tell me more about pagination in DB?
Maybe if I could share a screen with you and we could see it together?

 
Top