NLB and Web Deploy - asp.net

I have two webservers in a cluster serving a web application.
Using MS Web Deploy to push a new version of the application to one server, and then again to synchronize the files to the other server in the cluster. It seems to be the most ordinary thing to do.
But wouldn't there be a problemm, when one server is deployed with the new version, and the other is not yet finished. Will it not cause troubles, when a page loaded with the new version makes a webservice request and the balancer sends the request to the server with the old version?
What's the best way to avoid this?
I thought about scripting a drainstop of the server, that we deploy to, and make sure only one server is running at a time. But I can't find anyone else, who seems to have written about such a solution. And guess that it doesn't scale very well too.
Another solution could be to shut down all servers when updating. But that doesn't seems very clever.
Any suggestions?

You could use DFS so that the files are basically instantly copied over to the other server(s).
Also, you could edit the host files of each server so that each server uses it's own hosted services instead of going through NLB and potentially going to another server. There is rarely a reason to go to another server when you are already on a server, it only causes headaches like you mentioned and decreases performance.

Now there is also the Web Farm Framework: http://weblogs.asp.net/scottgu/archive/2010/09/08/introducing-the-microsoft-web-farm-framework.aspx

Related

.Net core application failing to upload via FTP, hosted on IIS

I have a problem deploying a .net core application via FTP which is hosted on IIS.
The main DLLs (core application) that I want to update just wont upload, FTP just gives me a generic permission error message. I think the reason is because they are in use because then I stop the application pool, upload and restart it works just fine.
But this isn't really a solution, are there any other methods of publishing that will alleviate this problem?
Edit:
"open for write: failure"
Is the only error I'm getting. I can't find anything online and the only solution I have is restart the app pool.
I found an answer and I figured it should be here for future Googling.
The issue is as I first expected IIS proxies the request to kestrel and that means the process is in use as far as Windows is concerned. There are three solutions.
The Good Solution
Have two (or more) VMs on azure behind a load balancer. Have a script which turns off the sites one at a time, does what it needs to do and turns them back on. Do this right and no downtime!
Intermission
Before I talk about the other solutions a little explanation. I have not been working with .NET for a long time but apparently there was this thing you could do where you add a app_offline.htm and it will temporarily take down the site for you.
In the context of IIS and .Net Core it also releases the process, which is really useful as it solves my problem! Although I had to visit the web page first for it to take effect, unless I'm mistaken.
The Bad Solution
Use an automated script to rename _app_offline.htm to app_offline.htm. Do the upgrade and then revert that change. Takes your site down, kind of ugly but scripting is always better than...
The Ugly Solution
You only have access to FTP, no remote admin or proper deployment process because... reasons.
Upload an app_offline.htm, upload as little as possible and hope it doesn't break anything before deleting or renaming app_offline.htm.
Also you would have to perform any DB migrations by using EnableAutomaticMigrations = true because you have no server access or scripting methods.

Can you publish asp.net webforms project keeping it online?

We've quite a big project at work which sometimes needs to be published during the day. However, the application will (of course) crash during publish and show errors. (because the /bin is being overwritten)
Is there a way to avoid this? Sometimes a publish takes up to 3-4 minutes.
I know I can use the app_offline.htm file to display a message instead of them seeing the actual errors.
There isn't a way to have 0 downtime on a deployment. But you have some options
Deploy a pre-compiled site
To speed up the time taken for a site to be active after deployment, you can use ASP.NET Web Site Pre-compilation. This process will package the site so that it will not need to be compiled on-the-fly after deployment.
Benefits
Faster site startup
Less assets to deploy
Can be packaged via the Web Deployment Tool
Drawbacks
Debugging can be harder as the names are scrambled; Debug mode can be turned on for it though
You cannot edit a pre-compiled site; you must do a full re-deployment
You should still use the app_offline.htm so avoid yellow-screen-of-death errors
Add another web server
The best option for these scenarios is to have 2 servers with a load balancer in front of them. Then this way you use the load balancer to redirect active traffic to one node while the new application is being deployed.
Benefits
Parallel deployments do not affect the existing site
Have double the capacity for future expansion
Load balancing allows the load to be spread evenly across servers.
Drawbacks
Session now needs to be stored out-of-process. Therefore, you must check you can switch to an out-of-process session storage to confirm you do not have any serialization problems. StateServer is a quick one to get started with locally.
More maintenance overhead for a deployment, as you need to include load balancing configuration as part of your deployment processes. Network Admins are normally familiar with this.

IIS, EC2, Web Farm, Web Deploy and ELB

I'm a developer now developing my startup. I really don't know much about IIS setup. I will host my startup on Amazon EC2. And I want to know how can I scale my application if my traffic increase. I been reading about MS Deploy and Web Farm Framework here: https://serverfault.com/questions/127409/iis-configuration-synchronization-for-web-server-farm . And I want a simple architecture, with not to much configuration. So I been looking an experience with an IIS web farm and Amazon ELBs. And I did not find any one.
So the question is:
It is possible to make a IIS web farm with Amazon ELBs?
Any experience on Ec2? IIS web deploy or WFF and/or without ELBs?
What you recommend for an easy web farm setup?
You can do almost anything you want with IIS on EC2. They are full servers (well window 2k8 datacenter edition) and you can open any ports you need to communicate between servers. Here is an explicit tutorial on how to set up WFF, for example, on EC2.
The question is, are you sure you need to build a web farm? If you simply want to have multiple servers running your code then you can accomplish this without anything more than IIS and the tools that EC2 provides.
You build your app so it uses shared resources (like a session state server, central location for storing user uploaded content), configure a server the way you like it, and capture a server image (AMI). You use this image when you configure AutoScaling to launch new instances based on server metrics (like CPU usage), and they would be automatically added to the load balancer when launched.
The last challenge is ensuring servers launched automatically are running your latest code. You can write a custom program to get the latest code from somewhere (like SVN) on server startup, or you can use something much simpler like Dropbox to handle the synchronization.

Very weird IIS6 asp.net website behaviour

I have a weird issue with my website. This is asp.net(.net 3.5) website hosted on a dedicated server IIS6.
Recently I got a strange behavior, the website hangs and just doesn’t reply unless I go to iis and restart either app pool or whole IIS - BUT what is the most strange thing is that in case I go to remote desktop of the server and try to access it locally it DOES work just fine.
I read couple threads about deadlocking and hanging because of memory leaks and non closed sql connections BUT why it still does work from the local?
In case there is something wrong with the code – why does it still work from locally?
In case there is some issues on the hosting side (like firewall issues) then why does iisreset help?
Any thoughts would be appreciated. Thank you!
We've just run into this problem, and we have a solution. IIS has two thread pools to handle requests. One thread pool is used for external requests. Another pool is used for local requests. Our problem was caused by a deadlock in backend code. Once the deadlock occurred, all external requests were queued but not serviced because all of the servicing threads were in use. Opening the website from the web server uses the other thread pool, so the requests are serviced. We were absolutley positive it was a network issue, but WinDbg proved otherwise.
See here for more information:
MSDN blog entry about IIS and threads
minLocalRequestFreeThreads
(Also, search for minFreeThreads to see the non-local request thread pools.)
Good luck!
Are you sure that the website hangs for all external users, so that it's not just one single user?
The IIS only runs one page at a time for each user, so if one request is caught in an eternal loop, that single user will experience that the server has stopped completely as no pages at all work until that page times out. The server will still work as usual for other users.
You can test this by using a different browser, or starting a new instance of the same browser (possible with IE, not with Firefox).
Hmm not enough info to really give you an answer, but I would look at your firewall first if it responds locally from the server. Do you have another server behind the FW like a SQL server? Try browsing from that as it will show you where the problem is.
My though would be a badly configured load balancer.

Running asp.net app on localhost

This might be a 'duh' question after all.
Are there any caveats running an asp.net (3.5) application on a local host? Assuming I have all the required services installed, I am looking for pitfalls/ troubles in terms of
database access
reporting/ charting and other such features
performance
The main reason for this is that the app I am developing will be eventually hosted on a proper web server but till then I want to be able to use my app from a browser (for test, demos...).
[Note: till the time the app is hosted on a web server, only I will be using the app]
As long as you install all the same components (and the same versions of them to be 100% sure) on your computer as you have available on the server, there shouldn't be any difference at all in functionality. One thing to watch out for is that the app will certainly be less responsive when someone accesses it over the internet, compared to the client and server being the same machine.
You won't have any problems at all, this is how many people indeed test. When you are ready to move it online, just make sure the host supports everything you need.

Resources