File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,25 @@ use std::{collections::HashMap, sync::Arc};
7
7
/// persistance, this session store is ephemeral and will be cleared
8
8
/// on server restart.
9
9
///
10
- /// # ***DO NOT USE THIS IN A PRODUCTION DEPLOYMENT.***
10
+ /// # ***READ THIS BEFORE USING IN A PRODUCTION DEPLOYMENT***
11
+ ///
12
+ /// Storing sessions only in memory brings the following problems:
13
+ ///
14
+ /// 1. All sessions must fit in available memory (important for high load services)
15
+ /// 2. Sessions stored in memory are cleared only if a client calls [MemoryStore::destroy_session] or [MemoryStore::clear_store].
16
+ /// If sessions are not cleaned up properly it might result in OOM
17
+ /// 3. All sessions will be lost on shutdown
18
+ /// 4. If the service is clustered particular session will be stored only on a single instance.
19
+ /// This might be solved by using load balancers with sticky sessions.
20
+ /// Unfortunately, this solution brings additional complexity especially if the connection is
21
+ /// using secure transport since the load balancer has to perform SSL termination to understand
22
+ /// where should it forward packets to
23
+ ///
24
+ /// Example crates providing alternative implementations:
25
+ /// - [async-sqlx-session](https://crates.io/crates/async-sqlx-session) postgres & sqlite
26
+ /// - [async-redis-session](https://crates.io/crates/async-redis-session)
27
+ /// - [async-mongodb-session](https://crates.io/crates/async-mongodb-session)
28
+ ///
11
29
#[ derive( Debug , Clone ) ]
12
30
pub struct MemoryStore {
13
31
inner : Arc < RwLock < HashMap < String , Session > > > ,
You can’t perform that action at this time.
0 commit comments