Hey people,
I am actually working on my new webshop and have some performance issues.
When i click on the checkout button in the shoppingcart it takes sometimes up to 1 minute to load the login window.
Using the profiler I found this lines, which seems to be the main issue.
mage::dispatch::controller::action::checkout_onepage_index::layout_render | 22.0200 | 1 | 0 | 0 |
frontend/base/default/template/checkout/onepage.phtml | 21.6264 | 1 | 3,610,824 | 4,194,304 |
frontend/base/default/template/persistent/checkout/onepage/billing.phtml | 21.3069 | 1 | 2,508,816 | 3,932,160 |
TEST: Mage_Directory_Helper_Data::getRegionJsonByStore | 20.9629 | 2 | 946,672 | 1,835,008 |
What can I do?
Thanks a lot!
Christian
Magento CE
Version 1.9.2.4
Have you made any local code customizations to the Mage_Directory_Helper_Data class, or any extension overriding this class? As shown in the profiler output, the method getRegionJsonByStore belonging to this class takes 20 seconds to load, which is not normal. I am also not sure why that line is prepended with the word "TEST:". I would start by looking into the code related to this method.
Thanks Sindre for your reply!
I found the "TEST-function" in the code, but it seems not to be modified or added by a pugin.
/** * Retrieve regions data json * * @param int|null $storeId * @return array() */ public function getRegionJsonByStore($storeId = null) { Varien_Profiler::start('TEST: '.__METHOD__); if (!$this->_regionJson) { $store = $this->_app->getStore($storeId); $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . (string)$store->getId(); if ($this->_app->useCache('config')) { $json = $this->_app->loadCache($cacheKey); } if (empty($json)) { $regions = $this->_getRegions($storeId); $helper = $this->_factory->getHelper('core'); $json = $helper->jsonEncode($regions); if ($this->_app->useCache('config')) { $this->_app->saveCache($json, $cacheKey, array('config')); } } $this->_regionJson = $json; } Varien_Profiler::stop('TEST: ' . __METHOD__); return $this->_regionJson; }
That method by itself should not be very time consuming, so the problem could be something else. Is the slowness only appearing on the checkout page and all other pages are loading quickly? Is your site a multi-store installation? If so, how many stores do you have?
I am having the same problem. When I click add to shopping cart it will take up to a minute to process.
These are the outstanding entries from Profiler:
Code Profiler | Time | Cnt | Emalloc | RealMem |
frontend/base/default/template/page/1column.phtml | 60.116 | 1 | 4050664 | 4718592 |
frontend/Titan/default/template/checkout/cart.phtml | 60.096 | 1 | 3563936 | 4194304 |
mage | 60.652 | 1 | 0 | 0 |
mage::dispatch::controller::action::checkout_cart_index | 60.229 | 1 | 0 | 0 |
mage::dispatch::controller::action::checkout_cart_index::layout_render | 60.122 | 1 | 0 | 0 |
mage::dispatch::routers_match | 60.237 | 1 | 0 | 0 |
Mage_Checkout_CartController::indexActioncart_display | 60.138 | 1 | 0 | 0 |
Magento Version: 1.9.2.4-1
I am running this site is AWS:
Instance type: t2.small
EBS Storage: Type: gp2 (30gb)
Filesystem | Size | Used | Avail | Use% | Mounted on |
udev | 996M | 12K | 996M | 1% | /dev |
tmpfs | 201M | 352K | 200M | 1% | /run |
/dev/xvda1 | 30G | 3.6G | 25G | 13% | / |
none | 4.0K | 0 | 4.0K | 0% | /sys/fs/cgroup |
none | 5.0M | 0 | 5.0M | 0% | /run/lock |
none | 1001M | 0 | 1001M | 0% | /run/shm |
none | 100M | 0 | 100M | 0% | /run/user |
(mySQL Does not seem to be the issue)
SQL Profiler Info:
Executed 69 queries in 0.018908739089966 seconds
Average query length: 0.00027403969695603 seconds
Queries per second: 3649.1063561513
Longest query length: 0.0028798580169678
I would start by looking at this template: frontend/Titan/default/template/checkout/cart.phtml
Judging from the profiler output, there seem to be a large delay while loading this template. You can try to replace it with the default one from the core package. If the issue goes away you need to optimize the code of your custom template.
Actually we have 2 stores on the installation. Both are actually running with the default theme.
Yes, every other page is fast. It does only and always spend so much time, when you click on the checkout-button in the shopping-cart or in the title-bar while cart is not empty.
just try it yourself. This link brings you to a product of our shop.
Click on "IN DEN WARENKORB" to add it to the shopping-cart.
Then Click on "ZUR KASSE" to checkout.
As you can see it will take a while.
@SindreM wrote:I would start by looking at this template: frontend/Titan/default/template/checkout/cart.phtml
Judging from the profiler output, there seem to be a large delay while loading this template. You can try to replace it with the default one from the core package. If the issue goes away you need to optimize the code of your custom template.
Thank you and I have checked the file as suggested. The contents is below but this is actually the same file as in the default/modern template (the Titan template is based off that one) The cart.phtml file has not been customized at this point.
<div class="cart"> <div class="page-title title-buttons"> <h1><?php echo $this->__('Shopping Cart') ?></h1> <?php if(!$this->hasError()): ?> <ul class="checkout-types"> <?php foreach ($this->getMethods('top_methods') as $method): ?> <?php if ($methodHtml = $this->getMethodHtml($method)): ?> <li><?php echo $methodHtml; ?></li> <?php endif; ?> <?php endforeach; ?> </ul> <?php endif; ?> </div> <?php echo $this->getMessagesBlock()->toHtml() ?> <?php echo $this->getChildHtml('form_before') ?> <form action="<?php echo $this->getFormActionUrl() ?>" method="post"> <fieldset> <table id="shopping-cart-table" class="data-table cart-table"> <col width="1" /> <col /> <col width="1" /> <?php if ($this->helper('wishlist')->isAllowInCart()) : ?> <col width="1" /> <?php endif ?> <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?> <col width="1" /> <?php endif; ?> <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?> <col width="1" /> <?php endif; ?> <col width="1" /> <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?> <col width="1" /> <?php endif; ?> <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?> <col width="1" /> <?php endif; ?> <col width="1" /> <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?> <thead> <tr> <th rowspan="<?php echo $mergedCells; ?>"> </th> <th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Product Name') ?></span></th> <th rowspan="<?php echo $mergedCells; ?>"></th> <?php if ($this->helper('wishlist')->isAllowInCart()) : ?> <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><span class="nobr"><?php echo $this->__('Move to Wishlist') ?></span></th> <?php endif ?> <th class="a-center" colspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Unit Price') ?></span></th> <th rowspan="<?php echo $mergedCells; ?>" class="a-center"><?php echo $this->__('Qty') ?></th> <th class="a-center" colspan="<?php echo $mergedCells; ?>"><?php echo $this->__('Subtotal') ?></th> <th rowspan="<?php echo $mergedCells; ?>" class="a-center"> </th> </tr> <?php if ($this->helper('tax')->displayCartBothPrices()): ?> <tr> <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> </tr> <?php endif; ?> </thead> <tfoot> <tr> <td colspan="50" class="a-right"> <?php if($this->getContinueShoppingUrl()): ?> <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" onclick="setLocation('<?php echo Mage::helper('core')->quoteEscape($this->getContinueShoppingUrl()) ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button> <?php endif; ?> <button type="submit" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" class="button btn-update"><span><span><?php echo $this->__('Update Shopping Cart'); ?></span></span></button> <button type="submit" name="update_cart_action" value="empty_cart" title="<?php echo $this->__('Clear Shopping Cart'); ?>" class="button btn-empty" id="empty_cart_button"><span><span><?php echo $this->__('Clear Shopping Cart'); ?></span></span></button> <!--[if lt IE 8]> <input type="hidden" id="update_cart_action_container" /> <script type="text/javascript"> //<![CDATA[ Event.observe(window, 'load', function() { // Internet Explorer (lt 8) does not support value attribute in button elements $emptyCartButton = $('empty_cart_button'); $cartActionContainer = $('update_cart_action_container'); if ($emptyCartButton && $cartActionContainer) { Event.observe($emptyCartButton, 'click', function() { $emptyCartButton.setAttribute('name', 'update_cart_action_temp'); $cartActionContainer.setAttribute('name', 'update_cart_action'); $cartActionContainer.setValue('empty_cart'); }); } }); //]]> </script> <![endif]--> </td> </tr> </tfoot> <tbody> <?php foreach($this->getItems() as $_item): ?> <?php echo $this->getItemHtml($_item) ?> <?php endforeach ?> </tbody> </table> <script type="text/javascript">decorateTable('shopping-cart-table')</script> </fieldset> </form> <div class="cart-collaterals"> <div class="col2-set"> <div class="col-1"> <?php if($_crosssell = $this->getChildHtml('crosssell')): ?> <?php echo $_crosssell; ?> <?php else: ?> <div class="no-crosssell"> <img src="<?php echo $this->getSkinUrl('images/media/callout1.jpg') ?>" alt="" /> <img src="<?php echo $this->getSkinUrl('images/media/fpo_no_crosssell.gif') ?>" alt="" /> </div> <?php endif; ?> </div> <div class="col-2"> <?php /* Extensions placeholder */ ?> <?php echo $this->getChildHtml('checkout.cart.extra') ?> <?php echo $this->getChildHtml('coupon') ?> <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?> <div class="totals"> <?php echo $this->getChildHtml('totals'); ?> <?php if(!$this->hasError()): ?> <ul class="checkout-types"> <?php foreach ($this->getMethods('methods') as $method): ?> <?php if ($methodHtml = $this->getMethodHtml($method)): ?> <li><?php echo $methodHtml; ?></li> <?php endif; ?> <?php endforeach; ?> </ul> <?php endif; ?> </div> </div> </div> </div> </div>