Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos DB Output binding shall support Bulk Execution mode for high throughput scenarios #820

Open
petr-hollay opened this issue Feb 2, 2023 · 4 comments

Comments

@petr-hollay
Copy link

The binding must support Bulk Execution mode by setting the following property:
https://docs.microsoft.com/cs-cz/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.allowbulkexecution?view=azure-dotnet

Expected behavior

Bulk Execution can be set in the binding attributes for compiled C# Functions.

Actual behavior

Build Execution mode can not be set using the existing output binding.

Known workarounds

Go around the standard output binding and use Cosmos DB SDK directly.

Related information

Introducing Bulk support in the .NET SDK - Azure Cosmos DB Blog (microsoft.com)

Bulk support improvements for Azure Cosmos DB .NET SDK - Azure Cosmos DB Blog (microsoft.com)

@ghost ghost added the Needs: Triage 🔍 label Feb 2, 2023
@ealsur
Copy link
Member

ealsur commented Feb 6, 2023

Thanks for the suggestion and feedback.

The problem with having this as a configuration attribute is, if the user sets it and then in the function calls sequentially the save method, then they are shooting themselves on the foot.

[FunctionName("WriteDocsIAsyncCollector")]
public static async Task Run(
	[QueueTrigger("todoqueueforwritemulti")] ToDoItem[] toDoItemsIn,
	[CosmosDB(
                databaseName: "ToDoItems",
		containerName: "Items",
                WithBulkMode = true,
		Connection = "CosmosDBConnection")]
		IAsyncCollector<ToDoItem> toDoItemsOut,
	ILogger log)
{
	foreach (ToDoItem toDoItem in toDoItemsIn)
	{
		await toDoItemsOut.AddAsync(toDoItem);
	}
}

That will generate more latency.

There is no API on IAsyncCollector that can avoid this pitfall at the moment.

@ealsur
Copy link
Member

ealsur commented Feb 16, 2023

Another biggest issue is that Bulk mode in C# depends on customers concurrently executing operations. Because other languages (Python/NodeJS/etc) use Bundles that run on top of C#, how does this work on other languages as well? Do all languages support concurrent execution? Isn't NodeJS single thread?

@praneeth-nimmagadda
Copy link

Is Bulk Execution mode supported in the cosmos output triggers?. I don't see that option at all , is there any specific version to see the bulk execution mode option ?

@ealsur
Copy link
Member

ealsur commented Dec 22, 2023

No, it is not supported as explained in the existing comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants