Website getting slower and slower for TTFB, despite been wery quick in the beginning

I have one site under Prestashop (LAMP platform), the sole website hosted on a dedicated server,
but in recent monthes it has gottent slow, and sometimes the mysql server crashed.
I don’ t know where to start, i just know that php-cgi was also the culprit.

i made a free -m and here is the result

$ free -m
total used free shared buffers cached
Mem: 7977 7800 177 0 1 3193
-/+ buffers/cache: 4605 3372
Swap: 975 751 224

it seems there’s a lot of memory consumption !

FYI i used to install nginx in the beginning, but now it is removed completely and i restarted the server.
Where should i start to investigate?
thank you

I would start with optimizing the DB and Apache. For MySQL google up mysqltuner and use it to check your DB. There is no one settings for everything and even two equal servers almost never have same settings. You should start by applying “default” settings for the amount of your memory and then use mysqltuner to fine tune your DB. Not hard if you have some knowledge but its time consuming as you need to wait at least 2-3 days between checks to get real picture what is going on with your DB. Oh and it would be good to switch to Innodb instead of MyISAM.

For the Apache you should check the logs and see what changes to apply.

hi thank you will do.
My Prestashop is already using InnoDB.
BUT how would you identify which part is slow (besides mysql)?
running free -m doesn’t show me.
Here is a screenshot with the commend top, is it normal that i have 17 instances of php-cgi for one website? each consuming 240m virtual memory?

Well if you never fine tuned your MySQL there is no question if you should do it. Usually when server becomes slow means few things:

  1. During time server got oversold and the performance is rapidly going down
  2. Hosting company do not track the server activity and there could be one or more users abusing the node
  3. You never fine tuned your MySQL, Apache… and with time it start to degrade
  4. All mentioned combined

Of course the reasons could be many but i’m telling you what are the ones what most frequently show out. Another thing what can speed up MySQL is SSD but if you dont do your part of the job it will be temporary and pretty soon you will end with same problem.

ok thanks

i ran mysqltuner, nothing to notice, but i saw that i installed a Wordpress using the innoDB engine (WP uses the engine of the DB) i think WP is not optimized for innoDB, that’s why the system was really slow, a top commend showed dozens of this WP with php-cgi command
i disable the WP and everything is fast again.
The uptime command showed an average load of 10 to 20 ! now back to 0.15 :slight_smile:

That means you must take time and properly setup DB settings. If just one WP can do such “damage” to the DB you have bigger problems than slow TTFB.