Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2 running very slow on local envirement #2999

Closed
kuldeepdaffodil opened this issue Jan 15, 2016 · 35 comments
Closed

Magento 2 running very slow on local envirement #2999

kuldeepdaffodil opened this issue Jan 15, 2016 · 35 comments
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@kuldeepdaffodil
Copy link

Hi

I am using magento 2 and found admin , frontend loading is very slow after disable cache . Additionally jQuery is not working in default luma theme for custom features .

@ezequielalba
Copy link

Got the same issue, installed a VM with kubuntu for work, and it is too slow, disabled cache of magento 2 as well.

@mrtuvn
Copy link
Contributor

mrtuvn commented Jan 15, 2016

For linux enviroment i think it work faster than in window. Try to use minify js css or merge theme to one line for better performance. You should try varnish for cache instead default

@acharrex
Copy link

Magento MUST be fast!

At the moment, it is just impossible to develop on Magento without keep caches enabled.

@alankent
Copy link

For now, using Grunt is the fastest UI development approach. If you google "grunt magento 2" multiple blog posts come up. There is also our documentation at http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-guide/css_quick_guide_mode.html#server-side-grunt if you have not seen it.

@alankent
Copy link

Reading back on this thread I am not sure if original question was for development vs production. I think some suggestions are good for development, other for production. Varnish is good for production. Grunt is best available for development if you are talking about CSS/Less etc.

@ezequielalba
Copy link

Ok, for theme customization, and for use of the CSS/Less the best way is by using Grunt? @alankent, i have a VM with a kubuntu ambient configured, so i have to install node.js too, if i follow the documentation of the devdocs.magento.com, am i right?

@alankent
Copy link

We try not to dictate tools for developers, but the answer to the most responsive "edit, test" cycle for CSS today that Magento provides is Grunt. If the community finds a better way, cool!

@ezequielalba
Copy link

thanks! @alankent

@kuldeepdaffodil
Copy link
Author

Hi All

I have create this issue for development environment. When We disabled cache and and doing changes then magento works very slow .

@aaronsturm
Copy link

I've noticed a few of these "slow" issues, so I'm unsure which to comment on. I'm using this one since it specifically says "local environment" since that best matches our situation.

I'm running Magento 2 using a local Docker VM with the memory set to 2048MB. Even with caching enabled, it would take several minutes to load the default homepage with a fresh install. Others on my team also tried with the same results.

I'm using the Docker Image from Chadrien as my base image. I changed the php.ini-developement values to:

  • always_populate_raw_post_data = -1
  • date.timezone = "America Los_Angeles"
  • memory_limit = 2048M

We're currently using AWS EC2 instances to bypass this using the same Docker configuration, but it isn't ideal. Let me know any information I can provide to help troubleshoot this. Thanks!

@alankent
Copy link

Could you do me a favor and try the alankent/gsd Docker image and time how long the home page takes to load. (I am more familiar with this image.) Then please let me know how many seconds it took to load and the hardware spec you are running on, thx!

@aaronsturm
Copy link

Thanks for your prompt reply @alankent! I used that image and it's significantly faster, or "normal speed". I don't see a Dockerfile on the Docker Hub page. Can you send it to me so I can compare? Thanks!

@alankent
Copy link

Interesting. My Dockefile is a bit of a hack job at present, and does things like preload Luma - good for play, not good for building a new site. I am travelling at present, so here are some snippets from the Dockerfile that I can get to you quickly as a point of comparison - I will try to make something cleaner if needed, but that will have to wait until after my current trip ends.

Oh, and have you tried https://github.com/mageinferno/ ? That might be your easiest solution.

Oh, and check XDEBUG is off - that slows things down a lot.

I have not tested (sneaking a few mins in), but here are the relevant bits I think from my Dockerfile.

Dockerfile

FROM php:7.0-apache
MAINTAINER Alan Kent <alan.james.kent@gmail.com>

RUN apt-get update \
 && apt-get install -y libfreetype6-dev libicu-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev libxslt1-dev \
 && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
 && docker-php-ext-install gd intl mbstring mcrypt pdo_mysql xsl zip
RUN apt-get update \
 && apt-get install -y vim git curl net-tools telnet sudo cron \
 && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
 && a2enmod rewrite

# Expand default memory limit.
COPY php.ini /usr/local/etc/php/

# MySQL / MariaDB (I used MariaDB because apt-get indicated MySQL
# was no longer available).

# Add the Apache virtual host file
ADD apache_default_vhost /etc/apache2/sites-enabled/magento.conf

# Load the sample database
ADD magento2-install.sh /usr/local/bin

# Overwrite apache config file to use /magento2 instead of /var/www/html
ADD apache2.conf /etc/apache2/apache2.conf

# Make sure XDEBUG is not enabled - that slows things down by factor of 3 or more.

php.ihi

memory_limit = 2048M

apache_default_vhost

<VirtualHost *:80>

  DocumentRoot /magento2

  <Directory /magento2>
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

magento2-install.sh

#!/bin/bash

set -x

cd /magento2

# Install Magento and load sample data.
bin/magento setup:install --backend-frontname=admin \
    --cleanup-database --db-host=127.0.0.1 \
    --db-name=magento --db-user=magento --db-password=magento \
    --admin-firstname=Magento --admin-lastname=User \
    --admin-email=user@example.com \
    --admin-user=admin --admin-password=admin123 --language=en_US \
    --currency=USD --timezone=America/Chicago --use-rewrites=1 \
    --use-sample-data

# Trigger index rebuilds to make sure everything is ready before
# web server starts (reduces warnings in admin UI about indexes not
# being up to date)
bin/magento cron:run
bin/magento cron:run

# Deploy static view assets to make the start up phase faster.
bin/magento setup:static-content:deploy

# Set developer mode
bin/magento deploy:mode:set developer

# Above commands result in 'localhost' being in cached files - clear
# the cache to lose that setting.
rm -rf var/cache

apache2.conf (I think I just took default one and changed home directory to /magento2, so probably don't need this.)

# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
# (Modified to use /magento2 instead of /var/www/html)

Mutex file:/var/lock/apache2 default
PidFile /var/run/apache2/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User magento
Group magento
HostnameLookups Off
ErrorLog /proc/self/fd/2
LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# ports.conf
Listen 80
<IfModule ssl_module>
    Listen 443
</IfModule>
<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /magento2>
    AllowOverride All
    Require all granted
</Directory>

DocumentRoot /magento2

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\ "" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog /proc/self/fd/1 combined

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

# Multiple DirectoryIndex directives within the same context will add
# to the list of resources to look for rather than replace
# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
DirectoryIndex disabled
DirectoryIndex index.php index.html

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

@aaronsturm
Copy link

Thanks again @alankent for your prompt reply! The two major differences are the PHP version and database. I'll go through yours and Mage Inferno to see if anything stands out and let you know.

@aaronsturm
Copy link

@alankent - After some testing, I found out that if I leave the Magento files in the container, and then only mount the folders I need from my machine, I can get it down to 18 seconds vs 5+ minutes. It's still not ideal, but way better than it was. Before I had the Magento files on my machine. I hope that makes sense. If you have any additional suggestions, do let me know! Thanks!

@alankent
Copy link

alankent commented Apr 8, 2016

@aaronsturm Yes, its the "vboxfs" in Virtual box that is a dog. I mount a subset like you say (but it rules out grunt/gulp file watching), or use fswatch/WinSCP-keep-up-to-date to copy inside the container, or more recently NFS/CIFS mount the drive via Samba (latest variation). http://alankent.me/gsd lists a few options I have tried.

@aaronsturm
Copy link

Ok, I'll look into those. I didn't have these issues with Magento 1. I know it's different, just letting you know for a comparison.

@alankent
Copy link

alankent commented Apr 8, 2016

I suspect (I should go measure it) that M2 has more smaller files. Larger coarse grain files made it hard to decouple modules, which in turn makes upgrades a bigger effort in M1. That is where extension conflicts etc come from. M2 with one module per package sometimes means you have to get configuration from lots of locations on disk during development (we merge the smaller files in production mode for speed). Thus M2 is impacted more during development by the slow vboxfs file system. (This is an educated theory by the way, I have not actually measured it.) Lots of people on lots of projects have complained about vboxfs performance, but Oracle has not fixed it in the free Virtual box product to date.

@aaronsturm
Copy link

👍 That makes sense, and I appreciate your educated theory. Hopefully with the upcoming native Docker client this won't be an issue any more (no more VirtualBox!). I'm going to call this "fixed" on my end.

@refaelgold
Copy link

@alankent do you believe its a good idea to use gulp instead grunt on M2?

@alankent
Copy link

Both work, but gulp appears to be a bit faster (at the moment - I heard Grunt was adding support for pipelines as well which may catch up with Gulp).

@dweirich
Copy link

I am having long load times on development as well (page load times from 30s - 1min) running locally on OSX. I'm not sure why, but stopping the event clean_cache_by_tags from firing on any given page decreased the page load time to 5s on average. This is with all caches disabled.

@theskillwithin
Copy link

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.

@theskillwithin
Copy link

@alankent I'm sorry did you mention a solution for this yet? Should I be using docker instead of vagrant? I am on OSX btw. and yes already using gulp its php that is slow I think. I have everything at high settings. I am very excited for magento 2, and I am very happy that it is way more modern now in workflow however the frontend development is painfully slow, I spend days and get nothing done because I am still warming up to it but I am getting very worried I will not be able to complete any of the 5 magento 2 jobs we have on the books now.

http://kopy.io/qRttc

@kanadgodse
Copy link

Hi,
I have turned on PHP Opcache on my local Windows XAMPP conifg and can see a noticeable speed improvement.

Maybe you can try turning on PHP Opcache and see if it helps.

@Amilath
Copy link

Amilath commented Sep 16, 2016

how do you enable the Opcache. Sorry im new to this

@veloraven
Copy link
Contributor

I'm closing this ticket as the GitHub issue tracker is intended for technical issues only. And this one transformed to some kind of discussion. Please transfer the discussion to the Community Forums.

If you have any specific issues please create a new ticket formatting it according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.

If you have any questions which do not relate to some kind of issue in Magento, please refer to the Community Forums or the Magento Stack Exchange site for technical questions.

@springimport
Copy link

Partial disable cache.

0cd11-clip-96kb

https://toster.ru/q/357427?e=4400522#comment_1193422

@theskillwithin
Copy link

@springimport ?

@springimport
Copy link

@theskillwithin it helped me.

@suthanalley
Copy link

Magento 2 is not slow. Now you can make it fast following these steps.
Update Magento Version
Configure Memcached
Optimize Javascript and CSS
Use lightweight theme
Images Should be Fully Optimized
Server and System Requirements
Enable Varnish Cache
Enable Flat Categories and Products
Content Delivery Network
Bug-Free Extensions
You can also follow this guide https://magenticians.com/why-magento-2-is-slow/

@keithmifsud
Copy link

On this occasion I did not use Vagrant and the docker dev box is not available for download so I'm running magento in Xammp. I experienced a very slow website until I enable opcache which has improved the speed significantly. https://codingtrabla.blogspot.com/2016/06/xampp-5621-enable-opcache.html

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 19, 2017
@orlangur
Copy link
Contributor

XAMMP/WAMP must not be used at all as Windows OS is not supported and there are known issues. There are quite many options nowadays to have some Ubuntu VM for development with WIndows as a host OS only.

@franklin-vidal
Copy link

On windows i use Bitnami.

@orlangur
Copy link
Contributor

Same situation as #1726 (comment).

Such kind of issue, especially related to unsupported OS, are out of scope for this repo.

@magento magento locked and limited conversation to collaborators Oct 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests