fix: reduce memory usage for monthly ZIP archive flow

Replace generated archive download response with FileResponse streaming so ZIP files are not fully loaded into process memory.

Move monthly archive task output to a temporary file and upload that file to storage, and write invoice attachments into ZIP archives in chunks.

Add Celery memory guard settings, a memory-aware base task hook, and periodic /tmp cleanup for prefixed archive files older than one day.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mariomitte
2026-09-05 08:15:30 +02:00
parent b985c285f9
commit 61bc772054
6 changed files with 260 additions and 52 deletions

View File

@@ -37,7 +37,13 @@ services:
environment:
DEBUG: "False"
DJANGO_SETTINGS_MODULE: core.settings.production
command: celery -A core worker --loglevel=info
CELERY_WORKER_PREFETCH_MULTIPLIER: "1"
CELERY_WORKER_MAX_TASKS_PER_CHILD: "20"
CELERY_WORKER_MAX_MEMORY_PER_CHILD: "350000"
APP_TMP_CLEANUP_DIR: "/tmp"
APP_TMP_CLEANUP_MAX_AGE_HOURS: "24"
APP_TMP_CLEANUP_PREFIXES: "erp-fleet-archive-"
command: celery -A core worker --loglevel=info --concurrency=${CELERY_WORKER_CONCURRENCY:-2}
volumes:
- media_volume:/app/media
depends_on: