Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

birdietorerik's avatar

Server very slow

Hi!

Have created a application, and using Digital Ocean for my application Today we have some big issues about the server..

  • CPU 100% usage -Memory somtimes uses 100%

I am using Redis in Laravel application

Somtimes i get problems in logging on to my Mysql database

Error message :

cant connect to MYSQL...

What can i do to fix this ?

Upgrade RAM and CPU ?

0 likes
7 replies
JussiMannisto's avatar

Before you upgrade anything, find out what's causing the issues. I recommend these steps:

  • Find out which processes are consuming the memory and CPU time. It's probably the DBMS, but you should verify it.
  • Check the web server logs and find out which routes were being hit when you experienced the mysql errors.
  • Performance issues are usually caused by bad DB queries. Check if any queries use non-indexed columns in their conditions. Check if any query retrieves a large amount of data from the DB unnecessarily. Check for N+1 problems, e.g. queries performed in a loop instead of a single query.
  • Examine the server logs to determine if the web traffic is valid or malicious. Add rate limits if needed.
  • Cache query results whenever it's feasible.
1 like
Tray2's avatar

I agree with @jussimannisto, there is something in your application that eat performance.

I would start looking for places where you do fetch all columns even though you might only use a couple of them. I would also look for place where you loop through your Eloquent collections for any other purpose than displaying them, and that includes maps, and filters. Try not to fetch all records from a table, use pagination as much as possible.

1 like
Snapey's avatar

Run htop on the server to see the proportion of resources used, and by what process.

What's the spec of the server and the number of overlapping requests?

1 like
birdietorerik's avatar

Hi All!

This error are so strange... Struggle with this now for 10 days

Get error Message :

Database is disconnected ?

I am using Laravel Forge and Server is using Digital Ocean. My application is using Redis and MYSQL using same host (on live server) 127.0.0.1 Can that be a problem ?

BoulbabMohamed's avatar

well first of all check if the server is capable of storing the amount of cache you require, it also depends on how you're handling your cache, we are not caching everything of course, only static tables that we don't change often, if you find yourself storing everything in cache, try to implement indexes instead for better db performance while using cache for specific cases. the other factor is how many active users you have, if you app is so busy, consider upgrading your server hardware and try, Digital Ocean and similar servers providers will charge you by hour and that's won't cost you much.

jlrdw's avatar

Also

  • do you have blob values in the database
  • are you retrieving too many records then paginating (paginate server side)
1 like

Please or to participate in this conversation.