Rate limit when sending > 10 updates for a single ...
# support
c
I am testing a migration script and am getting a too-many-requests response.
r
@Charlie from Imagine - we typically only rate limit auth requests. Are you getting an access token for every call?
c
No, just passing in client secret and clientid at the beginning.
r
That is surprising. We only hard rate-limit authentication requests, as far as I'm aware right now. There isn't a super clean way to disable via configuration. But there are some work arounds you might want to try: 1. Using Basic Auth, to avoid doing an auth handshake for your script 2. Turning on "autobatching" to limit the number of HTTP requests your script is making. You should see better performance from this as well
c
I confirmed we are already doing #1
Looking into #2
r
Another thought - is your migration script triggering a call to Okta / Azure auth at all? We've seen cases where the 429 error is actually thrown from the Auth provider
c
It was because we had >10 updates in our bundles
>10 updates to the same resouces
triggers some logic in the fhir router to reject it
r
Oh I see! I'm sorry about that - that should be documented
I'll also talk to the team to see how we arrived at that limit
Would be able to poiint to a link or line number ?
c
Yeah, standby
sorry for the delay - been in some meetings 🙂
r
Hmm, I see you've found our circuit breaker 🔌 This was a safety measure introduced to guard against rogue webhooks. There were medplum users who had
Subscriptions
that would get into infinite loops
Would you mind sharing an example of the kinds of updates the batch request is making for a single resource? There might be some patterns we can use to consolidate the requests in to a smaller number of
UPDATE
commands
c
We have a caregiver (modeled as a tagged patient) that has 10 children patients. In our bundle each related person linked is done with a patch
Copy code
{
          op: 'add',
          path: '/link/-',
          value: {
            type: 'seealso',
            other: { reference: relatedPersonUrn },
          },
        },
r
Have you already tried adding multple PATCH operations to a single PATCH entry in your bundle? If you know the
RelatedPerson
urns ahead of time, you should be able to using a single PATCH call, with 10 JSON Patch operations
c
The bundles are at the child level unfortunately
But we had considered that
Our workaround for now is to shuffle our source patient list so that we don't do the same children close together.... hacky but is working
r
Ok I'm sorry about that - i understand it's not the best solution. I'm happy to take a closer look to see if I can offer any help on consolidation. We can also look into changing that circuit breaker logic for bundles - but you would still see 10 different updates in teh caregiver's history, which may not be ideal
c
The constraint makes total sense to have really. I think we just need to make sure our script does not have abusive update patterns 😄
175 Views