Skip to content

Commit 9784faa

Browse files
committed
feat(infra): self-host Redis on spoonet, drop managed Redis Cloud
- redis:7-alpine container, 512mb maxmemory, allkeys-lru eviction - No persistence (cache rebuildable from Mongo) - Static IP 172.30.0.40 on spoonet - App depends_on redis healthy - Drops Redis Cloud free tier dependency - ~3-5ms latency win per cache lookup vs managed (network hop eliminated) - Survives VPS reboot via redis-data volume REDIS_URI on VPS swapped to redis://redis:6379/0 in .env.production. Old managed URL stays in .env.production.bak.* for emergency revert.
1 parent c448051 commit 9784faa

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

docker-compose.prod.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ services:
1313
--timeout-graceful-shutdown 30
1414
env_file:
1515
- .env.production
16+
depends_on:
17+
redis:
18+
condition: service_healthy
1619
healthcheck:
1720
test: ["CMD", "curl", "-fsS", "http://localhost:8000/health"]
1821
interval: 15s
@@ -31,6 +34,39 @@ services:
3134
max-file: "3"
3235
tag: "{{.Name}}"
3336

37+
redis:
38+
image: redis:7-alpine
39+
container_name: spoo_redis
40+
restart: always
41+
# 512MB cap (out of 8GB box). LRU evicts stale URL entries when full.
42+
# No persistence — cache is rebuildable from Mongo. RDB/AOF disabled to
43+
# avoid disk I/O cost. Lose-cache-on-restart is acceptable.
44+
command: >
45+
redis-server
46+
--maxmemory 512mb
47+
--maxmemory-policy allkeys-lru
48+
--save ""
49+
--appendonly no
50+
--tcp-keepalive 60
51+
--timeout 300
52+
volumes:
53+
- redis-data:/data
54+
healthcheck:
55+
test: ["CMD", "redis-cli", "ping"]
56+
interval: 10s
57+
timeout: 3s
58+
retries: 5
59+
start_period: 5s
60+
mem_limit: 768m
61+
networks:
62+
spoonet:
63+
ipv4_address: 172.30.0.40
64+
logging:
65+
driver: json-file
66+
options:
67+
max-size: "5m"
68+
max-file: "2"
69+
3470
cloudflared:
3571
image: cloudflare/cloudflared:latest
3672
container_name: spoo_tunnel
@@ -76,6 +112,9 @@ services:
76112
max-size: "5m"
77113
max-file: "2"
78114

115+
volumes:
116+
redis-data:
117+
79118
networks:
80119
spoonet:
81120
driver: bridge

0 commit comments

Comments
 (0)