Application Server Infrastructure¶
To ensure Socon-MKT remains highly available, secure, and capable of handling concurrent user traffic, the production environment utilizes a robust, multi-layered application server architecture.
While local development environments use lightweight built-in servers, the live production platform relies on an enterprise-grade combination of Gunicorn and Nginx.
1. The Role of Gunicorn¶
Socon-MKT uses Gunicorn as its primary WSGI (Web Server Gateway Interface) HTTP server to power the Python backend.
- Concurrency: Gunicorn acts as the robust interface between the web server and the Django application. It manages dedicated worker processes to handle simultaneous client API requests efficiently without bottlenecking.
- Process Management: The Gunicorn service is strictly managed by the host operating system's internal daemon (systemd). This ensures that the application server runs continuously in the background and automatically recovers in the rare event of a system reboot or failure.
2. Web Server & Reverse Proxy (Nginx)¶
Operating directly in front of Gunicorn is Nginx, an industry-standard, high-performance web server acting as a reverse proxy.
- Traffic Routing: Nginx receives all incoming HTTP/HTTPS requests from the Cloudflare edge network. It smartly routes dynamic API calls to the Gunicorn workers while independently handling other tasks to maximize performance.
- Security Isolation: By acting as a proxy, Nginx masks the internal application ports. The Gunicorn application server is never directly exposed to the public internet, adding a critical layer of infrastructure security.
3. Application State & Deployment¶
During the deployment cycle, the backend undergoes automated preparation to ensure the platform operates smoothly before interacting with user traffic:
- Database Synchronization: The application's data models (migrations) are securely synced with the PostgreSQL database to ensure data integrity for all active features.
- Static Asset Delivery: All foundational platform assets (stylesheets, scripts, and interface elements) are securely collected and compressed. This allows Nginx and the Cloudflare CDN to deliver the user interface globally with minimal latency.