---
title: "Discussion on \"Day 15: Supercharging My Flask App with NGINX Load Balancing and Docker Compose Cleanup\" | Hashnode"
description: "Discussion on \"Day 15: Supercharging My Flask App with NGINX Load Balancing and Docker Compose Cleanup\". I’m diving into an exciting session: enhancing my Flask + Redis app with NGINX as a load balancer, removing direct ports for security, and mastering Docker Compose environment cleanup and resource management.\nThe Mission: Why Day 15 Rocks\nAfter two w..."
url: "https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Day 15: Supercharging My Flask App with NGINX Load Balancing and Docker Compose Cleanup](https://grokguru.hashnode.dev/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup?utm_source=hashnode&utm_medium=feed)

I’m diving into an exciting session: enhancing my Flask + Redis app with NGINX as a load balancer, removing direct ports for security, and mastering Docker Compose environment cleanup and resource management. The Mission: Why Day 15 Rocks After two w...

Jun 10, 2025 · 6 min read · grokguru.hashnode.dev  
Read the article

-   [#cleanup](https://hashnode.com/tag/cleanup)

## Written by

[Usman Jap](https://hashnode.com/@usmanjap)

@usmanjap

  
[View profile](https://hashnode.com/@usmanjap)

life is to experience...

## Responses 1

Markdown supported · ⌘↵ to post

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 4](https://hashnode.com/posts/day-15-supercharging-my-flask-app-with-nginx-load-balancing-and-docker-compose-cleanup/6847eb82c19933b2f7df7bdb/comment/6aebb29644bbf5baf912ad86)

Putting nginx in front and dropping published app ports is the right security move — the piece that usually bites next is upstream health versus in-memory Flask sessions. Round-robin across replicas without a shared store (Redis or similar) looks like random logouts; either keep session state outside the workers or pin stickiness only where you must and document why.

On the proxy side I enable upstream keepalive with protocol 1.1 and an empty Connection header so sockets to the Flask containers actually reuse, and I keep max\_fails plus fail\_timeout modest so a crashed replica drops out quickly. After compose scale, hit each upstream by service name on the compose network, then through nginx, and compare Set-Cookie and latency — mismatches almost always mean a stale upstream block or a missing Host / X-Forwarded-Proto header, not the load-balancing algorithm itself.
