Pergunta

I've a site which is hosted in two load balancing servers. I've a collection of variables which is stored as a Lookup in a static variable to perform frequent and fast querying. The value in the static variable is a tree structured data, so I don't want to query it each time to DB and bind the relationship between the list variables. The static variable structure is like given below.

public static ILookup<long, ITree> MyStaticVar;

public interface ITree
{
    long ID { get; set; }
    // Some other properties
    ITree Parent { get; set; }
    IEnumerable<ITree> Children { get; set; }
}

Sometimes the content of the static variable might get updated (when Admin modifies some values), so I update the static variable with updated values and all the so that users could get the changes instantly.

It is working well in single server, but when I publish it to two or more servers, the variables won't get updated other servers than the one Admin logged in (since the static variable in that application server is only getting updated).

What is the best approach to maintain my static variable synchronized in multiple servers? Or is there any other way to manage my situation (Event driven or some other way to trigger/notify other servers and refresh the variable in them)?

I've a session state server which manages session values across these load balancing servers. Is there any way to store a single instance of the ILookup variable in session state server and share it across all users?

Foi útil?

Solução

Now I made a workaround. but it isn't an elegant solution. I made a web service to update the static variable.

I put the load balancing site's root paths in the web configuration and I called each application's web service on updating the static variable in any server.

But this works only when I know the load balancing server site paths, Is there any other way to update sites by finding the path dynamically?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top