`session.touch` is called on every request when `resave: false`
See original GitHub issueDescription
[PR incoming with unit tests and implementation of option - default to no change from current behavior]
session.touch
is called on every request when resave: 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
- RCU = Read Capacity Unit
- WCU = Write Capacity Unit
- 60,000 RPM site / 60 seconds / minute = 1000 RPS
- Write on Every Request
- 1,000 RPS requires
- 1,000 RCU x $0.00013 = $0.13 / hour = $1,138 / year
- 1,000 WCU x $0.00065 = $0.65 / hour = $5,964 / year
- Total =
$7,102
/ year
- 1,000 RPS requires
- Write on Update or when 75% of
originalMaxAge
Expired- Assuming 1% of requests update the session or reach 75% of
originalMaxAge
- 1,000 RPS requires
- 1,000 RCU x $0.00013 = $0.13 / hour = $1,138 / year
- 10 WCU x $0.00065 = $0.0065 / hour = $57 / year
- Total =
$1,195
- Savings =
83%
vs Write on Every Request
- Assuming 1% of requests update the session or reach 75% of
Best cases for cost reduction
- Relatively longer sessions (e.g. minutes, hours, days, months, but not seconds)
- Session values infrequently updated
Issue Analytics
- State:
- Created a year ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
When to use saveUninitialized and resave in express-session
Uninitialised = false. It means that Your session is only Stored into your storage, when any of the Property is modified in req....
Read more >Disable touch on certain paths #287 - expressjs/session
Hi! No, this is not a bug, as this module will touch a session any time that session is loaded by design. Whenever...
Read more >Express session middleware
Forces a session that is “uninitialized” to be saved to the store. A session is uninitialized when it is new but not modified....
Read more >Connect - High quality middleware for node.js - Sencha Labs
Session #touch(). Updates the .maxAge property. Typically this is not necessary to call, as the session middleware does this for you.
Read more >express-session - Expert Data Visualization-5309
Forces a session that is "uninitialized" to be saved to the store. A session is uninitialized when it is new but not modified....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @ragesoft 👋 . In your example, the query you are showing is not part of the
resave
feature, but rather that your store module is updating the expires column on your data store every time the session is accessed. That may be what you want, maybe not. Ideally the store would need to add an option on it’s end to allow you to control that behavior. This module just sends a signal to the store module that the session was accessed; what the store decides is the more appropriate thing to do with that signal is left up to the store module. I hope that helps.There is a PR here: https://github.com/chill117/express-mysql-session/pull/133