When to use it
Before your first production deploy, and whenever your traffic mix shifts toward longer documents. Throughput falls roughly linearly with document length, so size on characters, not request count.Measured throughput
Measured in AWS with 2 detect tasks onc9g.xlarge (one 4-thread worker per task), calling POST /deidentify — detection plus vault writes to Aurora — on synthetic medical-note-shaped text. “Saturated” is the highest throughput reached as concurrency increased.
For comparison, the engine alone, in process, one request at a time on
c9g.xlarge, takes p50 775 ms, p95 ~860–910 ms on a 5,250-character document. The difference to the service numbers is network, the vault and queueing.
What these numbers are, and aren’t. They were measured on an earlier image, through an internal load balancer — before callers reached the services through VPC Lattice. Lattice adds a little to every request, and a TLS handshake whenever the client opens a new connection. Re-measure on the image you deploy, with your own traffic, before you commit to capacity: entity density and text shape move these numbers too.
How many replicas
- Divide by 0.6 to keep replicas near the 60% CPU autoscaling target rather than at saturation, where p95 roughly doubles (5,250 characters: 1.6 s → 3.1 s).
- +1 keeps capacity during a rollout and through an AZ loss — rollouts take one replica out at a time.
- Mixed traffic: sum
peak_docs_per_s ÷ per_replica_docs_per_sacross document sizes before dividing.
2 / 1.26 / 0.6 = 2.6 → 3, plus 1 → 4 detect replicas.
Rehydration does no model inference on the request path. Two small replicas are enough for most workloads.
Instances
Scaling
- ECS (CloudFormation, Terraform): target tracking on CPU is on by default —
DetectCpuTargetPercent/detect_cpu_target_percent=60, betweenDetectDesiredCountandDetectMaxCount(2–10). 60% is of the task’s 4096 units (2.4 vCPU). The ASG’s managed scaling adds instances (AsgMaxSize, default12). - EKS (Helm):
detect.autoscaling.enabled=trueadds an HPA, target 60% CPU,2–10replicas. HPA utilization is measured against the request, so 60% of3500mis 2.1 cores. You need Karpenter or Cluster Autoscaler for new pods to get nodes. - Don’t scale on memory. The worker’s memory is dominated by the model and is flat with load.
Turn my traffic numbers into a replica count and autoscaling settings.
Gotchas
- A replica fills its node. Rollouts replace in place, so capacity drops by one replica (ECS: by half at the default 50% minimum healthy) during a deploy. Upgrades.
- Latency grows with queueing, not just size. Past saturation, extra concurrency only adds wait time: throughput stays flat while p95 keeps climbing. In the measurement, documents of 2,000 characters and up saturated at about 2 in-flight requests per replica — cap client concurrency near that.
- Reuse connections. A client that opens a new connection per request pays a TLS handshake each time. The
tenet-pii-latticeclient keeps one connection open per client. - Usage records show your real length mix. The counts-only usage records report documents by length per hour. Monitoring.