简体   繁体   中英

Best way to access a UNC path in C#

We are building an application that will be storing a lot of images. We have a virtualized environment at GoGrid.com and we were hoping to utilize their cloud storage.

Not sure exactly how to word this, but if we (in our code) specify the unc path and creds to place or retrieve an image, that seems terribly inefficient (connect, get image, disconnect)

If we have a large volume of images or many users performing this at once, it seems like it would bring any normal server to it's knees.

So my question is, short of having huge drives that your website is running on, how should we aim to accomplish this? Again, we are opting for the GoGrid cloud starge versus Amazon S3 since everything is under one nice umbrella. The cloud storage is accessible via a UNC path and a specific username/password.

Thanks!

C# can use unc paths like native paths, using the native operating system file i/o. Normally, you don't "connect/retrieve/disconnect", but rather once established the connection to the remote server will be held, as if you mapped a drive. Just because you don't have a drive letter for it, it doesn't mean there's no connection.

Alternatively (and knowing nothing about go grid), you could either just map a drive or use the Offline Files feature in Windows to keep the most frequently accessed files cached locally.

If you think you might be changing the file access method over the course of time, then be certain to keep it abstract. Start off with a simple UNC implementation, but you would then be able to change to a web service or REST implementation later.

I have not worked with high volume access servers before, but it sounds to me like you are looking for something very lightweight accessing a UNC path. Facebook has an architecture based on a lightweight HTTP implementation and blade servers for load balancing using a single 10TB filesystem, but you don't sound like you're quite there yet. If you want to maximize what you get out of the connects, try to pull multiple files in a connect/read/disconnect sequence. Be warned that this will make your users wait a little while longer, and 20ms slower for google lead to something like a 20% drop in users. Aside from that, I don't know of any faster way to do it than to simply access the path.

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