C
C#3mo ago
Pan!cKk

Scaling Background Services !

I have a background service that uses Redis as it's main operating database. What this background service do is that on user input (start button event), I store that entity on Redis and the background service keeps fetching these entities and process them (or not) based on different conditions. What I store on Redis is a list of those entities, so when a new process is requested, a new item is added to that list, and then I fetch that list and process the items within a foreach loop. It works fine with a single instance, but I am trying to figure out a way on how to make it work with multiple instances. What I tried so far was adding an new property to that entity, "IsLocked" so when it is fetched, I set that property to "true" so the other one does not process it, and finally I set it to "false". In theory it sounded possible, but the background service is executed every 100ms, what I am assuming that the other instance fetches that list before the other one updates the "IsLocked" property. I hope I am being clear with my request, but this is my first time trying to working with multiple instances, so be gentle ! Could someone provide me with some helpful resources and tips of what could be a good solution for my case? Or even if I should use a completely different approach ! Thank you in advance :)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server