Skip to content

Replace CosmosCache with Map

Krishna Nikhil Vedurumudi requested to merge cosmosClient into master

All Submissions:

  • [YES/NO] I have added an explanation of what changes in this merge do and why we should include it?
  • [YES/NO] I have updated the documentation accordingly.
  • [YES] I have added tests to cover my changes.
  • [YES] All new and existing tests passed.
  • [YES] My code follows the code style of this project.
  • [YES] I ran lint checks locally prior to submission.

What is the issue or story related to the change?

As per the recommendation from Cosmos team, there should be single client of Cosmos during the entire life cycle of the application.

The cosmos clients are heavy in nature and can eat up significant amount of memory. Using a cache is leading to two issues.

  1. Expiry of existing clients causes cache eviction which is leading to connection leaks.
  2. It is anyway not required, given that whatever Cosmos GoneExceptions are raised by the Cosmos are handled by the SDK itself.

High level design:


Change details:

Test coverage:

Does this introduce a breaking change?

  • [YES/NO]

Pending items

Reviewer request

  • Please provide an ETA when you plan to review this MR. Write a comment to decline or provide an ETA.
  • Block the MR if you feel there is less testing or no details in the MR
  • Please cover the following aspects in the MR -- Coding design: <Reviewer1> -- Backward Compatibility: <Reviewer2> -- Feature Logic: <Logic design> -- <Any other context mention here> OR -- <Component 1>: <Reviewer1> -- <CosmosDB>: <Reviewer2> -- <ServiceBus> <Reviewer3> -- <Mention any other component and owner>

Other information

Before fix, during scale up - the number of GoneExceptions were high.


After fix, during scale up - no GoneExceptions


Logs that confirm Cosmos client per partition is created only once.


Response status with scale up


Edited by Krishna Nikhil Vedurumudi

Merge request reports