-
-
Notifications
You must be signed in to change notification settings - Fork 986
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
session.touch
is called on every request when resave: false
#891
Comments
Hello, this is correct. Touching a session is the load of a session. Resave just controls saving the session data back to the store. Whenever a session is loaded from a store, it is touched. In order for a session not to be touched, it would be not loaded at all from the store. I hope that helps. As stated in the readme, the touch call signals that the session is active -- a request loading a session is session activity. |
Regarding specific actions of stores, that is something disconnected from the general signaling of this module; for example perhaps a store may not need to do something on a touch or it shouls throttle like in your example. Is there a specific reason why this cannot be implemented in the store? Is the API between this module suiable enough to implement in the store side some like this which is a store-specific concern or does that API need to be enhanced to provide additional information in the touch request? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Thank you. I just wrote the title to describe what I observed. The implementation of I'm not sure what to call it? |
It seems the question (so issue title) at hand is something along the lines of "how to reduce writes to the session storage" maybe? That's at least what it seems. Is there a specific reason why this cannot be implemented in the store? Is the API between this module suiable enough to implement in the store side some like this which is a store-specific concern or does that API need to be enhanced to provide additional information in the touch request? |
I believe the store protocol has enough info to skip the write. That was initially what I looked at but it occurred to me that this is much more generic and really applies to all stores. Consider these bizarre cases that happen now:
I do not suggest changing these behaviors by default because some may be relying on them. But I do suggest that there should be options to control them for those who would like to change how these odd cases work. I mention these because it shows that the current behavior of touch is not well defined. |
Yes, I can see that it could perhaps apply to more stores than one -- but a module published as a decorator would then make that work without adding it here or breaking the contract between this module and the store (that contact is either |
Shouldn't touch and resave have never been added? Those are also decisions that could be made by the store yet they are provided here. It seems odd to draw the line that adding features (selectable by consumers of this module) that control those touch and re-save are not a good fit but the feature itself is a good fit even though it contradicts the store having all the info. |
Hi @huntharo you are correct, and this is planned to be fixed in the next major version of this module. There is a big mess of options and behaviors in 1.x that makes it really hard to use. We are really trying to clean it up and continuing to pile on more and more behavior options is just the wrong directions we are trying to turn around the module for, which is why we are trying to really scrutinize these types of changes and really ask why it cannot be done in the store and to understand why that would be so we can make sure there is the right APIs here so the store can make all the decisions. |
Hi @dougwilson , thx for your support and maintaining this module!
I faced this problem on my dev environement (heroku) with the "mysql" session store. I can make some actions in my app, but i hit the hour request limit of free sql db releay fast. deep dive in query log shows my that on each single request 2 session queries are triggerd: even if there is no other query / updated needed. Maybe you are right and the store must handle this. But so it has to be done by each and every store owner. So i need some workaround here. :) |
Hi @ragesoft 👋 . In your example, the query you are showing is not part of the |
Hi @dougwilson, I have same issue now. Can we just skip |
There is a PR here: chill117/express-mysql-session#133 |
Description
[PR incoming with unit tests and implementation of option - default to no change from current behavior]
session.touch
is called on every request whenresave: false
is set.On in-memory stores such as connect-redis this has little impact other than additional traffic.
However, on disk-backed and/or globally replicated stores the costs can be significant, such as connect-dynamodb
Example Scenario with Costs - DynamoDB Store
DynamoDB Provisioned Capacity Pricing
$7,102
/ yearoriginalMaxAge
ExpiredoriginalMaxAge
$1,195
83%
vs Write on Every RequestBest cases for cost reduction
The text was updated successfully, but these errors were encountered: