[SOLVED] Is accessing a read-only static variable better or worse than repeatedly retrieving data from an Azure blob?

Issue

I have about 5,000 read-only records.

Typically I store records in an Azure blob, and a function will retrieve the data, search through them, and then return matching records to the end-user.

Is it efficient and safe to, instead, retrieve the data from the Azure blob once, store it in a static variable, and then search through that?

I’ve looked and looked, but I can’t find a comparison or discussion between (a) repeatedly retrieving data from an Azure blob vs. (b) just maintaining it in a static variable, and why that might be undesirable.

Solution

Issues with repeatedly retrieving data from an Azure blob:

  • Every retrieve (read) operation is a chargeable transaction so your Azure bill will go up.
  • Every retrieve (read) operation is a network call which might fail so you have to take that into consideration. Furthermore, it will add time to your overall request process.

Issues with maintaining it in a static variable:

  • Static variables will consume server memory.

Not sure how big these files are but if they are not big, then I would recommend storing them in static variables if your blobs are truly read-only (i.e. will not change).

Answered By – Gaurav Mantri

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *