Crazy TTFB, I need help!

Hi guys,

I’m currently running Magento 1.6.2. 2-3 days ago Hostgator migrated my site to another server (they claimed it’s an upgrade).

However after the migrate, somehow my website takes forever to load. In the past, one page takes about 3-5s to load, despite poor optimization.
Now after changing to a new server, and after optimizing my site, one page sometimes can take up to 1min to load!

Hostgator claimed that it is due to poor coding in my site. However this has never happened before in the past. I looked through the codes and everything, all seem good. Based on the test, it seem that the server takes a long time to receive response from my site, the waiting time is very long.

Here’s the test result:

I’m really lost, and the site is running live. Any idea what went wrong?

More likely than not it is horrible database performance. Poor Coding is a cop-out and their first resort. It’s possible that there is something timing out because there was a firewall hole open to some service for your old server’s IP but not the new one but that seems a lot less likely than the new web or database server being horribly over-provisioned. It looks like static files are served fast enough so it’s probably going to be the database.

In a perfect world - that’s one where every process has a surfeit of RAM to cache out of, the ultimate bottleneck for a magento site is plain CPU power.

However, to time it up for this, you really need to be able to configure your own server, which means at least a VPS to see and change what is going on.

For Magento sites,

  • ensure multiple CPUs ( virtual or not ) are available
  • Beef up the innodb caches for magento, so everything databasey is served from memory ( and probably query cache, but remember a) it doesn’t support prepared queries, and b) it’s single threaded so suck it and see),
  • run php in fpm mode with APC opcode caching ( I find this is so much simpler to do using nginx rather than fooling apache into accepting it but if you decide on sticking with apache then eaccelerator may well work better ),
  • investigate different caching and session storage backends ( look at Colin Mollenhour’s work )
  • for CE, look at fpc options ( eg Listi_fpc and ezzoom )

with these, good results can be had from this leviathan of a product on even modest hardware…
like my demo site… ( note running wpt flat out to make the site look as good as possible, and - as mentioned in a separate thread - the link to PayPal has been removed! ).

The alternative is to use Magento - specific hosting and see how they stack up.