Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy ASP.NET web site and Update MSSQL database with zero downtime

I have question about ASP.NET web site and MSSQL database deployment. We are hosting asp.net web site and developed new version, the some asp.net files are changed and database is modified a little. What is the best why to upload new version of web site and upgrade MSSQL database without downtime?

like image 871
Tomas Avatar asked Apr 11 '11 08:04

Tomas


2 Answers

I've managed a large website for the past 5 years with monthly releases and manage to have zero downtime more than 95% of the time. The key, unfortunately, is ensuring that the database is always backwards compatible, but only to the previous release, so you have the opportunity to rollback.

So, if you plan to drop a column, for example, that your application depends on:

  1. Change your application code to not depend on the column, and release that (without removing the column in the database).
  2. In the next release drop the column (as the application no longer relies on it).

It takes some discipline from your dev team, but is surprisingly easy to achieve if you have proper the right environments setup (dev/test/staging/production).

When you release:

  1. Deploy database changes to a staging environment, which is as close to production as possible. Do this preferably in an automated fashion, using something like SQL Compare and SQL Data Compare, so you know the database is completely up to date with your test environment.
  2. Perform "smoke tests" using the old application, but the new database schema, ensuring no major breaking changes have been introduced to the database.
  3. Release your application code.
  4. Smoke test your staging application.
  5. Release to production.

Another thing we do to ensure zero downtime on the website is blue-green deployment. This involves having 2 folders for each website, updating one and switching the IIS home directory once it is up to date. I've blogged about this here: http://davidduffett.net/post/4833657659/blue-green-deployment-to-iis-with-powershell

like image 89
David Duffett Avatar answered Oct 27 '22 12:10

David Duffett


Not to do it. Point.

ZERO downtime installs´s are VERY hard to do and involve multipel copies of the database, prechecking it in a staging engironment, carefull programming and resyncing the database.

It is pretty much always better to take a small downtime. Sleep long in the night, deploy at 2 in the morning. Or wake up earlier. Identify when it is lease inconvenient for your users.

100% uptime is VERY expensive to imeplement, in terms of the amount of time spent on it. Unless here is a strict business case for it, occasional downtime is a much saner busienss decision.

like image 32
TomTom Avatar answered Oct 27 '22 12:10

TomTom