Вопрос

I have Magento setup to manage 7 different storefronts on a VPS. Each storefront has a unique IP, while they of course share the same database, only some products are on some sites. About a week ago, one of the storefronts became dramatically sluggish. I’m talking 10+ second load times. The weird thing is, all of the other sites were still humming along fine at about 4 seconds. But periodically, their performance will dip as well. My host said they haven’t done anything to the server, and they corrected a few issues, but even they can’t identify what’s going on. I’ve decreased the time between log cleaning (even though I don’t think it needed to be). I do have to add that I have over 100 static pages and our htaccess is pretty big (215k) because of a number or redirects and blocked IPs. I think it’s a magento issue and not a server issue, but I cant figure out why it’s only this one storefront. Has this ever happened to anyone else? Or is there anything that I’m overlooking?

Это было полезно?

Решение

You need to do some profiling to figure out the culprit. Magento even offers some options out of the box.
First, go to System > Configuration > Developer, and add your current public IP to the Developer Client Restriction Allowed IP's.

Then switch to the store view scope of the store in question and turn on the profiler display in the debug section.

Next you need to enable the profiler to collect the data. This will further slow down the site (all stores), but since it will provide you with the data you need to fix it, this temporary tradeoff will hopefully be worth it.

There are two profilers integrated in Magento. One for PHP code, and one for DB SQL queries.

PHP Profiler
Open the index.php file in the Magento root directory and remove the comment character in front of the line that calls

Varien_Profiler::enable();

When you reload a page after enabling that call you should see a long list of profiler timers at the bottom of every page, telling you the time spent and the number of calls to each profiler section in question.

DB Profiler
Open the file app/etc/local.xml and add the <profiler>node to the connection configuration.

<config>
    <global>
        <resources>
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[xxxx]]></username>
                    <password><![CDATA[xxx]]></password>
                    <dbname><![CDATA[xxx]]></dbname>
                    <active>1</active>
                    <!-- This is the line you need to add: -->
                    <profiler>true</profiler>
                </connection>
            </default_setup>
         </resources>
    </global>
</config>

After you flush the config cache, you should also see some DB query statistics and the slowest query during that page request at the bottom of the page.

Hopefully this will give you some insight what is slowing down the store and provide you with some data how to fix it.
Remember to turn off the code profiler, the SQL profiler and the profiler output after you are finished. Just turning of the output only will still have the profilers happily collecting data and slowing down the whole website.

EDIT: The data collected by the profilers is available to, for example, create sortable spreadsheets and add custom timers. This can be helpful, but goes beyond the scope of this post. A developer familiar with Magento will be fine creating such custom modules on their own.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top