简体   繁体   中英

does Application state variable works fine in web farm servers

I am using an application variables to store the values and again access it.but my Question here as we using multiple servers (web farms). will be there any issue whiling access the values or it not worth to store values in application state variables when we are going ahead with multiple server

Thanks prince

No, Application State is not shared across the servers in a web farm, as per the documentation (see the section entitled Scalability ).

Application state is not shared among multiple servers serving the same application, as in a Web farm, or among multiple worker processes serving the same application on the same server, as in a Web garden. Your application therefore cannot rely on application state containing the same data for application state across different servers or processes.

You will need to find some other store for this shared information, ie via a database or shared cache.

However, you will be able to share viewstate and forms authenticate tickets across all servers in the web farm, but you must set the <machineKey> to the same values on all servers.

From the first article below:

If you deploy your application in a Web farm, you must ensure that the configuration files on each server share the same value for validationKey and decryptionKey, which are used for hashing and decryption respectively. This is required because you cannot guarantee which server will handle successive requests.

These MSDN articles have more information:
http://msdn.microsoft.com/en-us/library/ff649308.aspx#paght000007_webfarmdeploymentconsiderations
http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM