Principle #7: Port Binding
Goal: Make the app self-contained by having it listen on a specific port and handle incoming requests directly, without relying on an external web server to connect it to the outside world.
What It Means
- Self-contained: The application includes its own web server or networking layer.
- Port listening: The app binds to a port (e.g., 5000) and serves traffic directly.
- No dependency on external servers: You don't need Apache, Nginx, or IIS to run the app — though you can still place those in front for load balancing if desired.
- Easier deployment: The app can run anywhere as long as it can open a port.
Why It Matters
- Portability: Works in any environment without complex server setup.
- Consistency: The same application runs in development, staging, and production.
- Simplicity: No separate server configuration required.
- Integration: Easy to connect with load balancers or service discovery systems.
Example
A Python Flask app runs with:
python
app.run(host='0.0.0.0', port=5000)
Top comments (0)