magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Speed for magento 2 very slowly #1726

Closed tungmpo closed 8 years ago

tungmpo commented 9 years ago

Hi, I have installed magento 2 successfully on localhost but site load very slowly. it load about 30 seconds to 1 minutes. Do you know why ? pls help me

Thank a lots!

Regards Tony

mrtuvn commented 9 years ago

enable all cache may help you. Full page cache , varnish ....

dmitrii-fediuk commented 9 years ago

Use SSD (or RAM drive) for Magento files and database.

alankent commented 9 years ago

There are lots of potential reasons why, but the most common is around file system performance. In non-production mode especially, we hit the disk pretty hard (lots of different files). E.g. in developer mode we generate files on the fly (CSS etc). But without more details (PHP version? using Vagrant? VM? Docker? OS? Memory? is machine thrashing? etc), it is pretty hard to suggest something. Its certainly not taking any where near that long on my laptop. Can you provide any information about your setup? (But my first investigation would be around I/O performance - for example using Docker/VirtualBox with file syncing back to Windows is a dog - because the file syncing is very slow.)

patrickpeng2091 commented 9 years ago

linux vps so ok

kandy commented 9 years ago

@pengting Do you enable production mode (with di compilation and static files deployment)? http://devdocs.magento.com/guides/v2.0/config-guide/bootstrap/magento-modes.html

pronto2000 commented 9 years ago

First thing to check is the memory limit of PHP. Anything below 512MB is no good.

choukalos commented 9 years ago

MySQL 5.6 has some memory issues where a defaul config will use about 500mb of ram, to fix set performance_schema = off in your my.cnf and restart MySQL. Also make sure you have opcache turned on and set to at least 64mb of ram and 10000 files cached, preferable 128mb. If you tune your config you can run on a 512mb vps but it's tricky and you won't have enough ram for fpc on varnish and reddis sessions. 1 gb vps with the above MySQL fix should work like a champ out of the box on a vps.

Danruffor commented 8 years ago

Hello! I just have found quite interesting tips regarding this topic - http://sam-ecommerce.com/blog/view/speed-up-magento-website I think it could help you as well!

theskillwithin commented 8 years ago

Why would you ever enable caching on your localhost? obviously this is for development purposes not production.

It is extremely slow on my vagrant despite having a $8000 computer and devoting lots of resources to my vagrant and php. Of course every time this question is asked people assume its for live and tell them to enable caching but this does not help while developing/theming. Infact magneto 1 is much faster on my local vagrant at work on a much worse computer to develop in. Its just impossible.

nikunj1990 commented 8 years ago

you are right magento1 was fast and newer version should be faster and good than it but its reverse here.

nikunj1990 commented 8 years ago

There is no proper solution or guide to solve it.

theskillwithin commented 8 years ago

Well I will keep looking for a solution. =\

piotrekkaminski commented 8 years ago

@theskillwithin actually our internal teams work with all caches enabled and only flush the specific ones affected by code change. Which Vagrant environment are you using - can you provide a link?

nikunj1990 commented 8 years ago

There is no solution so far all pages,Add to cart every thing is slow on local host and cache is enabled. it take ages to load pages and addtocart. even no extension added, no theme added all that comes fresh installation.that must work fast.

atrejune commented 8 years ago

In my case, mysql 5.6.16 was the memory, i modified:

and change ,htaccess in magento root folder: ############################################

adjust memory limit

php_value memory_limit 3000M
php_value max_execution_time 18000

############################################

All the diference, even in dev mode.

:)

rafal-kos commented 8 years ago

Any changes on this topic? Making any changes in development mode takes too much time even if project and db are on SSD disk. Setting "production" mode and clearing specific caches during development is so cheap solution.

springimport commented 8 years ago

Enabling opcache help me with developing theme.

george-vlahakis commented 7 years ago

Same issue here. Tried everything documented. Even tried production, php7 and mysql 5.7 with as much ram as I can possibly give everything and it is stupidly slow when trying to open a "first-visit" section. Takes about 30secs. Second time it is fast but wtf. PHP 7.0.12, MYSQL 5.7.16, 2.4 Ghz i7, 8G RAM, SSD (MacBook Pro)

screen shot 2016-11-28 at 02 20 40

The screenshot from Chrome inspect and the times are on a production deployment (local) !!

OPCache enabled and MySQL performance scheme OFF still yields >5sec responses.

Why is this ticket closed?

george-vlahakis commented 7 years ago

For anyone interested, I am finally getting something below 5' responses with Full Page Caching off (stating that I use Varnish but I am not on Store config), merged-min-packed css and js, xdebug off, production mode, flat catalog, 5G innodb_buffer, innodb_flush_sync, 256M innodb_log_file_size, query cache size 1G, performance_schema off, mysql 5.7.16, php 7.0.12, OPCache 128M, 10000.

Did some profiling and the BuiltIn page cache seemed to generate a considerable bottleneck. So does piping to some of the plugins but didn't have time to identify which was taking longer to render.

All said and done, I think Magento 2 has some way to go in terms of performance. And caching everything is not a metric of performance to be honest. Sure it helps for volumes but baseline performance still needs to be there.

The above setting are obviously not suited for development but I have a feeling that disabling page caching (by turning it off and setting in store to use varnish - though you don't) may help considerably and probably best for dev.

greatwitenorth commented 7 years ago

I'm currently experiencing the same thing on a fresh installation of Magento 2.1 using Laravel Valet (powered by the Caddy web server). My system specs are the following:

Processor: 2.7 GHz Intel Core i5 Memory: 20GB DB: Ver 15.1 Distrib 10.1.17-MariaDB

Loading the homepage takes around 30 seconds to 1 minute. This kind of makes it a hard sell when the initial load time out of the box is this slow. Developers, like myself, are not going to want to touch this, and Agencies are going a have a hard time pitching this to clients knowing that there will be some significant issues with page speed.

I'm not saying this to be offensive, I'm just trying to communicate some of the conversation that goes on internally at an agency when determining if Magento is correct for an ecommerce project. This speed issue is a major blocker.

Can anyone shed some insight into what's being done about this? Also is there any way to develop locally without waiting 30 seconds between page loads? I see @vlahakis response, but as he said, it's unsuited for development. Or maybe I'm misunderstanding, and Magento 2 is not currently production ready?

ghost commented 7 years ago

@greatwitenorth this has been a long standing issue brought up many times with no real solution, just workarounds. Your best bet is to scratch local development for something remote like a vps that's linux based. Waiting for magento to load locally, even if its 15 secs every refresh will make you want to punch the screen out of your laptop.

mpont91 commented 7 years ago

This is a nightmare, I can't work with Magento2, it's just so slow, you can't develop when every single click needs 30s. All I read is enable cache, enable production mode, deploy static content... but nothing really happens.

Why happens this? This is the only framework that goes so slow. I've never experienced anything like that

snez commented 7 years ago

As I am now at over 10 minutes waiting for a single page load on a local Magento 2.1.3 setup, I thought I'd share this screenshot:

screen shot 2017-01-20 at 18 52 41

Essentially, if you are developing a site, you need to be in developer mode. To avoid caching the constantly changing assets, you need to configure the web server to go through static.php and resolve the correct asset paths. Compilation of course doesn't work because some 3rd party modules don't support it (crashing), so this is what a Magento 2 developer has to deal with.

Specs: Quad Core i7, PCIe SSD, 8gb ram, Nginx, php7-fpm, all magento caches enabled, non-containerized

snez commented 7 years ago

Update: It took a couple of weeks but the page finally loaded. I did an online course and finished the website in Shopify while I was waiting for the page to load.

screen shot 2017-01-20 at 19 05 52

george-vlahakis commented 7 years ago

Has anyone tried this?

https://magento.com/blog/technical/set-your-magento-2-development-environment-faster

mpont91 commented 7 years ago

I will try this, but never used docker... I feel awkard because what I readed, they just give you a magento project and that's all. But then? how I develop the code? what I understand is, the code is on the VM, so you'd need a sync folder or something to get the code on your windows. Well I just need to try.

But on my work we have windows 7, and seems that works only on windows 10..

Gosh.. I'm so tired of magento, I'm working on laravel with my own projects and it's just orgasmic getting away of magento for 2-3 hours ;)

On Fri, Jan 20, 2017 at 8:10 PM, George notifications@github.com wrote:

Has anyone tried this?

https://magento.com/blog/technical/set-your-magento-2- development-environment-faster

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/1726#issuecomment-274154023, or mute the thread https://github.com/notifications/unsubscribe-auth/AIK3rQr-MdIQCKNe5hYK-VV-3WGK-qWmks5rUQapgaJpZM4FwSXh .

george-vlahakis commented 7 years ago

Yeah. Have your code local in Win and map folders over to the VM or work completely within the VM if you feel comfortable with the *NIX tools.

All PHP dev is rather simple to manage in command line if you want too.

I don't know what DevBox does but I have Win10 and Mac so I might try in future.

george-vlahakis commented 7 years ago

Just tried it. Seems to be ok. Didn't dive into it too much though.

elbrodelche commented 7 years ago

I found this link that helped me a lot. It seems that you have to activate NFS on your docker machine in order to speed it up. http://andykdocs.de/development/Docker/Dockerize-Magento-2-on-Mac-OS

GBeushausen commented 7 years ago

Yeah sure, enable full page cache in development mode, use docker, buy a faster computer... In reality, we have to come to the conclusion, that Magento 2 is a piece of crap that's really really ill designed and should be abandoned as soon as possible. 1 minute page load time is insane. I've never seen a software this incredibly slow in my whole carreer.

Ctucker9233 commented 7 years ago

With people calling Magento 2 a piece of crap, it's no wonder the Magento team isn't motivated to fix it quickly. We impatiently gripe about how they don't release versions fast enough and then we yell at them for it having bugs. This is the nature of development today. The fact is it is nearly impossible to create or patch such a complicated piece of software quickly without any bugs. If developers want to create a perfect piece of software it will usually take years, during which investors will become impatient enough and want to pull out. The software company is therefore forced to release something to not lose that investment. It doesn't get any easier after the software has been released. It does seem like Magento is increasing their efforts to fix bugs judging by the number of pull requests that have been accepted and merged in recent months.

GBeushausen commented 7 years ago

What kind of logic is this? I've hurt their feelings, so they won't fix their bugs anymore? I never knew Magento was made by Kindergarten kids.

The slowliness of Magento 2 is not a bug that can be fixed. It's a design issue, becaue they've used Zend Framework 2 and because it's over engineered (both ZF2 and Magento 2).

Zend Framework 1 (which Magento 1 was based on) was able to do like 50 Requests per second. Zend Framework 2 does not even reach 1 requests per second. It's below that. add the over engineered complexety of Magento 2 to it and then you know, why a request takes at least a minute, with even 22 minutes not being seldom.

I remember a statement from Magento dev team a while ago, where they said, that for Magento 2 they would stick to use their own Zend Framework 1 based framework because ZF2 was just too slow.

I was really suprised when Magento 2 came out, that they re decided to use ZF2. Now we have the trouble of having our business based on Magento with huge customer bases which made incredible investments in this technology and all of a sudden we have a complete unusable piece of "software".

Ctucker9233 commented 7 years ago

@GBeushausen ZF1 is at end of life and it has been since September (announced in June) of last year. It doesn't make sense, in the long run, to stick with a framework that will get more and more obsolete. Perhaps this is what Magento decided as well. Who knows? Since ZF2 is slow, perhaps we should push for Magento to adopt ZF3 which seems to have an increased level of performance.

Also, I wasn't talking about you specifically. It has been the general tone of the community in the past. I'm sure they've got a thicker skin than you suggest. If someone called something you made a piece of crap, you wouldn't be strongly motivated to improve it either. Or maybe you would be. At least I know I wouldn't be. I'm not happy about the bugs either, but I'm trying to understand where Magento is coming from. Could they have done it better? Absolutely! But now, we are where we are. It's frustrating for sure, but they do seem to be attempting to improve. So I'm willing to wait and see where it goes.

GBeushausen commented 7 years ago

Of course everyone is upset. This is not a music player you use at home, where you can switch temporarily to another one if the one you used to like has too much bugs and wait till they're fixed.

If you're in the eCommerce business and you have spent uncountable time in training and gaining expertise in Magento and you convinced hundrets of customers, that Magento is THE perfect solution and those customers have invested hundrets of thousands in their Magento shops and all of a sudden, you see Magento 2 is unusable in development stage, of course this gets you angry. Now you probably have to tell all those customers, that you where wrong and Magento is not the perfect solution. They have to port to other systems, if they want to stay in business, then why should they work with you and not with another company, that's specilized in another shop software?

Those are decisions about life or death in business. And this is totally, totally unacceptable for Magento to release this unstable and unusable software. They know that their software is the absolute slowest on the market. EVER. they know that and instead of making other decisions, like staying with Magento 1 longer and port Magento 2 to Silex or anything else they bring their own customers willingly into huge trouble.

I predict that Magento will loose it's market share. Same with Zend Framework 2. ZF1 was the absolute market leader in PHP frameworks, until version 2came out. Nowadays i don't know anybody who is using ZF other than the Magento team. Other projects who made the error of using ZF2 have long corrected their mistake and ported away from it (i.e. Spryker).

Ctucker9233 commented 7 years ago

@GBeushausen I get it.

plastikschnitzer commented 7 years ago

Hello, will there be performance improvements with Magento 2.2? Did someone take a look into the details?

orlangur commented 7 years ago

The slowliness of Magento 2 is not a bug that can be fixed. It's a design issue, because they've used Zend Framework 2 and because it's over engineered (both ZF2 and Magento 2).

@GBeushausen this statement shows you never profiled Magento 2 if you think ZF2 have any significant impact on overall performance.

will there be performance improvements with Magento 2.2? Did someone take a look into the details?

@plastikschnitzer yes. I just googled "magento 2.2 performance" and found a couple of blog posts.

GBeushausen commented 7 years ago

@orlangur Yes i bielieve that. Magento 2 is so over engineered, it could have written in C++ and would still be the slowest application on earth. But ZF2 is world known to be the slowest PHP Framework. https://systemsarchitect.net/2013/04/23/performance-benchmark-of-popular-php-frameworks/ That's why very few projects use it anymore.

orlangur commented 7 years ago

@GBeushausen it does not matter as Magento 2 is not built on top of ZF2 (just like Magento 1 is not built on top of ZF1). Just some ZF1/ZF2/Symfony components are used.

Benchmark from 2013, really? Magento 2 performance under PHP7 is quite decent while giving much more flexibility compared to Magento 1. Having less bugs and more features is much more important nowadays than abstract "speed".

Of course performance could be poor in some circumstances, like "when I have 1000 simples assigned to configurable, it's quite slow". Those are identified and eliminated with time but obviously all such scenarios could not be checked in advance.

GBeushausen commented 7 years ago

@orlangur From an abstract viewpoint, you might be right. My problem is, in development mode my site takes at least 40 seconds up to 2 minutes per page load in a clean new shop without any products. On a new iMac with the fastest SSD. Also on any type of server i get the same result. This is just totally insane. All i read is you just need to turn the cache on. But how can i develop a theme with cache on? I don't know. Magento 1 was just so much better than this...

plastikschnitzer commented 7 years ago

Well maybe this is unconventional but I develop themes in the production mode on a dedicated testing server with https and http/2, not on a local machine...and I tend to change bigger code blocks at once in order to make the waiting time for emptying cache and so on as short as possible. @orlangur yes I read about it but in the past I often read about performance improvements in release notes or blogpost and when I tested it on my side, I did not see any visible change which makes a "difference". Exception: PHP5.x -> PHP7 :+1:

GBeushausen commented 7 years ago

@plastikschnitzer OK, but you should never be forced to do that by a well designed application.

hostep commented 7 years ago

@GBeushausen: if you work on the frontend, please don't disable all caches, just disable the ones which are relevant, for example, only disable these if you work on the frontend:

If you only work on css/less, you probably don't need to disable any caches, maybe only the full_page, but I'm not very sure.

Please experiment with this, once you understand which ones you can leave enabled and which ones you need to disable, it will save you a huge amount of time for a little bit of time experimenting with this.

orlangur commented 7 years ago

My problem is, in development mode my site takes at least 40 seconds up to 2 minutes per page load in a clean new shop without any products. On a new iMac with the fastest SSD.

Is it under https://github.com/weprovide/valet-plus or some docker/vagrant/native PHP?

mokanfar commented 7 years ago

My only recommendation after looking for solutions other than developing with M2 on localhost is to create an expensive droplet, develop on it and when you are done make a snapshot, and destroy the droplet so you won't pay. It's a pain but it's the cheapest solution. Droplet snapshots are 5 cents per gigabyte monthly.

orlangur commented 7 years ago

looking for solutions other than developing with M2 on localhost

M2 is quite fine even in developer mode and all caches disabled under PHP7. So, if local environment is slow, it should be investigated and fixed. Usually it happens due to slow NFS/Samba file operations.

GBeushausen commented 7 years ago

@orlangur Why do you keep telling people that Magento 2 is not slow in development mode? This is not true, we already had this discussion months ago. The whole Internet is full of people complaining about how slow Magento 2 is. Page reload in Magento 2 takes 40 seconds, even on the fastest MAC SSD which does more than 1200 MB / sec.

orlangur commented 7 years ago

Page reload in Magento 2 takes 40 seconds, even on the fastest MAC SSD which does more than 1200 MB / sec.

This is not true, I'm using such MacBook as well. Try tuning your env maybe or https://github.com/weprovide/valet-plus, which I already mentioned.

GBeushausen commented 7 years ago

Sorry, but Magento 1 does run fine in any environment. It runs finde with all caches turned off using either Apache on localhost, VMWare, VirtualBox, Docker, NFS Volume even in Windows with XAMPP it works totally fine. But with Magento 2 the only option to get it to accaptable speed is using valet-plus? I think Magento 2 is just a huge ill designed software.

orlangur commented 7 years ago

It would be really nice if you raise such topic in Community Forums, it will bring more attention and collectively we = Community can investigate every such case and bring all recipes into some HOWTO.

Magento 2 is not supposed to be faster than Magento 1 in developer mode, it is much more flexible, contains much more PHP classes etc. Just that it should have pretty decent speed under PHP7 (while Magento 1 will be uberfast).

either Apache on localhost, VMWare, VirtualBox, Docker, NFS Volume even in Windows with XAMPP

On all such environments except Windows Magento 2 should work fine if they are configured properly. It is quite sensitive to filesystem operations, from my experience initial indexing of VM with Ubuntu under Windows mounted via Samba is quite a long process but then it works well.