Skip to content

Commit b52ca1d

Browse files
committed
STATEFUL LAMBDA fixes
1 parent 6c67667 commit b52ca1d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

_posts/STATEFUL_LAMBDAS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const handler = async (event) => {
4242
};
4343
```
4444

45-
and then we'll invoke that lambda, concurrently and repeatedly, multiple times a second and see how often each environment is reused by the same user.
45+
and then we'll invoke that lambda, concurrently and repeatedly, multiple times and see how often each environment is reused by the same user.
4646

4747
```javascript
4848
const call = async (startTime) => {
@@ -85,14 +85,14 @@ const call = async (startTime) => {
8585
})();
8686
```
8787

88-
Depending on the number of concurrent imitated users and the sleep time between requests the session based hit rates differed. In a sample ran with 10 users and 1 second between each request the hit rates were ```rates: 0.63,0.38,0.41,0.45,0.47,0.26,0.46,0.42,0.43,0.36```. Pretty good if each hit means we are saving 1 call to DynamoDB or S3.
88+
Depending on the number of concurrent imitated users and the sleep time between requests the session based hit rates differed. In a sample ran with 10 users and up to 1 second between each request the hit rates were ```rates: 0.63,0.38,0.41,0.45,0.47,0.26,0.46,0.42,0.43,0.36```. Pretty good if each hit means we are saving 1 call to DynamoDB or S3.
8989

90-
In systems I've worked on we've seen in-memory session cache hit rates of close to 90%. However, your milage will vary based on user activity patterns and your exact cache usage, as with most performance enhancements it's good to measure before and after to see if the extra computation is worth it!
90+
In systems I've worked on we've seen in-memory session cache hit rates as high as 90%. However, your milage will vary based on user activity patterns and your exact cache usage, as with most performance enhancements it's good to measure before and after to see if the extra computation is worth it!
9191

9292
# Notes
9393

9494
<b id="f1">[1]</b> Caches aren't the only upside of AWS reusing environments. You can also reactively or preemptively perform work.
9595

9696
For example if you want to perform post request user analytics (say enriching the logs with what country/state a user is from), you can queue that up to be done during the next request (just be careful of orphaned threads!).
9797

98-
Other common idea is to preemptively establish persistent connections to your databases/external services.
98+
Another common idea is to preemptively establish persistent connections to your databases/external services. [](#a1)

0 commit comments

Comments
 (0)