mikeheme
11/21/2025, 2:45 PM_count requests hitting our write cluster. We need a short-term fix to stabilize performance while we work on a long-term architecture change.
The Problem
Our application relies on inbox counts for ServiceRequest resources (a ServiceRequest can belong to multiple inboxes). We are polling periodically for these counts.
* Impact: CPU spikes to 100% on the cluster, and all requests (not just counts) slow down/fail (Memory/IO are low/fine)
* Load: We're generating Users X Inboxes X Polling Rate = hundreds of simultaneous _count requests
Technical Details & Questions
1. Read Replica Utilization: Our cluster has one write and one underutilized read replica. All these _count requests are hitting the write replica
* Q1: Is there a standard way to force these specific read-only requests (_count) to the read replica? Or a recommended way to enable read-request round-robin?
2. Medplum Version: We are on v2.1.4 (yes, we know 😬)
* Q2: Can we expect a significant performance gain for _count requests by prioritizing an upgrade?
3. Accuracy vs. Performance
* _total=accurate is the culprit
* _total=estimate is too inaccurate
* Q3: Will the accurateCountThreshold setting help balance speed and accuracy for our specific issue? (How does this feature interact with our count load?)
4. GraphQL Aggregation:
* Q4: Can we use a single GraphQL query to perform these count aggregations in one call, reducing the N-query problem to a 1-query problem?
> Count Request Example:
> /fhir/R4/ServiceRequest?_count=0&_filter=authored%20pr%20false&_tag:not=archived,needs-review&_total=accurate&identifier=titan-intake::InboxStatus|registration
We appreciate any help!rahul1
11/21/2025, 4:35 PMrahul1
11/21/2025, 4:35 PMrahul1
11/21/2025, 4:40 PMrahul1
11/21/2025, 4:40 PMmikeheme
11/21/2025, 4:59 PMmikeheme
11/21/2025, 5:00 PMmikeheme
11/21/2025, 10:15 PMmikeheme
11/21/2025, 10:22 PMrahul1
11/22/2025, 3:29 AMmikeheme
11/22/2025, 2:44 PMmikeheme
11/22/2025, 2:44 PMrahul1
11/24/2025, 3:49 PMrahul1
11/24/2025, 3:50 PMrahul1
11/24/2025, 3:50 PMmikeheme
11/25/2025, 11:40 PM