Pytigon applications scale horizontally — from a single-developer SQLite setup to a multi-server PostgreSQL cluster behind a load balancer, without changing application code.
The simplest path: give Pytigon more CPU, RAM, and faster disks. Pytigon benefits from:
.ihtml → .html compilationPytigon's stateless design (all state in the database and VFS) enables horizontal scaling:
[Load Balancer]
/ | \
[App 1] [App 2] [App 3]
\ | /
[PostgreSQL] [Redis]
Internet → Nginx (SSL termination, static files)
├─→ Gunicorn (WSGI: HTTP requests)
└─→ Daphne (ASGI: WebSockets)
↓
Django
↓
PostgreSQL + Redis
upstream pytigon_app {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
server {
listen 443 ssl;
server_name myapp.example.com;
location /static/ {
alias /var/www/pytigon/static/;
expires 30d;
}
location / {
proxy_pass http://pytigon_app;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ws/ {
proxy_pass http://pytigon_ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
CONN_MAX_AGE setting keeps database connections alive between requests.| Cache Type | Backend | Use For |
|---|---|---|
| Template cache | File/Memcached | Compiled .ihtml → .html |
| Query cache | Redis | Frequently accessed data |
| Session cache | Redis | User sessions (required for multi-server) |
| Static files | Nginx/CDN | CSS, JS, images |
For multi-server deployments, configure a dedicated task worker:
# settings_app.py
TASK_BACKEND = 'redis' # or 'rabbitmq'
TASK_WORKER_COUNT = 4
Tasks are distributed across workers using Redis as the message broker.