Flask - Common Application Deployment Solutions

Introduction During development and debugging, Flask applications are typically run directly using app.run(). However, the built-in WSGI server in Flask is not known for high performance. For production environments, gunicorn is commonly used. For legacy projects that don’t require high performance and rely heavily on in-process shared variables, using gunicorn might affect inter-request communication, so you may consider using gevent directly. Before Docker became popular, Flask applications in production were typically deployed using virtualenv + gunicorn + supervisor. After Docker gained widespread adoption, the deployment approach shifted to gunicorn + Docker. Without container orchestration services, a reverse proxy like nginx is typically placed in front of the backend services. When using Kubernetes, services are typically exposed via Service + Ingress (or Istio, etc.). ...

February 14, 2026 · 12 min · Rainux He

Flask - Design and Implementation of tracking_id

Introduction In actual business scenarios, tracing the complete processing path of a request based on tracking_id is a common requirement. With the help of Flask’s built-in global object g and hook functions, it’s easy to add a tracking_id to each request and automatically log it. Main topics: How to add tracking_id to each request How to automatically log tracking_id How to customize response classes, implement unified response formats, and add tracking_id to response headers View function unit testing examples Gunicorn configuration Project Structure Although it appears complex, the implementation of tracking_id is actually quite simple. This article organizes the code according to production project standards, adding Gunicorn configuration and unit testing code, as well as standardizing log formats and JSON response formats. ...

January 17, 2026 · 10 min · Rainux He