简体   繁体   中英

Cosmos DB change feed monitoring vs polling

I have an image encoding service (asp.net core 5) and the pictures are processed via a queue, when the image is done all the image info are inserted into cosmos db.

I need to be notified when this append. It doesn't need to be at the same time it can have 1 second delay it would stile be acceptable.

So my question is: would it be better to process the cosmos db change feed to look for the insert event, or to poll via a query every second the id of the image to see if it exists?

Also I don't understand the cost around processing the change feed. If I poll the Id, it cost me around 3RU per query.

Any suggestion?

You can definitely use change feed here with no additional cost (well, I might be wrong) than your write operation . (EDIT: Change feed does incur some additional RU consumption ). But problem with that is your feed listener would be notified only when something is written. So holistically you won't be able to track failure in your processing with this. A better approach can be just to send notification from your code at the end of processing logic (success or failure). You can also make async by sending a message to another queue and send notification from it's listener (another service).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM