Skip to content

Poor loading times on "first called pages" #2731

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

Closed
ci2014 opened this issue Dec 16, 2015 · 10 comments
Closed

Poor loading times on "first called pages" #2731

ci2014 opened this issue Dec 16, 2015 · 10 comments

Comments

@ci2014
Copy link

ci2014 commented Dec 16, 2015

Hello everyone,

I am experiencing poor loading times, usually 1-3 seconds, but also up to 25 seconds, with my magento 2 instance, when a page was not called before.

When i watch 'top', I can see, that the process is going up to 99 percent of CPU usage and shrinks down, when the page itself is loaded.

This seems to be a problem with the cache, because pages, which were called before, load immediately. I don't know about the possibilities to warm up the cache on CLI. I already used setup:static-content-deploy successfully.

The user rights are well configured.

I need to mention, that I don't use varnish. APCu and memcached are installed. I am using the latest Plesk Server, CentOS 6 and PHP 5.6.16.

I also don't want the shop to process the less files every time. Magento is in production mode and server-side less compilation is enabled. Please ignore this, if this is correct.

Thank you in advance.

Kind regards

Chris

@ahmadhattab
Copy link

Could you please enable the magento log and share it with us ...

@okobchenko
Copy link
Contributor

Hi, Chris.

Thank you for your question. In general issue or mis-configuration can be easily identified by response time:

  • Catalog with Page Cache will respond in 50-150ms
  • Catalog page without Page Cache (or in case it is not warmed up for certain page) lead to 400-1500ms depending on the page and environment
  • Catalog page without any cache activated or warned will respond in 2-4 seconds
  • In case of real time static content processing (themes fallback, less compilation, other deploy procedures) time can jump up to 20-30seconds

Please check that after deploying of static content you set correct mode MAGE_MODE production in your htaccess file (for apache) or nginx.conf (for nginx) as well as check permissions for pub directory (as deployed files can be just unavailable) as well as for var directory (so you are sure cache files are available)

@ci2014
Copy link
Author

ci2014 commented Dec 16, 2015

Thank you both for your replies.

@ahmadhattab Which log may I share with you. I know there are different log files in the var/log folder.
@okobchenko The pages, which are taking too long to load are mostly product pages. The catalog pages load faster than most product pages.

In my .htaccess file SetEnv MAGE_MODE xyz is commented out.

php bin/magento deploy:mode:show returns Current application mode: production

I have set the pub and var directory world readable for debugging this issue, but the problem stills exists.

By the way (might be important): Why does setting "Workflow type" (which is "Not available in production mode") to "Client Side less compilation" writing 'rel="stylesheet/less"' and the script tag for less.min.js and its config file into magentos source code? Workflow type is not available in production mode, so this should not happen.

Of course setting it to "Server Side less compilation" removes those, but in production mode, this option should do absolutely nothing. This might be an indicator for something being wrong with the production mode.

Thank you all in advance.

@okobchenko
Copy link
Contributor

I believe there is a mix of developer workflow tools and attempts to switch everything to production mode.

In order to switch M2 into most performant mode (also called "production", but not limited just by setting environment variable in htaccess or nginx.conf file) next steps should be done:

  • Activating of client side performance features (is not the reason of slow server response, but recommended)
  1. JS bundling
  2. JS minification
  3. CSS minification
  4. HTML minification
  • Running static content deployment tool (to avoid real time less compilation, themes fallback, etc)

php bin/magento setup:static-content:deploy

  • Running code compiler (to avoid real time configuration and code analysis)

php bin/magento setup:di:compile

  • Setting production mode

Set $MAGE_MODE production (nginx)
SetEnv MAGE_MODE production (apache)

  • Performing re-index of catalog

php bin/magento indexer:reindex

  • Cleaning cache to apply all settings

php bin/magento cache:clean
php bin/magento cache:flush

Please try this flow on your Magento instance, it should help.

@ci2014
Copy link
Author

ci2014 commented Dec 18, 2015

@okobchenko

Thank you for your advice. That steps are important for setting M2 into production mode.

I already ran those commands successfully.

It did not help. I still see following in my source code, which I believe is a part of the problem:

<link  rel="stylesheet/less" type="text/css"  media="all" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/mage/calendar.css" />
<link  rel="stylesheet/less" type="text/css"  media="all" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/css/styles-m.css" />
<link  rel="stylesheet/less" type="text/css"  media="screen and (min-width: 768px)" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/css/styles-l.css" />
<link  rel="stylesheet/less" type="text/css"  media="print" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/css/print.css" />
<link  rel="icon" type="image/x-icon" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/Magento_Theme/favicon.ico" />
<link  rel="shortcut icon" type="image/x-icon" href="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/Magento_Theme/favicon.ico" />
<script src="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/less/config.less.js"></script>
<script src="http://magento/pub/static/version1450286045/frontend/Magento/luma/de_DE/less/less.min.js"></script>

So, when I see those less entries, there still has to be a problem with the production mode.

@eug123
Copy link
Contributor

eug123 commented Dec 21, 2015

Hi,
Seems "browser compilation mode" still active.
Please try the following:

  • make sure "Front-end development workflow" is set to "server side less compilation"
  • Remove all /var/ folder contents
  • Remove all /pub/static/ folder contents
  • run php bin/magento setup:static-content:deploy

@ci2014
Copy link
Author

ci2014 commented Dec 29, 2015

Hi,

after all that work, still clicking some pages the first time, the CPU usage of apache goes up to 98.2 percent. I have tested it on several instances and the problem occurs on all of them.

The servers are t2.large instances on amazon ec2, so they are powerful enough to perform magento 2.

Edit: The Magento user is shop, and the web server group is apache.

Some folders are created as apache:apache

drwxrwx--- 3 apache apache 4096 29. Dez 21:46 frontend
drwxrwx--- 3 apache apache 4096 29. Dez 21:46 _requirejs

The other ones are as follows:
-rw-rw-r-- 1 shop apache 1104 28. Dez 18:02 cron.php
drwxrwsr-x 3 shop apache 4096 28. Dez 18:02 errors
-rw-rw-r-- 1 shop apache 2834 28. Dez 18:02 get.php
-rw-rw-r-- 1 shop apache 1240 28. Dez 18:02 index.php
drwxrwsr-x 9 shop apache 4096 28. Dez 19:46 media
drwxrwsr-x 3 shop apache 4096 28. Dez 18:02 opt
drwxr-x--- 4 shop apache 4096 29. Dez 21:46 static
-rw-rw-r-- 1 shop apache 429 28. Dez 18:02 static.php

Is this correct?

#groups shop
shop : shop apache

#groups apache
apache : apache shop

@nikolaevas
Copy link
Contributor

Hi there,

I have the similar problem. I'm trying to create new theme. But every time I reload the home page it is going to high CPU loading.

My Settings:
New theme has just one file:
_/app/design/frontend/Test/default/web/css/source/extend.less
Magento mode: developer
Front-end development workflow: Server-side less compilation
Grunt is installed and configured.

Activity monitor:

screen shot 2016-04-17 at 13 42 56

Chrome console:

screen shot 2016-04-17 at 14 30 27

And only after php bin/magento setup:static-content:deploy the page is loading fast:

Chrome console:

screen shot 2016-04-17 at 14 31 32

Do I need to deploy static content every time I change some css style if I develop new theme?

Thanks!

@vkorotun vkorotun removed the PS label Aug 4, 2016
@ghost
Copy link

ghost commented Aug 30, 2016

Hello All,

I have same issues ,and finding solution since last few days but not getting what's an issues.

@ci2014 you find solution let me know .

I had tried all possible solution as give by above.

Thanks !

@veloraven
Copy link
Contributor

I'm closing this issue as GitHub issue tracker is intended for technical issues only. Please refer to the Community Forums or the Magento Stack Exchange site for technical questions.
If you think it to be an issue which requires fix please create new GitHub issue following the Issue reporting guidelines: with steps to reproduce, actual result and expected result. Please, also identify which version of Magento you are running.

magento-engcom-team pushed a commit that referenced this issue Jun 21, 2018
### Stories
* [MAGETWO-91869](https://jira.corp.magento.com/browse/MAGETWO-91869) [Indexer optimizations][Base Implementation] Tables sharding / segmentation for price indexer
* [MAGETWO-64467](https://jira.corp.magento.com/browse/MAGETWO-64467) [Indexer optimizations] Tables sharding / segmentation for price indexer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants