2

Alright, I normally don’t ask for help, but on this one I am a little baffled.

I am working on a website where we do a ajax post, that goes through my Magento module’s IndexControler and sends back a list of the available options. Pretty straight fowatd.

Everything works but for some reason the time to first byte is 800ms, which is too long (you start trying to click the select before the options are populated).

At first I thought it was my DB calls, so I completely removed all DB calls and set a static array.

{"models":[{"id":"5","name":"iPhone 5"},{"id":"6","name":"iPhone 5s"},{"id":"7","name":"iPhone 6"},{"id":"8","name":"iPhone 6+”}]}

Tested it, and the time to first byte was still 800ms. So after that I set up the file in its own local .php file on the same server and ran the test and it returned a 90ms, which is exactly what I expected…

So my question is this - where and what is causing Magento to have such a long time to first byte, and do you have any ideas?

  • I’ve already shift to sending my responses to json, and that did shave off 50ms it wasn’t enough to make it fell responsive enough to use in production.
1
  • 1
    What did Aoe_Profiler tell you? Or New Relic? Or xdebug profile dump in phpstorm? – Melvyn Dec 18 '14 at 17:15
1

I suspect you are basically just looking at the time it takes to initialise the Magento framework which unfortunately isn't a quick process. Building and rendering the layout is something else which also takes quite a bit of time. If 800ms is too slow, then you probably need to review the hardware your site is running on with a view to upgrading.

3
  • I am quite sure its not a hardware issue, in hindsight I should have realized the solution to it all would be caching. I never enable it when I am working on a development site and the moment I enable it - the speed goes from 800ms to 250-350ms. While 350ms is cutting it close on the functionality side of things it is much acceptable. – Johnathon Mathews Dec 18 '14 at 19:08
  • Also keep in mind that for complex DB calls, sometimes you're better off using raw SQL instead of Magento's/Zend's ORM components. – pspahn Dec 18 '14 at 20:25
  • The solution to poor performance is not caching. Your site should perform well with caching off, with caching then used to give an extra boost to performance and reduce resource usage. Remember certain areas of the site will never be cached such as cart and checkout, and if these areas are suddenly very slow when the rest of the site performs acceptably you are very likely to have abandoned carts. Raw database calls...just don't go there, the Magento EAV database structure is extremely complex and not using Magento methods to pull and save data is really not a good idea, even on flat tables. – Jonathan Hussey Dec 19 '14 at 8:54
0

Are other magento oriented pages with a similar TTFB? If so my guess is a 3rd party module could be referenced during the request.

Try disabling the community code pool via local.xml and rename app/code/local to something else temporarily as well since a lot of 3rd party modules reside there. This may help identify a call to a 3rd party module behaving badly, causing the delay.

With your own local.php test file is it bootstrapping magento?

Do you have APC setup? If not, I highly recommend it. Magentos auto loader can eat up a lot of I/O with it's huge codebase and 4 code pool directories to traverse over.

Also what (if any) caching mechanisms are in use?

As others mentioned AOE_profiler is a very handy tool to profile the codebase and even DB calls (see local.xml additions for it) to get more insight of the entire stack of a request. Mytop, iotop and htop are some Linux based tools to help watch the ins and outs as well in relation to the server stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.