-
Notifications
You must be signed in to change notification settings - Fork 48
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
Additional Session Prefix #29
base: master
Are you sure you want to change the base?
Conversation
In big cloud environments, one Redis/keyDB instance used for many Magento installations. This prefix is necessary to properly manage sessions
Fix missing sessionId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already fixed
The non-use of the I strongly recommend against sharing one Redis instance between Magento instances. The problem is that with shared resources one instance could affect all of the other instances negatively, for example by exhausting available memory and causing evictions for other clients. Also, you will actually get better performance using one Redis instance per Magneto installation since Redis is single-threaded and the Magento instances are excellent and natural "sharding" points. With Docker it is so incredibly simple to setup additional redis servers. E.g. if using docker-compose:
Or if not yet using Docker you can still easily do it:
The overhead for running separate instances is so miniscule it is basically negligible (~2MB). Another advantage is you can set different memory limits for each instance and also easily move one dataset to a different server without affecting the others. Lastly, the longer your prefix the more memory your indexes will consume. |
You are right, but this parameter will be configurable if somebody doesn't want use he will not use it. We can't run docker Redis because we using AWS ELASTICCACHE and we need just this parameter logically separate sessions keys, we don't care about the performance of the session because it is jus single request per page and we need it for development environment - to have shared session for 1-20 development environments managed by aws elastic beanstalk. This code doesn't affect the existing user's performance. I can move this Const (SESSION_PREFIX and PREFIS_ADDITIONAL) to the class property (this->prefix) to avoid constant issues. |
I see, thanks for the additional info. A couple other thoughts:
If you change the constant back I'll consider merging it, but it still seems unnecessary to me. |
The problem is not random cookie, Session key it is not human-readable. |
Session constant removed. |
Get configurable prefix for session ID method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Py the way it doesn't work with Magento because the configuration doesn't work like the dataObject and it doesn't have this method getPrefix();
@@ -616,6 +624,8 @@ public function read($sessionId) | |||
*/ | |||
public function write($sessionId, $sessionData) | |||
{ | |||
$sessionId = 'sess_'.$this->_prefixAdditional.$sessionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding prefix as a configurable parameter this->config->getPrefix() with a default value 'sess_'
without getAdditionalPrefix()? Then if somebody wants override can override the default parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good as long as it is fully BC.
Use another ElastiCache instance? This promotes a bad practice IMO. |
Where you can see bad practices there? One instance per different keys is ok. Different instances produce price and management overhead. Especially if you are building something big like SaaS or Cloud one Redis is better 10. |
In big cloud environments, one Redis/keyDB instance used for many Magento installations. This prefix is necessary to properly manage sessions. Thank you for merging these changes