0

I am using Magento 2.2.2 EE and getting slowest component from newrelic.

hange

env.php

  'session' => 
  array (
    'save' => 'files',
    'save_path' => '/var/lib/php7.0/session',
  ),

php.ini

session.save_handler = files
session.save_path = /var/lib/php7.0/session

If you guys have any Idea please share

Any help will be appreciated

  • 1900000 milliseconds = 1900 seconds = 31.66 minutes. Surely you would notice something like that? Any noticable issues with sessions on your website? – Dominic Xigen Jul 13 at 16:19
  • Hi @DominicXigen, I did't get anything related to this. Do you have any idea why this is happening ? – Chander Shekhar Jul 15 at 11:55
0

Make sure your sessions are being saved correctly. Check your session handler, magento_root/app/etc/env.php

 'session' =>
    array (
      'save' => 'files',
      'save_path' => '/var/www/session',
 ),

If you're using redis or memcached make sure you're able to connect.

netstat -ap | grep yourSessionHostPort
  • Hi @Hunter, I have updated my question. – Chander Shekhar Jul 17 at 8:01
  • @ChanderShekhar just to confirm, the path exists at /var/lib/php7.0/session and not /var/lib/php/7.0/session? – Hunter Jul 17 at 14:35
0

Enable store sessions in Redis https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-session.html or store sessions in memcache https://devdocs.magento.com/guides/v2.3/config-guide/redis/redis-session.html

In general you can't do much about it but to improve and optimize code. Like any other Magento 2 site you have a few extensions installed and a developer wrote modules for various features in the store. That code has to be improved. There are issues related to perfromance in vanilia Magent 2. If it's a kown issue/bug than you can apply patches.

Why would you need overall code performance improvements when you have a specific issue with PHP sessions ? What you see in New Relic is not the root cause. Most likely read speed on PHP sessions are fine. Most likely it's a PHP sessions lock issue. In Magento 2 when you load a page it doesn't do 1 request. It does a lot of requests:

  • 1 request for the html of the URL you access
  • 0 to many AJAX requests (section.xml / sections data)
  • in checkout page you have more AJAX requests
  • static resources requests
  • other ?

There are issues with PHP session lock because different requests used to render a page wait each other for read/writes operations on the same file/resouce (Redis case). There is a PHP setting to disable session lock (do not use it). You need PHP session locking to write safely the data in session files/resources.

Long story short: you have to improve the code in your store to run faster. If the code runs faster than the time while PHP session lock is in effect will be smaller. PHP session lock won't be a big issue.

Or maybe you can invest in a better server(s) to host the store on.

I had this issue: Magento 2.3.0 MSI isTableExists calls take too long It was a hosting/server issue and I had to change some code in Magento 2 vanilla to have the store load pages fast. I would start to search for code performance bottle necks. If you resolve most of them (which should be a couple or a several) than you will have a faster store. There is no specific fix.

  • Hi @obscure Thanks for your ans. I have checked <?php echo $block->getProductDetailsHtml($_product); ?> this is taking too much time. I think this is happening because I have (100+ , 150+, 200+) simple products with configurable product. Do you have any idea how can I optimize this without removing simple products from configurable. – Chander Shekhar Jul 23 at 11:08
  • Sorry, no. Look if you have redundant $product loads in the debug trace ($product->load()) – obscure Jul 23 at 11:26

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.