Using Redis For Both Back End Cache And Sessions

I tried to use the recommended setting to use APCu for cache, and redis for sessions (using PHP 7 with multivendor 4.3.10). However, the store crawls and it takes about 2-3 seconds for a page to load. I switched to using redis for both and the page load time improved dramatically.

Now I have 2 questions

1. Has anyone encountered performance issues with APCu for cache and how was it fixed?

2. Any potential issue using Redis for both? I have a VPS with 4GB RAM.

Thanks in advance!

I can't talk about the performance because it is extremely difficult to measure the difference. I can tell you though there is a problem with Redis and it is causing my website to have session problems. They fixed Redis in next version but Redis 3.x and PHP 7 has problem.

Here is what I get in my error_log. I had to switch over to Database.

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user (path: app/Tygh/Web/Session.php on line 326

I had to switch back to PHP 5.6 because of this error but it is really problematic. PHP 7.0 is at least 30% faster than 5.6 and it makes a big difference.

Does anybody have this issue with their system?

Hi!

there is a problem with Redis and it is causing my website to have session problems.

Redis 3.x and PHP 7 has problem.

Can you please tell more details about the problem you've faced? Is it only fatal error or something else?

1. Has anyone encountered performance issues with APCu for cache and how was it fixed?

We, developers team, haven't. But this may be related to incorrect configuration of APCu, I mean shared memory limits.

Also, such problems require APCu cache hit/miss rate monitoring, there're a lot of one-file scripts on the internet that can be used for this purpose.

2. Any potential issue using Redis for both? I have a VPS with 4GB RAM.

It's all about Redis configuration.

Hi Alexander,

Please see these articles:

https://github.com/phpredis/phpredis/issues/818

https://github.com/phalcon/cphalcon/issues/12234

https://github.com/phpredis/phpredis/issues/658

It is very similar to these issues. It is random. I have 175 x 500 Server error message in my apache logs that means people got "Server Failed" message.

Redis just came up with 3.1.1 and I upgraded redis on our server so I'm hoping it will fix it at least for redis.

This is something that you must look at since all other people reported says something to do with how the code is handling sessions. It happens with PHP 7.0.x and I have php running as php-fpm.

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user (path: /www/home/public_html/) in /www/home/public_html/app/Tygh/Web/Session.php on line 326

I can report that even with Redis 3.1.1, the issue still persists. I still have tons of 500 Server error in my log file. I'm having to return back to PHP 5.6 which really sucks.

Can you please fix the problem with the code?

I can report that even with Redis 3.1.1, the issue still persists. I still have tons of 500 Server error in my log file. I'm having to return back to PHP 5.6 which really sucks.

Can you please fix the problem with the code?

I'd suggest downgrading to Redis 3.0.6 as this is the latest version known to be stable.

This is a PHP7 issue that causes various platforms/frameworks around the web to fail for certain saved sessions. The temp solution is to force strings even when FALSE is provided by PHP7. This issue thread talks about it, and the magento fix works for CS too: https://github.com/Inchoo/Inchoo_PHP7/issues/4#issuecomment-165618172

In app/Tygh/Session.php find "public static function read($sess_id)" and look for its return.

Change "return $data;" into "return (string)$data;" to enforce a string when returning session data.

It seems to have fixed it on our shops. Please let us know in this topic if it doesn't work or you still see it happening somewhere else.

Hi
Does anybody knows the fix? Has the similar problem, but login and chart is working for me and most users…

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user (path: /home/admin/tmp) in /home/admin/web/stencil-library.ru/public_html/app/Tygh/Web/Session.php on line 326

Line 326 says

session_regenerate_id(true);

I’ve got the trick as I see:

PHP Catchable fatal error: session_regenerate_id(): Failed to create(read) session ID: user (path: /home/admin/tmp) in /home/admin/web/stencil-library.ru/public_html/app/Tygh/Web/Session.php on line 326

326 - where the error occurs in in function session_regenerate_id() which gets not ID but Boolean FALSE.

read($sess_id) - this function generates FALSE if session does not exist. So we must change NOT the line 326 BUT the return of the function which read session ID.

In 4.3.6 is is app/Tygh/Web/Session.php line 676 in public function read($session_id)

Am I right?