Tool to clean up expired sessions gracefully
Project description
This is a Django management command (as in https://docs.djangoproject.com/en/dev/howto/custom-management-commands/) that cleans up expired sessions from the database.
Why?
Django ships with a built-in command to handle session cleanup, but it is problematic when dealing with large session tables. Due to its design, it can block writes to the session table for minutes at a time, potentially disrupting sites that rely on sessions. This command is designed to perform the same maintenance tasks as the built-in command without disrupting a site by locking the table for a really long time.
Installation
Install the distribution from PyPI, e.g. pip install django-batch-session-cleanup.
Then, add batch_sesion_cleanup to INSTALLED_APPS in your Django project.
That’s it. You can now run django-admin.py and confirm that the command shows up.
Example Uses
Delete expired sessions in batches of no more than 50000, and sleep for 2 seconds in between batches::
django-admin.py batch-session-cleanup --batch-size=50000 --sleep-time=2
Known Issues and Bugs
The tool has only been tested thoroughly on a MyISAM MySQL table. I’m not aware of any reason that it wouldn’t work on other SQL session backends, but you should be careful if you’re using it in those environments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-batch-session-cleanup-0.1.1.tar.gz
.
File metadata
- Download URL: django-batch-session-cleanup-0.1.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f566fc06803d5f3cd11ee2a59fbca7df39737bb40ad01ac0320f7a5e14140847 |
|
MD5 | 038d95ccfad2fc53280de2d381c5f1f8 |
|
BLAKE2b-256 | fb315e70068d769673457cd50c5465b77cdb5801559896447a5e1a323f162b38 |