Azure / azure-functions-servicebus-extension

Service Bus extension for Azure Functions
MIT License
65 stars 35 forks source link

Service bus trigger consuming a large volume of messages at the end of the topic #228

Open asncharish opened 10 months ago

asncharish commented 10 months ago

We are implementing a system where we consume the messages from the topic and push it to the upstream. Since the upstream cannot be chocked, we need to throttle our requests. So, we are using MaxConcurrentCalls in host.json and MaxInstanceCount in the configuration.

We are load testing the system and dropping the messages in the topic.

We are able to control the load the function is consuming, but as it reaches the end of messages in topic, a huge volume of messages is being consumed which might choke our upstream system.

Ex: If the avg consumption of messages is ~200/min, the spike is taking it to ~1800/min for the 3-5 mins and settling down. We observed this spike mostly at the end of the queue but also sometimes in the middle of the queue (after consuming >50% of the messages). The spike does not last long.

This is occurring for multiple combinations of MaxConcurrentCalls in host.json and MaxInstanceCount in the configuration. Load we are trying to test: 5k, 8k, 10k, 12k, 20k, 40k, 50k, 80k. We observed the same behavior in all the scenarios. This is even observed with MaxConcurrentCalls=1 and MaxInstanceCount=1

We tested on both consumption & app service plan and the behavior is same.

Any help/suggestion to throttle is highly appreciated.