I have an Azure function with ServiceBusTrigger which will post the message content to a webservice behind an Azure API Manager. In some cases the load of the (3rd party) webserver backend is too high and it collapses returning error 500.
I'm looking for a proper way to implement circuit breaker here.
I've considered the following:
- Disable the azure function, but it might result in data loss due to multiple messages in memory (serviceBus.prefetchCount)
- Implement API Manager with rate-limit policy, but this seems counter productive as it runs fine in most cases
- Re-architecting the 3rd party webservice is out of scope :)
- Set the queue to ReceiveDisabled, this is the preferred solution, but it results in my InputBinding throwing a huge amount of MessagingEntityDisabledExceptions which I'm (so far) unable to catch and handle myself. I've checked the docs for host.json, ServiceBusTrigger and the Run parameters but was unable to find a useful setting there.
- Keep some sort of responsecode resultset and increase retry time, not ideal in a serverless scenario with multiple parallel functions.
- Let API manager map 500 errors to 429 and reschedule those later, will probably work but since we send a lot of messages it will hammer the service for some time. In addition it's hard to distinguish between a temporary 500 error or a consecutive one.
Note that this question is not about deciding whether or not to trigger the circuitbreaker, merely to handle the appropriate action afterwards.
Additional info
- Azure functionsV2, dotnet core 3.1 run in consumption plan
- API Manager runs Basic SKU
- Service Bus runs in premium tier Messagecount: 300.000