# Scaling & High Availability {#scaling--high-availability}


Scale Ever Gauzy for enterprise workloads with horizontal scaling and high availability.


## Architecture {#architecture}






```mermaid
graph TB
    LB[Load Balancer] --> API1[API Server 1]
    LB --> API2[API Server 2]
    LB --> API3[API Server N]
    API1 --> DB[(PostgreSQL Primary)]
    API2 --> DB
    API3 --> DB
    DB --> Replica[(Read Replica)]
    API1 --> Redis[(Redis Cluster)]
    API2 --> Redis
    API3 --> Redis
    API1 --> S3[(Object Storage)]
```






## Horizontal Scaling {#horizontal-scaling}



### API Servers {#api-servers}


Run multiple API server instances behind a load balancer:

```yaml
# docker-compose.yml
services:
  api:
    image: ghcr.io/ever-co/gauzy-api:latest
    deploy:
      replicas: 3
```


### Requirements for Multi-Instance {#requirements-for-multi-instance}


| Requirement           | Description                                 |
| --------------------- | ------------------------------------------- |
| Redis                 | Required for session storage and job queues |
| External file storage | Use S3/Wasabi instead of local storage      |
| Stateless API         | No in-memory state between requests         |
| Database pooling      | Use PgBouncer for connection pooling        |


## Database Scaling {#database-scaling}



### Read Replicas {#read-replicas}


Configure read replicas for read-heavy workloads:

```
DB_REPLICATION=true
DB_REPLICA_HOST=replica.db.host
```


### Connection Pooling {#connection-pooling}


Use PgBouncer for efficient connection management:

```ini
[databases]
gauzy = host=localhost dbname=gauzy

[pgbouncer]
pool_mode = transaction
max_client_conn = 1000
default_pool_size = 40
```


## Redis Clustering {#redis-clustering}


For high availability, use Redis Sentinel or Redis Cluster:

```
REDIS_HOST=sentinel-host
REDIS_PORT=26379
REDIS_SENTINEL_MASTER=mymaster
```


## Related Pages {#related-pages}


- [Production Deployment](https://sourcey-gauzy.pages.dev/devops/production-deployment/index.md) — initial setup
- [Monitoring](https://sourcey-gauzy.pages.dev/devops/monitoring/index.md) — production monitoring
