I have an App Service
which hosts 6 web-jobs. Here, one web-job has CosmosDBTrigger
and my expectation is that it gets triggered every time there is new change feed in the container.
I am noticing, 8/10 times, that this feed trigger is taking almost an hour. Meaning, when the record is added to the container, I see it takes upto an hour to send this feed to this webjob.
How can I improve this? What could be the root cause?
Web-Job code:
Listener.cs:
public async Task ProcessMessageAsync(
[CosmosDBTrigger(
"%DatabaseName%", "%ContainerName%",
Connection = Configurations.CosmosDbConnectionString,
CreateLeaseContainerIfNotExists = true,
LeaseContainerName = "leases",
LeaseContainerPrefix = nameof(EventsListener))]
string documents, CancellationToken cancellationToken)
{
}
Program.cs
var builder = new HostBuilder()
.UseEnvironment(environment)
.ConfigureWebJobs(b =>
{
b.AddCosmosDB(configDbOptions =>
{
configDbOptions.ConnectionMode = ConnectionMode.Gateway;
});
})
Cosmos:
- This has through put set to autoScale with 4000 max RUs
- Just add an entry, no upsert is happening on this container.
The main thing I have noticed in logs is, when this container keeps receiving an events, in the time of the delay, I see upto 130 feeds are triggered at once.
I don’t know what is the reason that sometime this container feeds this much events instead of releasing them as soon as it comes.