feat(deployment): support sse notification streaming

This commit is contained in:
2026-04-25 17:19:14 +03:30
parent 3b052aeca4
commit d3f14aeb78
2 changed files with 38 additions and 13 deletions

View File

@@ -31,3 +31,11 @@ docker compose up --build
``` ```
The backend container runs database migrations and `collectstatic` on startup, then serves Django with Gunicorn using `config.wsgi:application`. The backend container runs database migrations and `collectstatic` on startup, then serves Django with Gunicorn using `config.wsgi:application`.
## SSE Notifications
Notifications now use Server-Sent Events at `/api/notifications/stream/`.
- Nginx disables buffering and cacheing for the SSE endpoint.
- The current Gunicorn setup can serve SSE for MVP traffic, but each live stream consumes a worker while connected.
- If notification concurrency grows, move the SSE endpoint to an async worker class or a dedicated ASGI process.

View File

@@ -31,11 +31,27 @@ server {
} }
# Standard API Proxy # Standard API Proxy
location /api/notifications/stream/ {
proxy_pass http://backend:8000;
proxy_http_version 1.1;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
add_header X-Accel-Buffering no;
}
location /api/ { location /api/ {
proxy_pass http://backend:8000; proxy_pass http://backend:8000;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
} }
# Admin Panel Proxy # Admin Panel Proxy
@@ -44,6 +60,7 @@ server {
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
} }
# Frontend Proxy # Frontend Proxy