Scaling Considerations
How each AgentShield component scales, where contention appears, and how budgets and per-organization serialization affect throughput.
Component scaling
| Component | Model | Notes |
|---|---|---|
| Gateway | Horizontal, stateless | All shared state is in PostgreSQL and Redis. Scale on CPU and request rate |
| Intelligence engine | Horizontal, stateless | CPU-bound regex matching; time grows linearly with content size |
| Control plane | Horizontal, stateless | Low traffic relative to the gateway |
| Dashboard | Horizontal, stateless | Server-side proxy to the control plane |
| Event relay | Single replica | Ordering is per relay; two relays may interleave events. Claims use SKIP LOCKED, so a second replica would not duplicate work, but ordering guarantees would weaken |
The production overlay runs two replicas of each stateless service with disruption budgets.
Where time goes
From the recorded benchmarks, in-memory work per authorization is small:
| Step | Median |
|---|---|
| Ed25519 verification | ~81 µs |
| Policy evaluation (5 entries per list) | ~14 µs |
| Full in-memory authorization | ~126 µs |
Real latency is dominated by network round trips: Redis (nonce and budget script) and one PostgreSQL transaction for authorize; a claim transaction, the adapter call, and a completion transaction for execute; plus the analyzer call when enabled.
Contention points
Per-organization audit chain. Every event appends to its organization's chain under a row lock on the chain head. Writes for one organization are serialized. This bounds per-organization event throughput and is inherent to a hash chain.
Per-agent budgets. A single agent is limited to 60 requests and 30 calls per tool per minute. Load tests from one agent measure the rate limiter, not the gateway. Throughput scales with the number of agents.
Large policies. Evaluation re-validates both documents on every call: about 565 µs at 200 entries per list. Keep policies focused.
Content analysis. About 4 ms per 16 KiB of content and roughly 130 ms at the 512,000-character request limit. Set INTELLIGENCE_TIMEOUT (≤ 5 s) for your largest results, and add analyzer capacity for throughput. In the Kubernetes production overlay the analyzer is a gateway sidecar, so it scales with gateway replicas. A timeout yields unavailable, not a failure.
Data growth
| Store | Growth driver | Management |
|---|---|---|
| PostgreSQL | Invocations, decisions, events, chain links per call | Append-only; plan capacity and archival |
| Redis | Short-lived keys per agent | Self-expiring |
| JetStream | Events, seven-day retention | Size storage for seven days |
| Object storage | One bundle per flagged or failed call | Retention set by the operator |
Availability
- Run at least two gateway replicas across nodes; the overlay spreads them.
- PostgreSQL and Redis availability directly bounds gateway availability, because the gateway fails closed without them.
- The relay and NATS are off the request path. Their outages delay events, not decisions.
- The analyzer is optional on the request path. Its outage produces
unavailablereports.
Was this page helpful?