Skip to content

Commit ab49c4f

Browse files
committed
README updates
1 parent 99515fc commit ab49c4f

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Overview
22

3-
Partial, as of 2022-05-25, implementation of a DynamoDB-based session store for [express-session](https://www.npmjs.com/package/express-session), using the [AWS SDK for JS v3](https://github.com/aws/aws-sdk-js-v3).
3+
[DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html)-based session store for [express-session](https://www.npmjs.com/package/express-session), using the [AWS SDK for JS v3](https://github.com/aws/aws-sdk-js-v3), offering configurability for cost, performance, and reliability not found in other DynamoDB session stores.
4+
5+
DynamoDB is an excellent choice for session stores because it is a fully managed service that is highly available, durable, and can scale automatically (to nearly unlimited levels) to meet demand. DynamoDB reads will typically return in 1-3 ms if capacity is set correctly and the caller is located in the same region as the `Table`.
46

57
# Features
68

@@ -10,13 +12,56 @@ Partial, as of 2022-05-25, implementation of a DynamoDB-based session store for
1012
- This should only be used during PoCs, else tables will be created in any accounts that developers point at using credentials that have permissions to create tables
1113
- Cost reduction through reducing the TTL write on every read via `.touch()` calls from `express-session`
1214
- [This PR](https://github.com/expressjs/session/pull/892) for `express-session` would have made that a configurable option for every session store, but alas, it was rejected in favor of implementing the same thing 15+ times
13-
- These TTL writes consumed WCUs based on the size of the entire session, not just hte `expires` field
15+
- These TTL writes consumed WCUs based on the size of the entire session, not just the `expires` field
1416
- These writes were 10x more expensive than reads for under 1 KB session with ConsistentReads turned off
1517
- These writes were 40x more expensive than reads for 3-4 KB session with consistent reads turned off
1618
- Cost of 1 WCU is 5x that of 1 RCU
1719
- Eventually Consistent Read of 4 KB takes 0.5 RCU
1820
- Write of 1 KB takes 1 WCU, write of 4 KB takes 4 WCU
1921

22+
# Configuration Tips
23+
24+
- Use a Table per-region if you are deployed in multiple regions
25+
- Use a Table per-environment if you are deployed in multiple environments (e.g. dev/qa/prod)
26+
- Use a Table unique to the session store - do not try to overload other data into this Table as the scaling and expiration needs will not overlap well
27+
- For applications attached to a VPC (including Lambda's attached to a VPC), use a VPC Endpoint for DynamoDB to avoid the cost, latency, and additional reliability exposure of crossing NAT Gateway to reach DynamoDB
28+
- Use Provisioned Capacity with auto-scaling to avoid throttling and to achieve the lowest cost - On Demand seems nice but it is costly
29+
30+
# Example of Pricing
31+
32+
Disclaimer: perform your own pricing calculation, monitor your costs during and after initial launch, and setup cost alerts to avoid unexpected charges.
33+
34+
[Saved AWS Pricing Calculation](https://calculator.aws/#/estimate?id=fb2f0d461ab2acd6c98a107059f75a4325918bda)
35+
36+
## Assumptions
37+
- Using Provisioned Capacity with auto-scaling
38+
- Using Eventually Consistent Reads
39+
- 2 KB average session size
40+
- 100k RPM (requests per minute) average load
41+
- 1 million new sessions per month (~0.4 new sessions / second)
42+
- 8 million existing sessions
43+
- 2 million session updates / expirations per month (~0.8 updates / second)
44+
45+
## Pricing Calculation
46+
- Storage
47+
- 2 KB * 8 million = 16 GB of storage
48+
- 16 GB * $0.25 / GB / month = $4 / month for storage
49+
- Reads
50+
- 100k RPM / 60 seconds = ~1,700 RPS (requests per second)
51+
- 1 RCU (read capacity unit) per item * 0.5 (eventually consistent reads) = 0.5 RCU per read
52+
- 1,700 RPS * 0.5 RCU per read = 850 RCUs
53+
- 850 RCUs / read * 720 hours / month * $0.00013 / RCU / hour = ~$80 / month for reads
54+
- Writes
55+
- 0.4 new sessions / second + 0.8 updates / second = 1.2 WPS (writes per second)
56+
- 1.2 WPS * 2 WCU (write capacity unit) per item = 2.4 WCUs
57+
- Allocate more WCUs to handle bursts
58+
- 100 WCUs * 720 hours / month * $0.00065 / WCU / hour = ~$50 / month for writes
59+
- Total
60+
- $4 / month for storage
61+
- $80 / month for reads
62+
- $50 / month for writes
63+
- $134 / month total
64+
2065
# Running Examples
2166

2267
## [express](./examples/express)
@@ -91,5 +136,3 @@ Partial, as of 2022-05-25, implementation of a DynamoDB-based session store for
91136
```
92137

93138
<img width="1236" alt="image" src="https://github.com/pwrdrvr/connect-dynamodb-v3/assets/5617868/7815582a-c12a-49ec-83c0-323d76d441a6">
94-
95-

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"bugs": {
2424
"url": "https://github.com/pwrdrvr/dynamodb-session-store/issues"
2525
},
26-
"homepage": "https://github.com/pwrdrvr/dynamodb-session-store#readme",
27-
"private": true,
26+
"homepage": "https://pwrdrvr.github.io/dynamodb-session-store/",
2827
"scripts": {
2928
"build": "tsc --build tsconfig.json && echo 'examples/\n*.tsbuildinfo\n*.spec.*' > dist/.npmignore",
3029
"build:docs": "typedoc src/index.ts",

0 commit comments

Comments
 (0)