简体   繁体   中英

load balancer question c# asp.net

The place where I work has 2 servers and a load balancer. The setup is horrible since I have to manually make sure both servers have the same files. I know there are ways to automate this but it has not been implemented, hopefully soon (I have no control over this). I wrote an application that collects a bunch of information from a user, then creates a folder named after the email of the user in one of the servers. The problem is that I can't control in which server the folder gets created in, so let say a user goes in.. fills his stuff and his folder gets created in server 1, user goes away for a while and goes back to the site but this time the load balancer throws the user into server 2, now the user does something that needs to be saved into his folder but since it didn't created in this server an error occurs. What can I do about this? any suggestions?

Thanks

It sounds like you could solve a few issues by implementing a cloud file service for the file writes such as Amazon S3 http://aws.amazon.com/s3/

  1. Disk size management would no longer be a concern
  2. Files are now written and read from S3 so load balancer concerns are solved
  3. Benefits of a semi-edge network with AWS. (not truly edge but in my experience better than most internally hosted solutions)

Don't store your data in the file system, store it in a database.

If you really can't avoid using the file system, you could look at storing the files in a network share both servers have access to. This would be a terrible hack, however.

It sounds like you may be having a session state issue. It sounds odd the way you describe it, but have a look at this article. It's old, but covers the basics. If it doesn't try googling "asp.net session state web farm"

http://ondotnet.com/pub/a/dotnet/2003/03/24/sessionstate.html

This is a normal infrastructure setup. Below are the two commonly used solutions for the situation you are in.

  1. If you have network attached storage available (eg Netapps), you can use this storage to centrally store all of your user files that need to be available across all servers in your web farm.
  2. Redesign your application to store all user specific data in a database.

Use NAS or SAN to centralize storage. That same network-accessible storage can store the shared configuration that IIS can be setup to use.

Web Deploy v2 just released from Microsoft, I would encourage the powers that be to investigate that, along with Application Request Routing and the greater Web Farm Framework.

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