Magento slow post

Hello.

After an intense debug into Magento, we (Filipe Ibaldo and me) have found two problems in Magento code, related to slow Place Order with many products in cart (not many qty of a product).

One of the problems is the order item save, which is executed precisely in app/code/core/Mage/Sales/Model/Entity/Order/Attribute/Backend/Parent.php, on afterSave method, who spent many time on my machine (Core 2 Duo 2.26/4GB RAM), about 0.3 second for each product.

Considering the number of items average of customer’s cart is about 50 distinct products, this time, adding to another code executions and a high server load, is easily more than one minute, and this is unacceptable.

The found workaround is disable some observers from Mage_Downloadable and Mage_Rss, who execute in afterSave of each item in order.

In app/code/core/Mage/Downloadable/etc/config.xml, remove/comment the following lines:

<sales_order_item_save_commit_after>
    <observers>
        <downloadable_observer>
            <class>downloadable/observer</class>
            <method>saveDownloadableOrderItem</method>
        </downloadable_observer>
    </observers>
</sales_order_item_save_commit_after>

The code above appears twice.

In app/code/core/Mage/Rss/etc/config.xml, remove/comment the following lines:

<sales_order_save_after>
    <observers>
        <notifystock>
            <class>rss/observer</class>
            <method>salesOrderItemSaveAfterNotifyStock</method>
        </notifystock>
    </observers>
</sales_order_save_after>
<sales_order_save_after>
    <observers>
        <ordernew>
            <class>rss/observer</class>
            <method>salesOrderItemSaveAfterOrderNew</method>
        </ordernew>
    </observers>
</sales_order_save_after>

With this workaround, the save time of each product went from 0.3 second to 0.001 second, an incredible speed improvement.

However, if you are using downloadable products or Magento Inventory Management, this modifications can broke related features, so, be careful.

Another problem found is related with module disable feature into System > Configuration > Advanced > Advanced > Disable Module Output. If you disable some module, their observers did not disabled, and you need to remove their configuration or delete module folder.

Bye.

Tags: php, magento, performance

Comments

comments powered by Disqus