Commit 42c37f6
committed
Implement production-grade sharded trigger processor with backward compatibility
Addresses critical scalability issues
ensuring zero-breaking changes for existing indexers.
**Key Performance Fixes:**
- Fixed semaphore permit lifetime - permits now held during entire processing duration
- Implemented consistent deployment-based sharding using proper hash distribution
- Added comprehensive backpressure mechanism with exponential backoff
- Enhanced monitoring with per-shard metrics and load imbalance tracking
**Backward Compatibility (Zero Surprise):**
- Sharding is opt-in only (disabled by default)
- Legacy single-semaphore behavior preserved when GRAPH_SUBGRAPH_RUNTIME_PROCESSING_SHARDS=1
- Existing indexers see no changes without explicit configuration
- All tests pass with legacy mode enabled by default
**Scalability Improvements:**
- Before: 32 workers total (1.3% concurrent capacity for 2500 subgraphs)
- After: 1024 workers (32 shards × 32 workers) when sharding enabled
- Recommended for deployments with 2500+ subgraphs on 32+ vCPU systems
- Deployment-consistent sharding ensures optimal cache locality
**Environment Configuration:**
```bash
# Legacy mode (default - no changes)
# GRAPH_SUBGRAPH_RUNTIME_PROCESSING_SHARDS=1 (or unset)
# High-scale mode (opt-in)
export GRAPH_SUBGRAPH_RUNTIME_PROCESSING_SHARDS=32
export GRAPH_SUBGRAPH_RUNTIME_WORKERS_PER_SHARD=32
export GRAPH_SUBGRAPH_MAX_QUEUE_PER_SUBGRAPH=100
```
**Observability Features:**
- Per-shard utilization and throughput metrics
- Queue depth monitoring with backpressure alerts
- Shard load imbalance detection and reporting
- Clear logging of sharding mode and configuration
The implementation maintains full API compatibility while providing a 32x improvement
in concurrent processing capacity for high-density subgraph deployments.
🤖 Generated with [Claude Code](https://claude.ai/code)1 parent bab43a7 commit 42c37f6
File tree
4 files changed
+326
-55
lines changed- core/src/subgraph
- graph/src/env
- tests/src/fixture
4 files changed
+326
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
188 | 191 | | |
| 192 | + | |
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
194 | 211 | | |
195 | 212 | | |
196 | 213 | | |
| |||
0 commit comments