cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.6 - any way to make Memcached work - Please Help!

Magento 2.4.6 - any way to make Memcached work - Please Help!

Is there any way to configure memcached to work on Magento for session storage. Let's say it works, and you can really see the difference, especially in the admin backend.

 

Everything works fine until, for example, when I open Catalog / Products and need to load 200+ products per page, problems arise there.

 

env.php:

'session' => [
'save' => 'memcached',
'save_path' => '127.0.0.1:11211'
],

 

First i got red box with text:

"A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later."

 

Browser console:

[Error] Failed to load resource: the server responded with a status of 500 ()
https://xxxxx.xx/xxxxxxxxxxx/mui/bookmark/save/key/aa0e91ea2ab9dc5b54161be5a9695013137eecb6ff5c3a215d9efb22f254f828/?isAjax=true


Var/report:

{"0":"Warning: SessionHandler::read(): Unable to clear session lock record in \/home\/customer\/www\/xxx\/public_html\/vendor\/magento\/framework\/Session\/SaveHandler\/Native.php on line 24","1":"#1 SessionHandler->read() called at [vendor\/magento\/framework\/Session\/SaveHandler\/Native.php:24]\n#2 Magento\\Framework\\Session\\SaveHandler\\Native->read() called at [vendor\/magento\/framework\/Session\/SaveHandler.php:212]\n#3 Magento\\Framework\\Session\\SaveHandler->callSafely() called at [vendor\/magento\/framework\/Session\/SaveHandler.php:125]\n#4 Magento\\Framework\\Session\\SaveHandler->read()\n#5 session_start() called at [vendor\/magento\/framework\/Session\/SessionManager.php:186]\n#6 Magento\\Framework\\Session\\SessionManager->start() called at [generated\/code\/Magento\/Backend\/Model\/Auth\/Session\/Interceptor.php:149]\n#7 Magento\\Backend\\Model\\Auth\\Session\\Interceptor->start() called at [vendor\/magento\/framework\/Session\/SessionManager.php:123]\n#8 Magento\\Framework\\Session\\SessionManager->__construct() called at [vendor\/magento\/module-backend\/Model\/Auth\/Session.php:105]\n#9 Magento\\Backend\\Model\\Auth\\Session->__construct() called at [generated\/code\/Magento\/Backend\/Model\/Auth\/Session\/Interceptor.php:14]\n#10 Magento\\Backend\\Model\\Auth\\Session\\Interceptor->__construct() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:121]\n#11 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->createObject() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:66]\n#12 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]\n#13 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:170]\n#14 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:276]\n#15 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->getResolvedArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:239]\n#16 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgumentsInRuntime() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:34]\n#17 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->_resolveArguments() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:59]\n#18 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]\n#19 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:170]\n#20 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:276]\n#21 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->getResolvedArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:239]\n#22 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgumentsInRuntime() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:34]\n#23 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->_resolveArguments() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:59]\n#24 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]\n#25 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:206]\n#26 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->parseArray() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:182]\n#27 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:276]\n#28 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->getResolvedArgument() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:239]\n#29 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->resolveArgumentsInRuntime() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:34]\n#30 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->_resolveArguments() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:59]\n#31 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]\n#32 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/App\/FrontController.php:109]\n#33 Magento\\Framework\\App\\FrontController->__construct() called at [generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php:14]\n#34 Magento\\Framework\\App\\FrontController\\Interceptor->__construct() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/AbstractFactory.php:121]\n#35 Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->createObject() called at [vendor\/magento\/framework\/ObjectManager\/Factory\/Dynamic\/Developer.php:66]\n#36 Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create() called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:70]\n#37 Magento\\Framework\\ObjectManager\\ObjectManager->get() called at [vendor\/magento\/framework\/App\/Http.php:115]\n#38 Magento\\Framework\\App\\Http->launch() called at [vendor\/magento\/framework\/App\/Bootstrap.php:264]\n#39 Magento\\Framework\\App\\Bootstrap->run() called at [pub\/index.php:30]\n","url":"\/admin_nxxi29\/mui\/bookmark\/save\/key\/aa0e91ea2ab9dc5b54161be5a9695013137eecb6ff5c3a215d9efb22f254f828\/?isAjax=true","script_name":"\/pub\/index.php","report_id":"2cd732cb68493b03475a72e06fe6f989c1248e988a1d2e3b489c96f5f5038795"}

 

Log/exception.log:

[2023-05-08T01:22:33.200842+00:00] main.CRITICAL: Exception: Warning: SessionHandler::read(): Unable to clear session lock record in /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler/Native.php on line 24 in /home/customer/www/xxx/public_html/vendor/magento/framework/App/ErrorHandler.php:62
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'SessionHandler:...', '/home/customer/...', 24)
#1 /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler/Native.php(24): SessionHandler->read('92098a0d28cfc95...')
#2 /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler.php(212): Magento\Framework\Session\SaveHandler\Native->read('92098a0d28cfc95...')
#3 /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler.php(125): Magento\Framework\Session\SaveHandler->callSafely('read', '92098a0d28cfc95...')
#4 [internal function]: Magento\Framework\Session\SaveHandler->read('92098a0d28cfc95...')
#5 /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SessionManager.php(186): session_start()
#6 /home/customer/www/xxx/public_html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(149): Magento\Framework\Session\SessionManager->start()
#7 /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SessionManager.php(123): Magento\Backend\Model\Auth\Session\Interceptor->start()
#8 /home/customer/www/xxx/public_html/vendor/magento/module-backend/Model/Auth/Session.php(105): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State))
#9 /home/customer/www/xxx/public_html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(14): Magento\Backend\Model\Auth\Session->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State), Object(Magento\Framework\Acl\Builder\Proxy), Object(Magento\Backend\Model\UrlInterface\Proxy), Object(Magento\Backend\App\Config), NULL)
#10 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Backend\Model\Auth\Session\Interceptor->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State), Object(Magento\Framework\Acl\Builder\Proxy), Object(Magento\Backend\Model\UrlInterface\Proxy), Object(Magento\Backend\App\Config), NULL)
#11 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Backend...', Array)
#12 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Backend...')
#13 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(170): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Backend...')
#14 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(276): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Backend...', NULL, 'authStorage', 'Magento\\Backend...')
#15 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(239): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('Magento\\Backend...', Array, Array)
#16 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Backend...', Array, Array)
#17 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Backend...', Array, Array)
#18 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Backend...')
#19 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(170): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Backend...')
#20 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(276): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Backend...', NULL, 'auth', 'Magento\\Backend...')
#21 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(239): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('Magento\\Backend...', Array, Array)
#22 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Backend...', Array, Array)
#23 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Backend...', Array, Array)
#24 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Backend...')
#25 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(206): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Backend...')
#26 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(182): Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray(Array)
#27 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(276): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, NULL, NULL, 'validators', 'RequestValidato...')
#28 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(239): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('RequestValidato...', Array, Array)
#29 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('RequestValidato...', Array, Array)
#30 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('RequestValidato...', Array, Array)
#31 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('RequestValidato...')
#32 /home/customer/www/xxx/public_html/vendor/magento/framework/App/FrontController.php(109): Magento\Framework\ObjectManager\ObjectManager->get('RequestValidato...')
#33 /home/customer/www/xxx/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(14): Magento\Framework\App\FrontController->__construct(Object(Magento\Framework\App\RouterList), Object(Magento\Framework\App\Response\Http\Interceptor), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
#34 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Framework\App\FrontController\Interceptor->__construct(Object(Magento\Framework\App\RouterList), Object(Magento\Framework\App\Response\Http\Interceptor), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
#35 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#36 /home/customer/www/xxx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#37 /home/customer/www/xxx/public_html/vendor/magento/framework/App/Http.php(115): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#38 /home/customer/www/xxx/public_html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#39 /home/customer/www/xxx/public_html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#40 {main} {"report_id":"2cd732cb68493b03475a72e06fe6f989c1248e988a1d2e3b489c96f5f5038795","exception":"[object] (Exception(code: 0): Warning: SessionHandler::read(): Unable to clear session lock record in /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler/Native.php on line 24 at /home/customer/www/xxx/public_html/vendor/magento/framework/App/ErrorHandler.php:62)"} []

 

Log/system.log:

[2023-05-08T01:22:33.197921+00:00] main.ERROR: Warning: SessionHandler::read(): Unable to clear session lock record in /home/customer/www/xxx/public_html/vendor/magento/framework/Session/SaveHandler/Native.php on line 24 [] []


Setup:

Magento CE 2.4.6,
4 CPUs, 
8 GB RAM, 
50 GB SSD

 

I beg you for help!!! Thank you in advance!!!

3 REPLIES 3

Re: Magento 2.4.6 - any way to make Memcached work - Please Help!

Hello @raul_baricevic 

 

Yes, it is possible to make Memcached work with Magento 2.4.6. Here are the steps you can follow:

  • Check if Memcached is installed and running on your server. You can do this by running the command systemctl status memcached. If it is not installed, you can install it using the command sudo apt-get install memcached.
  • Install the Memcached PHP extension by running the command sudo apt-get install php-memcached.
  • Configure Magento to use Memcached by updating the app/etc/env.php file with the following code:
    'cache' => [
            'frontend' => [
                'default' => [
                    'backend' => 'Magento\Framework\Cache\Backend\Memcached',
                    'backend_options' => [
                        'servers' => [
                            [
                                'host' => 'localhost',
                                'port' => '11211'
                            ]
                        ],
                        'compression' => false
                    ]
                ],
                'page_cache' => [
                    'backend' => 'Magento\Framework\Cache\Backend\Memcached',
                    'backend_options' => [
                        'servers' => [
                            [
                                'host' => 'localhost',
                                'port' => '11211'
                            ]
                        ],
                        'compression' => false
                    ]
                ]
            ]
        ]
  • Save the env.php file and clear Magento cache by running the command php bin/magento cache:clean.

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9

Re: Magento 2.4.6 - any way to make Memcached work - Please Help!

Thanks @johnwebdes40a5 ,

 

but I meant on the session, these are cache instructions. I tried to use memcached for the session according to the official documentation. it works, but occasionally throws the errors I put above. Do you have some advanced tutorital how to configure session to use memcached  ??

Re: Magento 2.4.6 - any way to make Memcached work - Please Help!

Hello @raul_baricevic 

 

1. First of all, check if Magento 2 Memcached is active. To do so, type the following command in the terminal:

  • ps aux | grep memcached

2. Configure Magento 2 Memcached

  • Magento 2 also supports Memcached for caching objects but it isn’t enabled by default. You need to make simple changes to the $Magento2Root/app/etc/env.php file to enable it. In env.php, you will see a large number of PHP arrays with different settings and configurations. Open the file in your favorite code editor and locate the following code:
'    array (
    session' =>
        'save' => 'files',
    ),
    Modify this chunk as:
    'session' =>
        array (
          'save' => 'memcached',
          'save_path' => '<memcache ip or host>:<memcache port>'
    ),

Note that the default value for memcache ip is 127.0.0.1:11211. Similarly, the default value for memcache port is 11211.

3. Magento 2 Memcached Configuration Verification

  • To verify that Magento 2 has been configured appropriately to use Memcached, run the following command in the terminal and delete the content of some directories under your Magento 2 installation:
    • rm -rf var/cache/* var/page_cache/* var/session/*
  • Open your Magento 2 store in a browser and start browsing different pages to see if some page breaks down.
  • Login to the admin panel as well to see if any error pops up. If so, it means Memcached has been configured with Magento 2 store, and it is working correctly.

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9