How do I cluster an upload folder with ASP.Net? - asp.net

We have a situation where users are allowed to upload content, and then separately make some changes, then submit a form based on those changes.
This works fine in a single-server, non-failover environment, however we would like some sort of solution for sharing the files between servers that supports failover.
Has anyone run into this in the past? And what kind of solutions were you able to develop? Obviously persisting to the database is one option, but we'd prefer to avoid that.

At a former job we had a cluster of web servers with an F5 load balancer in front of them. We had a very similar problem in that our applications allowed users to upload content which might include photo's and such. These were legacy applications and we did not want to edit them to use a database and a SAN solution was too expensive for our situation.
We ended up using a file replication service on the two clustered servers. This ran as a service on both machines using an account that had network access to paths on the opposite server. When a file was uploaded, this backend service sync'd the data in the file system folders making it available to be served from either web server.
Two of the products we reviewed were ViceVersa and PeerSync. I think we ended up using PeerSync.

In our scenario, we have a separate file server that both of our front end app servers write to, that way you either server has access to the same sets of files.

The best solution for this is usually to provide the shared area on some form of SAN, which will be accessible from all servers and contain failover.
This also has the benefit that you don't have to provide sticky load balancing, the upload can be handled by one server, and the edit by another.

A shared SAN with failover is a great solution with a great (high) cost. Are there any similar solutions with failover at a reasonable cost? Perhaps something like DRBD for windows?
The problem with a simple shared filesystem is the lack of redundancy (what if the fileserver goes down)?

Related

How can I synchronize physical files manually in a Kentico web farm?

We have a non-standard Kentico architecture which Kentico have advised is supported as long as synchronization of physical files between load balanced servers is disabled and handled manually. What is the correct way to manually synchronize web farm server files? I wondered about using a tool like DirSync but assume this would require one server to act as the primary, whereas with Kentico a new media file, for example, may be initially saved to any of the physical servers.
I'm hoping to identify a definitive solution to this issue. Thanks.
Kentico web farm by default synchronizes physical files automatically if the web farm is working properly. As each request can be served by different server Kentico serializes file binary into Database which is shared by all servers and then re-creates file on the server where it is missing.
I'm not aware of any situation where web farms are supported, but file synchronization isn't. It's either all or nothing, there is no middle solution.
Can you be more specific of why the synchronization of physical files is not working on your end? As long as all servers see the database (which they should otherwise the WF is not working at all) the file synchronization will work.
PS: If your files are not synchronized, go to Web farm -> Tasks application and check how many tasks are there. If there are no tasks (or very few which are being deleted constantly) then your web farms are working, if there are tasks older then few minutes then your web farms are not working at all.
I read the thread above and would recommend you take a look at this tool from BizStream: https://devnet.kentico.com/marketplace/modules/compare-for-kentico
I haven't gotten to play with it myself, but they are a top notch shop so I can bet its a top notch product.
Otherwise you are going to have to go the custom sync code.
We've tried to do moves via the SQL Tables and it is 'possible', but the amount of interconnected relationships just make it quite unrealistic to build or support.

Mimic Azure Staging on Custom Server

In WebsiteAzure we have an Staging feature. So we can deploy to one staging site, test it, fill all caches and then switch production with stage.
Now how could I do this on a normal Windowsserver with IIS ?
Possible Solution
One stragey i was thinking about is having a script which copies content from one folder to an other.
But there can be file locks. Also as this is not transactional there is some time a kind of invalid state in the websites.
First Poblem:
I've an external loadbalancer but it is externally hosted and unfortunately currently not able to handle this scenario.
Second problem As I want my scripts to always deploy to the staging i want to have a fix name in IIS for the staging site which i'm using in the buildserver scripts. So I would also have to rename the sites.
Third Problem The Sites are synced between multiple servers for loadbalancing. Now when i would rebuild bindings on a site ( to have consistent staging server) i could get some timing issues because not all Servers are set to the same folder.
Are there any extensions / best practices on how to do that?
You have multiple servers so you are running a distributed system. It is impossible by principle to have an atomic release of the latest code version. Even if you made the load-balancer atomically direct traffic to new sites some old requests are still in flight. You need to be able to run both code versions at the same time for a small amount of time. This capability is a requirement for your application. It is also handy to be able to roll back bad versions.
Given that requirement you can implement it like this:
Create a staging site in IIS.
Warm it up.
Swap bindings and site names on all servers. This does not need to be atomic because as I explained it is impossible to have this be atomic.
as explained via Skype, you might like to have a look at "reverse proxy iis". The following article looks actually very promising
http://weblogs.asp.net/owscott/creating-a-reverse-proxy-with-url-rewrite-for-iis
This way you might set up a public facing "frontend" website which can be easily switched between two (or more) private/protected sites - even they might reside on the same machine. Furthermore, this would also allow you to actually have two public facing URLs that are simply swapped depending on your requirements and deployment.
Just an idea... i haven't tested it in this scenario but I'm running a reverse proxy on Apache publicly and serving a private IIS website through VPN as content.

deploying flex applications

I have a Flex application which has to be deployed in some server. The typical form of access would be invoking the URL. How do i go about it?
Should I have multiple instances of the applications running on the same server/ deploying the application in diff servers and using a load balancer for routing?
If i must have multiple instances, how to do that?
On a given day, the application is expected to get around 2000-3000 hits. What are all the factors to be kept in mind while deployment?
Any pointers would be helpful.
thanks.
I'm actually a bit unsure what specifically you're asking, so I'll take your questions one by one.
I have a Flex application which has to
be deployed in some server. The
typical form of access would be
invoking the URL. How do i go about
it?
Put your SWF files on a web server. For best results export a release build first. Flash Builder makes this easy.
Should I have multiple instances of
the applications running on the same
server/ deploying the application in
diff servers and using a load balancer
for routing?
Probably not, but it depends. A SWF is just a binary asset. As far as the server is concerned it is no different from a JPG, gif, or PNG file. Whether or not you need a load balancer to serve the SWF depends on the size of the SWF, the amount of simultaneous hits you expect, other traffic on the server, bandwidth of your hosting provider, and probably a whole slew of other considerations that escape me at the moment.
If your SWF is making calls to the server--very common in Flex Applications--that may also be a consideration.
If i must have multiple instances, how
to do that?
If you have multiple instances of what? Of the SWF? Why would you need to do that? As I said, as far as the server is concerned a SWF is just a binary asset. In theory you could keep as many copies of the file on your server as you want, in practice most people just use a single one.
On a given day, the application is
expected to get around 2000-3000 hits.
What are all the factors to be kept in
mind while deployment? Any pointers
would be helpful.
That strikes me as low traffic site; however it depends what you're doing.
Despite my answer, I have to vote to close as your questions is vague and ambiguous. I'm not sure what you want to know.
I think you miss a basic information on your application.
As long as you create Flex/Flash application and you put them on your server they will always be SWF file executed Client Side.
So i think you don't have to wonder on the workload of your server because isn't your server that run the application but the Client PC.
As long as your server can manage 2000/3000 hit per day you can be quite sure that alway will run smootly.
Claudio.

Is there a way to share an in-memory object between multiple websites?

We have about 70 sites on our server that use same application (with different Application Pools) and they use for example a shared skin file.
So is there a way to load this file to memory and share for all applications?
what I mean is to sharing cache in multiple websites to decrease pressure on server.
Thanks in advance
May be I'm not answering your question directly, but you problem has better solution. The best place for CSS, images, static content is either CDN (content delivery network) or standalone server.
At first it improves time of page loading (since per browser convention there only 2 opened threads to single domain). So placing onto standalone server allows browser simultaneously load content from you server and CDN.
At second it solves your problem since application doesn't spent time to dispatch requests of static data
I agree with Dwefy. But if you need to share dynamic content in memory have a look at memcached
Unless you use a shared cache such as memcached then no, there's no way to do this. Even using a shared cache you're still going to be creating temporary objects in each site when you retrieve the item from the cache.
Best to store this somewhere on disk and just share the file.

Flex writing to it’s own directory

I have a Flex application I’m writing (Learning exercise) that I’d like to run of a network drive for many users to access. I’d like users to be able to save high scores on the network.
Users have read write to the network location it's on.
I don’t want to change anything on the computers that might use it (IE install AIR) or IE/Firefox settings. They are just default.
I don’t want to run a server (IE PHP)
Is there anyway to do it?
Cheers
Nope, not without AIR. And even then with difficulty. Flex runs within the context of the browser, and only has available to it the resources available to the browser (for obvious security reasons.)
Flash enjoys a unique position of corporate trust for reliability and safety, and they do everything possible to protect that position. So you're sandboxed.
The best I can think of is put together something that serves a URL and a common or custom read-write protocol - probably not trivial.
You will have to use a backend to access any of those resources. Eg, if you're using BlazeDS then you can just use Java to write to the network. You will have a server anyways to host your application.
You really want to use a backend technology for this. If you're dead set against it, Flash Player 10 can write files to the local filesystem. You could probably trick it to use a network resource by referencing it as a mapped drive or maybe even a named host.
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#save()
You can also use the "load()" method of FileReference to read a local file into your Flex application.
I really don't recommend you write in an application using this but it looks like it could be done. The caveat here is that these actions can happen only if the user specifically chooses a location for a file: they need to select the file you want to load or choose the location where a file is saved.

Resources