Thanks for sharing On Saturday, August 6, 2022 at 4:56:41 AM UTC-6 Lisandro wrote:
> I'll try to answer my own question, in case it helps someone else. > Yes, you should run sessions2trash periodically, even if you're using > Redis and you're setting an expiration time for every session. > > As the documentation states: *"... when session_expiry is set [...] you > should ocassionally run sessions2trash.py just to clean the key holding the > set of all the sessions previously issued..."* > > In my deployment I have around 1000 applications running in one web2py > instance. All of them set session_expiry to 2 days. The load is very > stable: about 2 millon sessions in memory, using about 1gb of memory. > However, while the number of sessions stays stable in time, memory usage > increases slowly. I've found that running sessions2trash makes memory usage > to go down to 1gb. And yes, you have to run it once for every installed > app. I've inspected the source code of sessions2trash.py and I can't > realise what is it that it deletes (besides the expired sessions). > > It would be nice to have a script that only takes care of cleaning "the > other stuff", so it doesn't take too much time to run. Consider that > sessions2trash.py iterates over all the stored sessions, and if you're > using Redis and you're setting an expiration time for every session, it > doesn't make sense to iterate over all the dataset just to clean "that > other stuff". > > Hope it helps someone :) > > El martes, 26 de julio de 2022 a la(s) 08:40:04 UTC-3, Lisandro escribió: > >> Hey there! >> I'm using Redis to store sessions. Every session has an expiration time >> of two days. Should I still run sessions2trash.py from time to time? >> The answer is not clear to me. The documentation says: >> >> >> *If session_expiry is not set, sessions will be handled as usual, you'd >> need to cleanup sessions as usual once a while.* >> *However, when session_expiry is set will delete automatically sessions >> after n seconds (e.g. if set to 3600, session will expire exactly one hour >> later having been updated the last time), you should occasionally run >> sessions2trash.py just to clean the key holding the set of all the sessions >> previously issued.* >> >> If the answer is affirmative: >> - How frequently should I run sessions2trash.py? >> - If my web2py instance runs several applications, lets say, a thousand >> apps, will I have to run sessions2trash.py a thousand times, one time for >> each app? >> >> Thanks in advance! >> Warm regards, >> Lisandro >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/747a055c-4285-4134-ad5a-e696936747f7n%40googlegroups.com.