Refactor email sending for non-blocking performance and add request timing
• Dockerfile: bump Gunicorn workers to 4 for concurrent request handling • server.py: - Load SMTP credentials once at startup - Wrap send_confirmation_email in a daemon Thread for “fire-and-forget” delivery - Replace print() with structured app.logger.error() on failure - Add before_request/after_request hooks to log per-request durations - Use context manager for SMTP_SSL connections (auto-close) - Simplify route JSON responses and HTTP methods declarations - Retain existing DB logic but recommend low DB connect_timeouts - Ensure Flask binds on 0.0.0.0 in development These changes eliminate request blocking on email I/O, expose request latencies in logs, and improve overall concurrency.
This commit is contained in:
parent
af910a291a
commit
6bf6d15fbe
2 changed files with 90 additions and 51 deletions
|
|
@ -14,5 +14,4 @@ ENV FLASK_APP=server.py
|
|||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "server:app"]
|
||||
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "server:app"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue