29

I used Magento 1.9 and it was okay.It wasnt as fast as a simple joomla site but i had many customers with no problem.

Now i wanted to upgrade my site to Magento 2,i bought a new host (same as i currently have) and installed Magento 2 without sample data and its a pain to use.Not just the admin,but the empty homepage as well take minutes to load and when i try to create an account i getting error that i "Resource Limit Is Reached"

I tried with Facebook FlashCache,OptimumCache and Cloudflare but nothing has changed even though the creators said Magento 2 is much faster than the first version.

I'd like to understand why they cant fix it after so many years and why so many people using it?

Is there any way fasten it up?

UPDATE:

I used mgt-commerce before and it was incredibly fast,took less than 2s to load but it cost too much: AWS Price + € 199.00

They offered php7 / HHVM , Varnish, Redis , CDN ,NGINX by default i guess thats why it was fast.

I had to buy Amazon WS account i don't know why i guess my site was actually hosted by Amazon.

Im looking for the same speed for a lower price. A VPS provider example.

I was looking around but found that every hosting provider claims they have Magento hosting. Siteground,Mochahost,Hostgator,Fastcomet etc.

Maybe there's a hosting provider who would install these caches to beat competitors.

PS: Sorry if my post seems to be silly for programmers i'd choosen economics,commerce and marketing at university unfortunately :(

  • Can you explain what have you tried with Facebook FlashCache, OptimumCache and Cloudflare please? – mbalparda Dec 28 '16 at 15:54
  • 1
    Looks like its environment issue. On my vm it's open cms/home page without FPC < 0.1s and with FPC < 0.01s – KAndy Dec 28 '16 at 16:09
  • disable css/js merging stores > configuration > advanced > developer see my comment here magento.stackexchange.com/questions/150073/… – Konstantin Gerasimov Dec 28 '16 at 18:18
  • 2
    I'm starting with M2 and very frustrated with it's performance as well. If your software requires a thousand caches to run for a single user, there's something wrong. I hope I change my mind soon. – Ricardo Martins May 23 '17 at 6:27
  • @KAndy can you write what vm do you use? If you use vagrant would it be possible to share the provisioning script? I tried several VMs but all of them didn't work. Magento installation is successful but then pages don't load. – Alan Jan 19 '18 at 17:25
23

There are multiple resources available to improve Magento 2 performance and all of them are pretty well documented.

Mode: Magento 2 has introduced modes, being the default one the slowest. Give the developer mode a try and always run your live store in production mode. More info here.

Cache: Varnish is supported out of the box, pretty easy to configure and use.

Redis: Redis is an optional backend cache solution to replace Zend_Cache_Backend_File, which is used in Magento 2 by default. It can be used for session storage and page caching.

Memcache: Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. In Magento 2 it can be used for sessions.

PHP 7: Magento 2 is compatible with PHP 7 out of the box. There is a lot of research on how PHP 7 affects performance for good.

This is just the start, you should be able to fine tune your webserver and database server but that will heavily depend on your particular use case.

If you don't know how to do that yourself, there are plenty of companies specialized in Magento hosting.

For a pretty solid dev environment my personal recommendation is Paliarush' Vagrant or the VM I got from Magento for the courses. There is an official docker image coming soon.

7

Magento runs reasonably well even in developer mode. It does need some initial configuration though.

First make sure Magento is set up correctly, assuming your on Ubuntu:

Use the latest build as Magento 2.2+ supports php 7.1 http://devdocs.magento.com/guides/v2.2/install-gde/prereq/php-ubuntu.html

sudo apt-get install php7.1 php7.1-imap php7.1-xml php7.1-dom php7.1-intl

If your running multiple php versions set 7.1 to the default via

sudo update-alternatives --set php /usr/bin/php7.1

Onto Magento

  1. Set to Developer if not already php -f bin/magento deploy:mode:show

    php -f bin/magento deploy:mode:set developer

  2. Check Magento's cache is enabled

    php -f bin/magento cache:status

If not enabled (series of 1's)

php -f bin/magento cache:enable

Enable JS/CSS bundling

Stores > Configuration > Advanced > Developer

*Note the above menu item only shows up whilst in developer mode

Template Setttings

  • Minify HTML = Yes

Javascript Settings

  • Merge JS files = Yes

  • Enable JS Bundling = Yes

  • Minify JS files = Yes

CSS Settings

  • Merge CSS = Yes
  • Minify CSS = Yes

Do a cache flush from here on in after every step flush the cache, this is your baseline for trying to improve the loading time.

php -f bin/magento cache:flush

Advanced bundling

This would be a post in itself follow guidelines from magento devdocs on how to enable this, this could further increase the frontend JS loading making it 3x as fast.

Use Redis

sudo apt-get update
sudo apt-get install build-essential tcl8.5
sudo apt-get install make
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cd utils/
sudo ./install_server.sh

Edit /www/project/app/etc/env.php

'cache' => 
  array (
    'frontend' => 
    array (
      'default' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'database' => '0',
          'port' => '6379',
        ),
      ),
      'page_cache' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'port' => '6379',
          'database' => '1',
          'compress_data' => '0',
        ),
      ),
    ),
  ),

Use PHP-FPM

apt-get install php7.1-fpm
a2enmod proxy_fcgi setenvif
a2enconf php7.1-fpm
sudo service php7.1-fpm restart
sudo service apache2 restart

Enable opcache in PHP

Edit /etc/php/7.1/apache2/php.ini find opcache.enable

opcache.enable=1

I would also recommend using a Cloud DB such as AWS RDS or other it will save you the headaches of configuring mysql.

If you now enable production mode php -f bin/magento deploy:mode:set production

you should find it's running reasonably well.

Taking it further from here you can add Varnish, Switch to Nginx add a CDN for static files.

2

I had this problem too on a Macbook Pro (late 2016) with MAMP.

What I wanted to do was to create a Magento 2 theme. I had deactivated all caches and it took like 30s to reload a page (frontend and backend).

I activated all caches with the command "php magento cache:enable" and the site loads very fast. I can still work with Grunt and LESS without deactivating any cache type.

1

Magento 2 is not slow by default. You have to follow these steps to make it fast:

  1. Server and System Requirements

  2. Update Magento Version

  3. Enable Varnish Cache

  4. Configure Memcached

  5. Enable Flat Categories and Products

  6. Optimize Javascript and CSS

  7. Content Delivery Network

  8. Use lightweight theme

  9. Bug-Free Extensions

  10. Images Should be Fully Optimized

  • 20
    I'm sorry, but if you have to add multiple levels of caching to an application, then it is slow by default. – Robert Egginton Apr 6 '17 at 7:53
  • Robert: Dude, adding cache to several layers of a multi layered system is the right kind of architecture. We're not talking cache upon cache... -o- – miracules Aug 28 '17 at 10:36
  • Using caches during development is not really an optimal solution. Clearing cache every time a change is made feels more like developing in compiled language, not PHP. – Alan Dec 21 '17 at 9:45
0

How do you figure Magento 2 is slow? My site which uses a very heavy theme scores a solid 93/100 in Page Speed and load times are 2 secs. I'd say get a better host for Magento because your web server plays a big part in the performance of your site. As for "default" mode being the slowest not true at all. I ran my store in default mode until I was ready to switch over to production mode and it scored a 91/100 in default mode and only went to a 93/100 after switching to production mode.

Get a better host and a better web server if you really want to use Magento 2.

  • After magento cache:disable the load time is over 30 seconds. – Tom Anderson Jul 31 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.