0
I have an ASP.NET 3.0 application that works fine on one server. It uses application variables to check if a user has checked out a file and locks it for all other users. When I put the application on the load balanced servers, the application didnt work as expected since it multiple users got sent to multiple servers and each user could check out the requred file.
The main point is that, is there any way I can share the application variables in my application even though it is distributed on multiple servers. Or is there a better way to get a global variable?
EDIT: I am checking if a file is checked out by Application[“FileLocked”] is true or false
Two things for you to consider:
In a load balanced environment, instance data within one server will not be available to another. While you can use Out-of-process session state, you can’t easily make Cache items or static class data available across servers. A user’s request will not always be routed to the same server (unless you use something like sticky sessions) – which can cause other problems.
You probably should use a more persistent mechanism (like a lock file) to determine whether a particular user is using a file. Otherwise, you may introduce race conditions in your system – and if a user’s sessions ends without them unlocking the file you’ll end up with orphaned locked files in your system.