Cosmos DB – Request Units charged for processing a Gremlin API request
by Howard van Rooijen
We’re currently building a Data Governance Platform product that enables UK Financial Services organisations to discover and manage the life-cycle, usage, risk and compliance requirements of data assets across the organisation. Much of the core functionality is delivered using Cosmos DB’s Gremlin API to model data lineage and other relationships best represented by a graph data structure.
If you’ve used Comsos DB before you’ll be aware of the Request Units pricing model, which is based on a number of factors such as item size, item indexing, item property count, indexed properties, data consistency, query patterns and script usage. One of the biggest challenges building an API over Cosmos DB’s Graph functionality was figuring out how expensive a read / write operation was. It was very much a trial and error approach.
Fortunately the Gremlin API now supports the x-ms-total-request-charge response header, so you can get an accurate cost measure on each Graph API operation.
Use <PackageReference Include="Gremlin.Net" Version="3.4.0-rc2" /> as the minimum version of the package reference for the sample below:
Combined with the new 400 RU minimum database level which can be shared across all containers within a database, the Cosmos DB team really are taking away all of the barriers to entry.
Thanks to Rimma Nehme & Shireesh Thota for this info!
If you enjoyed this post, please consider sharing it on social media using the buttons below. Thanks!
Howard spent 10 years as a technology consultant helping some of the UK's best known organisations work smarter, before founding endjin in 2010. He's a Microsoft ScaleUp Mentor, and a Microsoft Azure MVP. You can follow him on Twitter via @HowardvRooijen