問題描述
Magento 通常這么慢嗎?
Is Magento usually so terribly slow?
這是我第一次使用它,管理面板需要很長(zhǎng)時(shí)間才能加載和保存更改.它是帶有測(cè)試數(shù)據(jù)的默認(rèn)安裝.
This is my first experience with it and the admin panel simply takes ages to load and save changes. It is a default installation with the test data.
托管它的服務(wù)器以超快的速度為其他非 Magento 站點(diǎn)提供服務(wù).Magento 使用的 PHP 代碼是什么導(dǎo)致它變得如此緩慢,以及可以做些什么來修復(fù)它?
The server where it is hosted serves other non-Magento sites super fast. What is it about the PHP code that Magento uses that makes it so slow, and what can be done to fix it?
推薦答案
我只是偶爾參與了 Magento 的性能優(yōu)化,但這里有一些系統(tǒng)如此緩慢的原因
I've only been tangentially involved in optimizing Magento for performance, but here's a few reasons why the system is so slow
部分 Magento 使用在 MySQL 之上實(shí)現(xiàn)的 EAV 數(shù)據(jù)庫(kù)系統(tǒng).這意味著查詢單個(gè)事物"通常意味著查詢多行
Parts of Magento use an EAV database system implemented on top of MySQL. This means querying for a single "thing" often means querying multiple rows
幕后有很多事情(應(yīng)用程序配置、系統(tǒng)配置、布局配置等)涉及在內(nèi)存中構(gòu)建巨大的 XML 樹,然后查詢"這些相同的樹以獲取信息.這需要內(nèi)存(存儲(chǔ)樹)和 CPU(解析樹).其中一些(尤其是布局樹)是巨大的.此外,除非打開緩存,否則這些樹是從磁盤上的文件和每個(gè)請(qǐng)求構(gòu)建的.
There's a lot of things behind the scenes (application configuration, system config, layout config, etc.) that involve building up giant XML trees in memory and then "querying" those same trees for information. This takes both memory (storing the trees) and CPU (parsing the trees). Some of these (especially the layout tree) are huge. Also, unless caching is on, these tree are built up from files on disk and on each request.
Magento 使用其配置系統(tǒng)來允許您覆蓋類.這是一個(gè)強(qiáng)大的功能,但它意味著無(wú)論何時(shí)實(shí)例化模型、助手或控制器,都需要運(yùn)行額外的 PHP 指令來確定是否需要原始類文件或覆蓋類文件.這加起來.
Magento uses its configuration system to allow you to override classes. This is a powerful feature, but it means anytime a model, helper, or controller is instantiated, extra PHP instructions need to run to determine if an original class file or an override class files is needed. This adds up.
Magento 的模板系統(tǒng)除了布局系統(tǒng),還涉及到大量的遞歸渲染.這加起來.
Besides the layout system, Magento's template system involves a lot of recursive rendering. This adds up.
總的來說,Magento 工程師的首要任務(wù)是構(gòu)建盡可能靈活、可定制的系統(tǒng),然后再擔(dān)心性能問題.
In general, the Magento Engineers were tasked, first and foremost, with building the most flexible, customizable system possible, and worry about performance later.
為確保更好的性能,您可以做的第一件事是打開緩存(系統(tǒng) -> 緩存管理).這將緩解 Magento 構(gòu)建其各種 XML 樹時(shí)發(fā)生的一些 CPU/磁盤阻塞.
The first thing you can do to ensure better performance is turn caching on (System -> Cache Management). This will relieve some of the CPU/disk blocking that goes on while Magento is building up its various XML trees.
您要做的第二件事是確保您的主機(jī)和運(yùn)營(yíng)團(tuán)隊(duì)具有 Magento 性能調(diào)優(yōu)經(jīng)驗(yàn).如果您依靠每月 7 美元的計(jì)劃來幫助您度過難關(guān),那么祝您好運(yùn).
The second thing you'll want to do is ensure your host and operations team has experience performance tuning Magento. If you're relying on the $7/month plan to see you through, well, good luck with that.
這篇關(guān)于為什么 Magento 這么慢?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!