RenewBlobLease transactions

Zelgadis Greywords 0 Reputation points
2024-04-13T19:37:08.0433333+00:00

Hi everyone,

I have a NodeJS AWS application that I'm trying to migrate to Azure. I've started with a little proof of concept Function App that runs once a day with a timer trigger. At midnight it reads and then writes a single ~2mb json to a blob storage to try out the platform. However I'm getting billed for ~10k (!) transactions a day, discouraging me to try more complex use cases. I know the monthly cost is still small (<1€), but considering the current app scope, I fear it might get unbearable once expanded to a proper app.

From the metrics panel, I can see 7 RenewBlobLease operations per minute, all day long, for a grand total of ~295k operations per month. There are also ~15 operations of other types at midnight (mostly ListBlobs, GetBlob, PutBlob) which are otherwise zero during the day. I totally understand the latter transactions, but I imagine their cost is negligible compared to the others

What is going on? What are these lease operations doing and who is responsible for their execution?

Thanks

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,049 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,436 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sumarigo-MSFT 43,801 Reputation points Microsoft Employee
    2024-04-22T10:06:45.34+00:00

    @Zelgadis Greywords Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    Based on your scenario, I would recommend to please contact Billing and Subscription team would be the best to provide more insight and guidance on this scenario: https://azure.microsoft.com/en-us/support/options/ , it's free, and it's the best choice for your scenario. They can provided detailed information on scenrio based on your region or requirements.

    It sounds like the issue you are experiencing is related to the blob lease mechanism in Azure Blob Storage. When you acquire a lease on a blob, you are essentially taking an exclusive lock on that blob, which prevents other clients from modifying or deleting the blob until the lease is released. This can be useful in scenarios where you need to ensure that only one client is modifying a blob at a time, such as when implementing a distributed lock.

    In your case, it seems that your Function App is acquiring and renewing a lease on the blob every minute, which is resulting in a large number of transactions. This is likely because the default lease duration for a blob is 60 seconds, so if you are renewing the lease every minute, you are essentially keeping the lease active indefinitely.

    To reduce the number of transactions, you can try increasing the lease duration to a longer value, such as 5 minutes or 10 minutes. This will reduce the number of lease operations that are required to keep the lease active. You can also consider releasing the lease when you are done with the blob, rather than keeping it active indefinitely.

    It's also worth noting that the cost of blob leases is relatively low, so even if you are seeing a large number of transactions, the overall cost should still be relatively small. However, if you are concerned about the cost, you can try optimizing your code to reduce the number of lease operations that are required.

    In terms of who is responsible for executing the lease operations, it is your Function App that is acquiring and renewing the lease on the blob. When you acquire a lease on a blob, you are essentially telling Azure Blob Storage that you want to take an exclusive lock on that blob, and Azure Blob Storage will enforce this by requiring you to renew the lease periodically.

    Please let us know if you have any further queries. I’m happy to assist you further.    


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.