question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow consumption of Change Feed as a in-memory push model

See original GitHub issue

Is your feature request related to a problem? Please describe. We’re using ChangeFeedProcessor to update in-memory caches. When an instance of the application dies, a new one takes its place (either via rolling upgrade or failures) and the CFP lease is orphaned (requiring cleanup, sooner or later).

Describe the solution you’d like Allow us to bypass the need for a lease container to read from the change feed. One solution might be to make ChangeFeedProcessorBuilder.WithInMemoryLeaseContainer() public with a way of specifying whether to start from the beginning or end of the change feed. We are able to take snapshots and would just read from the end when starting the application.

Describe alternatives you’ve considered Keep using the existing model and clean up CFP lease containers that haven’t moved (cont. token not brought up to level within n time) - this is less than ideal when the in-memory lease container seems to do exactly what we need, without requiring any cleanup in Cosmos.

Request sprung from discussions in #831.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Nov 7, 2020

@liquidsnk In-memory push scenarios are better served by the Change Feed pull model. Because In-memory has really no benefits (no load balancing nor distribution) over the Pull model. Pull gives more control on the frequency and even lets you store the state if you desire so (also in a controlled fashion, since you can store the continuation token anywhere you want). It is also easier if you are using it in a background process (for example, a Background Host in an ASP.NET app).

Please do describe your scenario so we can see why you’d need In-memory with push?

0reactions
ealsurcommented, Nov 12, 2020

The problem is that CFP adds a lot of threads/Tasks in the background for this simple scenario. It would start one parallel set of Tasks for each partition, where each set contains a Task to renew the in-memory leases, a Task to read the changes, and a Task to do cross partition synchronization. It’s just a lot of things that won’t yield any benefit and will potentially add overhead.

With the pull model you can have your Background host periodically just call ReadNextAsync on the FeedIterator. From the lines of code perspective I believe they are pretty similar, both would need a setup (configuring and starting the CFP vs creating the FeedIterator), and consuming it (create a handler or call ReadNextAsync and handle the changes). So you end up coding more or less the same amount and one does not generate the Task overhead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change feed pull model in Azure Cosmos DB
In this article​​ You can use the change feed pull model to consume the Azure Cosmos DB change feed at your own pace....
Read more >
Is push model of cosmos change feed processor really a ...
With a push model, the change feed processor pushes work to a client that has business logic for processing this work.
Read more >
Azure Cosmos DB change feed
Consume the change feed. There are a few ways to read the change feed. These methods usually involve push and pull models. Push...
Read more >
How to Use Caching with Azure Cosmos DB - Webinar
We have a mechanism within Microsoft Azure Cosmos DB. It uses change feed. There's an observer pattern. So, it allows you to manage...
Read more >
Azure Cosmos DB : Change Feed processor for Java
You can work with the Azure Cosmos DB change feed using either a push model or a pull model. With a push model,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found