Question

I have a multi-instance worker role.

It needs to do 2 things.

  • Download emails from a pop-inbox, save them, create a DB entry & then delete the emails
  • Download files from an FTP Server, save them, create a DB entry & then delete the files

Both these operations are time-sensitive and in a multi-instance environment, it's possible the second instance could pull duplicate copies of files/emails before the first instance goes back and deletes them.

I'm planning to implement a sync-lock mechanism around the main download method, which acquires a lease on a blob-file. The goal being that it would act as a lock, preventing another instance from interfering for the duration of the download-save-delete operation. If anything goes wrong with Instance 1 (i.e. it crashes), then the lease will eventually expire, and the second instance will pick up where it left off on the next loop and I can maintain my SLA

Just wondering if this is a viable solution or if there are any gotcha's I should be aware of ?

Was it helpful?

Solution

Blob leases are a viable locking strategy across multiple servers.

However, I'd still be cautious and record downloading of each individual email as a separate record, so that i would minimize accidental double downloading of the same email.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top