Raza
Raza

Reputation: 847

Global variables in windows azure cloud service

Our application has some global variables and hidden fields like any other asp.net application.

We are having a doubt about the Windows azure cloud service, Since azure has multiple instances so if a global variable of javascript is assigned a value somewhere in midway of the code.

Then will that global variable hold the same value if there is an instance shift due to load balancing.

Also we are saving large html text on the server at a specified folder and retrieving the same after some time as per the user selection.(Its a large PDF document) Will this create a problem if the instances shift.

The load balancing criteria of windows azure is not so very well clear to me. If someone can shed some light on this, we would be very thankful.

We tend to create 4 instances.

Upvotes: 0

Views: 879

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136306

Our application has some global variables and hidden fields like any other asp.net application.

We are having a doubt about the Windows azure cloud service, Since azure has multiple instances so if a global variable of javascript is assigned a value somewhere in midway of the code.

Then will that global variable hold the same value if there is an instance shift due to load balancing.

Since JavaScript is a client side technology (at least in the form used by you), you must be populating your JS variables using some server side code. The question is how you're storing the variables which populate the JS variables on the server. If they are stored in a particular server (using static variables or in-proc session variables), then you would definitely have an issue as they are not available on other instances of your role.

One way to solve this issue is store these variables somewhere (in distributed cache, persistent storage etc.) where they can be accessible across all instances. If they don't contain any sensitive information, you may save them in cookies as well.

Also we are saving large html text on the server at a specified folder and retrieving the same after some time as per the user selection.(Its a large PDF document) Will this create a problem if the instances shift.

OH YEAH! This is definitely going to create problems for you. Recommended approach is to save these files in blob storage instead of VM's local storage.

The load balancing criteria of windows azure is not so very well clear to me. If someone can shed some light on this, we would be very thankful.

In short, Windows Azure Cloud Services uses Round Robin Load Balancing scheme which essentially dictates you to have your services stateless from session perspective.

You may want to look into Windows Azure Websites if you really don't need all the features provided by Windows Azure Cloud Services. If all you're doing is hosting a website, Windows Azure Websites may not be a bad option to go with.

Upvotes: 2

Related Questions