You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace single semaphore with sharded trigger processor for high-scale deployments
When running 2500+ continuously syncing subgraphs, the original single semaphore
approach created a severe bottleneck where only 1.3% of subgraphs could process
concurrently (32 permits for 2500 subgraphs = 97% waiting time).
This commit introduces a sharded trigger processor that:
**Key Changes:**
- Replaces single global semaphore with multiple per-shard semaphores
- Uses consistent hashing to distribute subgraphs across shards
- Provides 32x improvement in concurrent capacity (32 → 1024 workers)
- Eliminates the global contention bottleneck for large deployments
**Architecture:**
- Each subgraph is consistently assigned to one shard via hash of deployment ID
- Each shard has its own semaphore pool (configurable workers per shard)
- Subgraphs compete only within their assigned shard (~78 subgraphs per shard)
- Total concurrent capacity = num_shards × workers_per_shard
**Configuration (Environment Variables):**
- `GRAPH_SUBGRAPH_RUNTIME_PROCESSING_SHARDS` (default: CPU count)
- `GRAPH_SUBGRAPH_RUNTIME_WORKERS_PER_SHARD` (default: 32)
- `GRAPH_SUBGRAPH_MAX_QUEUE_PER_SUBGRAPH` (default: 100)
**Performance Impact:**
- Before: 2500 subgraphs → 32 permits (1.3% concurrent processing)
- After: 2500 subgraphs → 32 shards × 32 permits = 1024 permits (41% concurrent)
- Recommended for deployments with 32 vCPU/248GB: 1024 concurrent executions
**Breaking Changes:**
- Removes `GRAPH_SUBGRAPH_RUNTIME_PROCESSING_PARALLELISM` environment variable
- Single semaphore `SubgraphTriggerProcessor` replaced with sharded version
- Test fixtures updated to use new processor with minimal shard config
The sharded approach maintains all existing functionality while dramatically
improving scalability for high-density subgraph deployments.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
0 commit comments