PostgreSQL + Dragonfly
Stack Components
Section titled “Stack Components”PostgreSQL
Section titled “PostgreSQL”Full-featured relational database. Handles:
- Application data
- User authentication
- Complex queries with CTEs
- JSONB for flexible schemas
- Full-text search
Configuration
Section titled “Configuration”DB_CONNECTION=pgsqlDB_HOST=postgres-xxxxxDB_PORT=5432DB_DATABASE=appDB_USERNAME=postgresDB_PASSWORD=generatedAdvantages Over MySQL
Section titled “Advantages Over MySQL”| Feature | PostgreSQL | MySQL |
|---|---|---|
| JSONB performance | Native indexing | Limited |
| CTEs (WITH queries) | Full support | Basic |
| Window functions | Full support | Limited |
| Full-text search | Built-in | Plugin |
| Upserts | ON CONFLICT | REPLACE/INSERT IGNORE |
Dragonfly
Section titled “Dragonfly”Redis-compatible in-memory store. Drop-in replacement with better performance and lower memory usage.
Configuration
Section titled “Configuration”REDIS_HOST=dragonfly-xxxxxREDIS_PORT=6379REDIS_PASSWORD=generatedCACHE_STORE=redisSESSION_DRIVER=redisQUEUE_CONNECTION=redisDragonfly vs Redis
Section titled “Dragonfly vs Redis”| Metric | Dragonfly | Redis |
|---|---|---|
| Memory efficiency | 25% less | Baseline |
| Throughput | 25x higher | Baseline |
| Multi-threading | Native | Single-threaded |
| Protocol | Redis compatible | - |
Usage in Laravel
Section titled “Usage in Laravel”// CacheCache::put('key', $value, 3600);
// Sessions (automatic)// CSRF tokens, flash messages stored in Dragonfly
// Queuesdispatch(new ProcessOrder($order));
// Rate limitingRateLimiter::for('api', function ($request) { return Limit::perMinute(60)->by($request->ip());});Backup Strategy
Section titled “Backup Strategy”Coolify handles automatic backups for PostgreSQL databases. Dragonfly data is ephemeral (cache/sessions) and doesn’t require backup.