Commit b132c33
committed
Add Valkey distributed cache for horizontal scaling
Implement distributed caching using Valkey (Redis-compatible) to enable
horizontal scaling of Trino Gateway across multiple instances. This allows
query metadata to be shared between gateway instances, ensuring consistent
routing regardless of which instance receives a request.
Key features:
- 3-tier caching architecture: L1 (Guava local) → L2 (Valkey distributed) → L3 (PostgreSQL)
- Graceful degradation when Valkey unavailable (falls back to database)
- Configurable health checks and connection pooling
- Cache metrics (hits, misses, writes, errors, hit rate)
- Write-through caching for backend and routing group lookups
- Lazy-loading for external URL lookups
- Convention over Configuration with sensible defaults
Implementation:
- Add ValkeyConfiguration with 11 configurable parameters (minimal 3 required)
- Create DistributedCache interface and ValkeyDistributedCache implementation
- Integrate distributed cache into BaseRoutingManager routing logic
- Use modern Duration API (no deprecated methods)
- Add comprehensive input validation and error handling
- Include 31 unit tests (16 config + 15 cache tests)
Configuration:
valkeyConfiguration:
enabled: true
host: valkey.internal
port: 6379
password: ${VALKEY_PASSWORD}
Documentation includes:
- Quick start guide with minimal configuration
- Full configuration reference with tuning guidelines
- Deployment scenarios (single vs. multi-instance)
- Performance tuning recommendations
- Security best practices
- Architecture documentation and troubleshooting
Single-instance deployments don't need distributed caching - local Guava
cache is sufficient. Multi-instance deployments benefit from shared cache
for consistent query routing.1 parent 5040c0d commit b132c33
File tree
5 files changed
+10
-3
lines changed- docs
- gateway-ha
- src/main/java/io/trino/gateway/ha/module
5 files changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
190 | 191 | | |
| 192 | + | |
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
59 | 57 | | |
60 | | - | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
0 commit comments