I recently started developing on magento2 new extensions or customizations, and my first impression was a nightmare. I have to wait about 20-30s for every change I make? really?

I'm talking about development mode, I know that in production with cache enabled and other things the website can be smooth. But when I'm working with an extension or layout problem I need to be removing static files, clearing cache, etc.

My question is, how you all M2 developers work? because I don't believe you have to wait 20s-30s for refreshing the page...

My environment: My pc is "good" i5 with 8gb RAM. I need to work with Windows so I use vagrant:

  • Use of all 4 cores CPU
  • Use 5120MB of RAM
  • Ubuntu/trusty64 - Ubuntu 14.04
  • PHP Version 7.0.12-1+deb.sury.org~trusty+1
  • MariaDB - 10.1.18-MariaDB-1~trusty
  • Magento 2.1.2 is installed only with sampledata (no more modules are installed)
  • (Ask me if you wanna know sth more)

What is happenning exactly? Usually M2 responds okay, slow but okay, about 5-10s to load the pages, but sometimes (more usually than sometimes) it just stucks forever! sometimes is the first page and sometimes are the css,js,html files but always the problem is with TTFB.

I saw a problem going to setup wizard too... with angular.js these files lasts forever...

These 2 pictures are about navigating inside setup wizard.

http://imgur.com/Izoyuhj http://imgur.com/Vs5q8eT

Then another one navigating on frontend catalog: http://imgur.com/oXYC52D

What am I asking exactly? Is this normal? you guys work with this timing? I commented this with some colleagues and we just don't believe, I have to be working like this? I sometimes despair of waiting all the time watching the screen...

If someone asks me for show him a test, like creating a new product or something like that he just freaks out... Creating a new order, filling the fields and every field executes a js that lasts for 5-6s...

I don't know but I feel so bad developing with this stuff...

  • Haven't had the chance to play with magento 2: but id assume that most of the performance issues comes from your vagrant environment. Do you use virtualbox with vagrant or something else. Using multiple cores with virtualbox degrades performance. Do you run the magento from a shared folder on the vagrant > magento writes files back to the same share you get performance issues. – Olli Tyynelä Oct 18 '16 at 12:03
  • Also you also might be running out of memory on your system what leads to using swap on the host if you give the vagrant 5gigs. only increase the amount if you actually need it. – Olli Tyynelä Oct 18 '16 at 12:08
  • A big part of your problem is that you are on Windows. I was on Windows for years and it was super slow with vagrant/magento. This is because of the file synching mode, its not up to par with nfs. I started dual booting into Ubuntu desktop and my magento sites were very fast, then a while later I got a mac, which uses NFS, and it is also very fast. – Shawn Abramson Oct 18 '16 at 13:04
  • Yes, it's vagrant with virtualbox. Why using more cores have to degrade performance? I assume giving all resources to VM may be slow "my pc" but faster my VM... And the folder I'm using is /var/www (I tried to not use shared folder, it's only "linux" what is running now). How can I see what is failing? I can execute top, or commands like that.... but don't know how to interpret... – slayerbleast Oct 18 '16 at 13:08
  • @ShawnAbramson Yep... we suggested to install dual boot just to try it because as I said we don't believe M2 developers are working like I'm currently doing hehe... – slayerbleast Oct 18 '16 at 13:48

10 Answers 10

up vote 6 down vote accepted

I tried everything and the only thing it works is the virtual machine that provides bitnami. https://bitnami.com/stack/magento/virtual-machine

Seriously, I don't know what has this vm, but goes really fast. I tried creating my VM using a fresh installation of Ubuntu, CentOS, etc. But no works so fine like this VM.

  • I think the major difference to the spec of this VM is memcache? Which, on my Windows (On PHP 7 at least, is not possible) – MackieeE Dec 14 '17 at 18:00

disable CSS/JS merging and minifying:

Stores > Configuration > CSS Settings (Javascript Settings) > Merge CSS (Merge JS) > NO

Stores > Configuration > CSS Settings (Javascript Settings) > Minify CSS (Minify JS) > NO

Also see this guide on how to improve Magento 2 performance.

  • 1
    The default settings has already these values. And this does not affect so much... – slayerbleast Jan 17 '17 at 14:49
  • So would merging be useful on an online server? More overhead towards the processing and not downloading? – Mohammed Joraid Mar 2 at 13:04
  • Why would you disabled CSS/JS Merging and minifying, it's literally an option there to increase speed, this seems to me like shooting yourself in the foot – John May 22 at 7:21

Suggestions from Magento posted after this question was answered. Reading other answers I think this information could be a helpful addition

http://devdocs.magento.com/guides/v2.2/extension-dev-guide/build/optimal-dev-environment.html

Optimal Configuration

The following is a list of optimizations you can make on your local development machine

  • Magento recommends installing and using the latest supported version of PHP 7 to increase performance.
  • Replace your MySQL database with Percona.
  • Make sure you install and enable PHP OPcache.
  • Xdebug is off by default. Enable this feature only when you need it because it requires a lot of memory and degrades performance. The xdebug.max_nesting_level configuration needs to be set to 200 or greater for Magento. You can increase the memory available to PHP to get an increase in performance with Xdebug on.
  • If you need sample data, you can install it using composer or by cloning repositories.
  • To speed up front end development, turn off merging of CSS and JavaScript.
  • Make sure caching is turned on (this is the default behavior). Generally, only page cache and block cache should be turned off for development and turned back on when testing.
  • Opcache timestamp validation should always be on for development. Development is impossible with opcache on and revalidation off because any PHP modification would require a cache reset.
  • For me Opcache did the trick. Its loading quite fast now. – Amit Singh Jun 25 at 14:28
  • One other thing I've encountered is Xdebug can be enabled by default which also has a performance hit. Check /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini After changing I think you need to restart the container docker restart {web-container-name} – Ian at Xantek Aug 9 at 9:06

I found that developer mode disable everything - which was overkill. There's certain aspects I do wish to cache, such as translation. Thankfully in env.php you can still set which caches to use specifically:

'cache_types' => 
      array (
        'config' => 1,
        'layout' => 0,
        'block_html' => 0,
        'collections' => 1,
        'reflection' => 1,
        'db_ddl' => 0,
        'eav' => 1,
        'customer_notification' => 1,
        'target_rule' => 1,
        'full_page' => 0,
        'config_integration' => 1,
        'config_integration_api' => 1,
        'translate' => 1,
        'config_webservice' => 1,
        'compiled_config' => 1,
      ),

This was the above that I chose to cache whilst developing on the Checkout, as this was heavily front-end. I chose to not cache Layout; Blocks and Full page to see my changes.

Turn on your cache.

Go to <your magento 2 directory>/bin and run this command magento cache:enable.

Clean the cache when you edit the frontend to see what you've edited.

Go to <your magento 2 directory>/bin and run this command magento cache:clean.

My Reference

I'm new to magento 2 too. I hope someone has a way to make magento 2 fast even when the cache is disabled.

  • 1
    Don't know if this is a viable solution... Everywhere it says to disable cache on development mode... – slayerbleast Oct 18 '16 at 13:55
  • 6
    Of course if I enable cache, site will go faster... but every change I will have to clean the cache... still a waste of time I think... – slayerbleast Oct 18 '16 at 13:57

Just want's to share my personal experience, The solution i came up was to install Xampp with php version 7.0 as Magento is not fully compitable with higher version of Php. I tried Bitnami Image listed in answer but doesn't worked as i was expecting Xampp 7.0.23 Download Link

  • Really? With xampp is working fine? I tried so many times and it was terrible... What Magento version? Maybe they've fix some performance with this time. I'll try again. And why the Bitnami Image is not working as you expected? – slayerbleast Sep 25 '17 at 7:16
  • I have Magento 2.1 and Xampp 7.0 link added above, Comparing Bitnami image to Xampp 7.0 i found xampp easy and faster – user3127648 Sep 25 '17 at 11:35

Increasing PHP memory_limit in php.ini file will make good difference. However it won't make it very very smooth(Although it will save time).

The default value is 512M. On my local machine I set this at "-1"(unlimited) and it gives better loading time.

The recommended value is memory_limit=2G mentioned here.

Magento is heavy and needs high performance hardware like SSD to be smooth :(

  • memory_limit has no relation to performance whatsoever. It's obvious from the name of the directive. – Daniel V. Mar 15 '17 at 6:40
  • @DanielV. I was also wondering about that but then I found this: devdocs.magento.com/guides/v2.2/install-gde/prereq/… where it says 2G as recommended value – Binod Jan 8 at 12:34
  • 1
    Again, it is recommended for its own reasons. Which have absolutely no relation to performance. Memory limit is only there to not halt your system completely in case some PHP scripts (or in this case, Magento modules) end up eating all of the server RAM. There is absolutely no performance impact from setting the value too low or too high. It's simply preventive directive to make system more failsafe. And I'm surprised that folks blindly assume that giving more memory for it means performance is achieved through this directive. It's not and never will be. – Daniel V. Jan 8 at 22:08
  • Interesting point, Daniel. I did blindly assume that actually. How can we demonstrate this? Any pointers that you can guide me with so that I can experience this? – Binod Jan 9 at 6:42
  • Set it too low (e.g. 16MB which is surely not enough for M2) and the PHP will fail with fatal error. Install as many modules as you can and set it too high (e.g. 4GB) and things will run OK until you get few more site visitors which will surely cause your server to reach Out of Memory state. You don't need these experiments if you just read the docs for that directive. PHP runs in memory all the time. It doesn't swap to disk or do funny things like that. – Daniel V. Jan 9 at 11:49

If your having problems setting up on a Vagrant box, it will almost certainly be how your folders are shared. They should be shared over NFS.

After messing around with lots of different boxes, I realised that although I had set NFS in the config, it was not actually working and the standard VirtualBox sharing system was taking over.

I went back to basics and set up a simple LEMP box and installed this plugin:

https://github.com/Learnosity/vagrant-nfs_guest

Confirmed NFS was working and all was well.

Things that can make your Magento 2 setup fast on your local server or in general on any server enviroment.

  1. Minify JS and CSS
  2. Use a caching application like Redis or Memcached.
  3. Enable all the cache like block_html, layout, page_cache etc provided by Magento 2.
  4. Merge CSS and JS
  5. Enable flat products and categories.

Now when on the development enviroment flush only the needed cache instead of flushing the whole cache to prevent the whole rebuild of cache.

My Setup on Ubuntu 16.10 for frontend development for LESS edits:

  1. Set Developer mode:

    php bin/magento deploy:mode:set developer

  2. Enable all caches:

    php bin/magento c:enable

  3. Fronted Development Workflow set to Server side compilation

  4. After any changes in less files run

    grunt clean

(Last time I menage to start - grunt watch with live browsing and its great)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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