문제

당사 웹 사이트의 새 버전을 배포하려면 다음을 수행합니다.

  1. 새 코드를 우편화하고 서버에 업로드하십시오.
  2. 라이브 서버에서 IIS 웹 사이트 디렉토리에서 모든 라이브 코드를 삭제하십시오.
  3. 새 코드 ZipFile을 Now Empty IIS 디렉토리로 추출하십시오.

이 프로세스는 모두 스크립트되어 있으며 매우 빨리 발생하지만 이전 파일이 삭제되고 새 파일이 배포 될 때 여전히 10-20 초의 다운 타임이있을 수 있습니다.

0 초 다운 타임 방법에 대한 제안이 있습니까?

도움이 되었습니까?

해결책

서버 2 개와로드 밸런서가 필요합니다. 다음은 다음과 같습니다.

  1. 서버 2의 모든 트래픽을 돌립니다
  2. 서버에 배포 1
  3. 테스트 서버 1
  4. 서버 1의 모든 트래픽을 돌립니다
  5. 서버 2에 배포됩니다
  6. 테스트 서버 2
  7. 두 서버에서 트래픽을 전환합니다

"스티커 세션"을 사용하는 경우이 경우 에도이 경우에도 응용 프로그램이 다시 시작되고 세션 손실이 있습니다. 데이터베이스 세션이나 상태 서버가있는 경우 모든 것이 정상입니다.

다른 팁

그만큼 Microsoft 웹 배포 도구 이것을 어느 정도 지원합니다.

Windows Transactional File System (TXF) 지원을 활성화합니다. TXF 지원이 활성화되면 파일 작업은 원자입니다. 즉, 그들은 성공하거나 완전히 실패합니다. 이를 통해 데이터 무결성을 보장하고 "반쯤"또는 손상된 상태에서 데이터 또는 파일이 기존에서 나오는 것을 방지합니다. MS 배포에서 TXF는 기본적으로 비활성화됩니다.

트랜잭션은 전체 동기화에 대한 것 같습니다. 또한 TXF는 Windows Server 2008의 기능 이므로이 트랜잭션 기능은 이전 버전에서는 작동하지 않습니다.

폴더를 버전 및 IIS 대사로 사용하여 0 다운 타임으로 스크립트를 수정할 수 있다고 생각합니다.

  • 기존 경로/URL의 경우 :
  • 새 (또는 수정 된) 웹 사이트를 서버에 복사합니다.
    • web app v2.1
  • 웹 사이트 경로를 변경하려면 IIS 대사를 수정하십시오
    • ~에서 web app 2.0
    • 에게 web app v2.1

이 방법은 다음과 같은 이점을 제공합니다.

  • 새 버전이 문제가있는 경우 v2.0으로 쉽게 롤백 할 수 있습니다.
  • 여러 물리적 또는 가상 서버에 배포하려면 파일 배포에 스크립트를 사용할 수 있습니다. 모든 서버에 새 버전이 있으면 Microsoft 웹 배포 도구를 사용하여 모든 서버의 대사를 동시에 변경할 수 있습니다.

다른 포트의 두 로컬 IIS 사이트 간의 소프트웨어로드 밸런서로서 IIS의 응용 프로그램 요청 라우팅을 사용하여 단일 서버에서 제로 다운 타임 배포를 달성 할 수 있습니다. 이것은 a로 알려져 있습니다 블루 그린 배포 전략 주어진 시간에로드 밸런서에서 두 사이트 중 하나만 사용할 수 있습니다. "다운"인 사이트에 배치하고 워밍업 한 다음로드 밸런서 (보통 응용 프로그램 요청 라우팅 건강 검사를 통과하여)로 가져온 다음 "풀"에서 올라간 원본 사이트를 가져옵니다 (다시. 건강 점검 실패로 인해).

전체 튜토리얼은 여기에서 찾을 수 있습니다.

나는 최근에 이것을 겪었고 내가 생각해 낸 해결책은 IIS에 두 개의 사이트를 설치하고 그들 사이를 전환하는 것이 었습니다.

내 구성의 경우 다음과 같은 각 A 및 B 사이트에 대한 웹 디렉토리가있었습니다.

IIS에는 각각 자체 애플리케이션 풀이있는 두 개의 동일한 사이트 (동일한 포트, 인증 등)가 있습니다. 사이트 중 하나가 실행 중입니다 (A)이고 다른 하나는 중지됩니다 (B). Live One에는 라이브 호스트 헤더도 있습니다.

라이브 배치에 관해서는, 나는 중지 된 사이트의 위치에 간단히 게시합니다. 포트를 사용하여 B 사이트에 액세스 할 수 있으므로 사이트를 미리 따뜻하게하여 첫 번째 사용자가 응용 프로그램을 시작하지 않습니다. 그런 다음 배치 파일을 사용하여 라이브 호스트 헤더를 B로 복사하고 A 중지 및 시작 B를 시작합니다.

Microsoft.web.administration의 ServerManager 클래스를 사용하여 자체 배포 에이전트를 개발할 수 있습니다.

요령은 가상 디렉토리의 물리 경로를 변경하여 구식 웹 앱과 새로운 웹 앱 사이의 온라인 원자 전환을 초래하는 것입니다.

이로 인해 구식 및 새로운 앱 도메인이 병렬로 실행될 수 있습니다!

문제는 데이터베이스 등에 변경 사항을 동기화하는 방법입니다.

구식 또는 새로운 물리적 경로로 앱 도메인의 존재에 대한 여론 조사를 통해 오래된 앱 도메인이 종료되었을 때와 새로운 앱 도메인이 시작된 경우를 감지 할 수 있습니다.

AppDomain이 시작하도록 강요하려면 HTTP 요청을해야합니다 (IIS 7.5는 AutosTART 기능을 지원합니다).

이제 새로운 AppDomain에 대한 요청을 차단하는 방법이 필요합니다. 배포 에이전트가 생성하고 소유 한 명명 된 MUTEX를 사용하고 새 웹 앱의 application_start가 기다린 다음 데이터베이스 업데이트가 작성되면 배포 에이전트가 출시합니다.

(웹 앱에서 마커 파일을 사용하여 Mutex 대기 동작을 활성화합니다) 새 웹 앱이 실행되면 마커 파일을 삭제합니다.

OK so since everyone is downvoting the answer I wrote way back in 2008*...

I will tell you how we do it now in 2014. We no longer use Web Sites because we are using ASP.NET MVC now.

We certainly do not need a load balancer and two servers to do it, that's fine if you have 3 servers for every website you maintain but it's total overkill for most websites.

Also, we don't rely on the latest wizard from Microsoft - too slow, and too much hidden magic, and too prone to changing its name.

Here's how we do it:

  1. We have a post build step that copies generated DLLs into a 'bin-pub' folder.

  2. We use Beyond Compare (which is excellent**) to verify and sync changed files (over FTP because that is widely supported) up to the production server

  3. We have a secure URL on the website containing a button which copies everything in 'bin-pub' to 'bin' (taking a backup first to enable quick rollback). At this point the app restarts itself. Then our ORM checks if there are any tables or columns that need to be added and creates them.

That is only milliseconds downtime. The app restart can take a second or two but during the restart requests are buffered so there is effectively zero downtime.

The whole deployment process takes anywhere from 5 seconds to 30 minutes, depending how many files are changed and how many changes to review.

This way you do not have to copy an entire website to a different directory but just the bin folder. You also have complete control over the process and know exactly what is changing.

**We always do a quick eyeball of the changes we are deploying - as a last minute double check, so we know what to test and if anything breaks we ready. We use Beyond Compare because it lets you easily diff files over FTP. I would never do this without BC, you have no idea what you are overwriting.

*Scroll to the bottom to see it :( BTW I would no longer recommend Web Sites because they are slower to build and can crash badly with half compiled temp files. We used them in the past because they allowed more agile file-by-file deployment. Very quick to fix a minor issue and you can see exactly what you are deploying (if using Beyond Compare of course - otherwise forget it).

The only zero downtime methods I can think of involve hosting on at least 2 servers.

I would refine George's answer a bit, as follows, for a single server:

  1. Use a Web Deployment Project to pre-compile the site into a single DLL
  2. Zip up the new site, and upload it to the server
  3. Unzip it to a new folder located in a folder with the right permissions for the site, so the unzipped files inherit the permissions correctly (perhaps e:\web, with subfolders v20090901, v20090916, etc)
  4. Use IIS Manager to change the name of folder containing the site
  5. Keep the old folder around for a while, so you can fallback to it in the event of problems

Step 4 will cause the IIS worker process to recycle.

This is only zero downtime if you're not using InProc sessions; use SQL mode instead if you can (even better, avoid session state entirely).

Of course, it's a little more involved when there are multiple servers and/or database changes....

To expand on sklivvz's answer, which relied on having some kind of load balancer (or just a standby copy on the same server)

  1. Direct all traffic to Site/Server 2
  2. Optionally wait a bit, to ensure that as few users as possible have pending workflows on the deployed version
  3. Deploy to Site/Server 1 and warm it up as much as possible
  4. Execute database migrations transactionally (strive to make this possible)
  5. Immediately direct all traffic to Site/Server 1
  6. Deploy to Site/Server 2
  7. Direct traffic to both sites/servers

It is possible to introduce a bit of smoke testing, by creating a database snapshot/copy, but that's not always feasible.

If possible and needed use "routing differences", such as different tenant URL:s (customerX.myapp.net) or different users, to deploy to an unknowing group of guinea pigs first. If nothing fails, release to everyone.

Since database migrations are involved, rolling back to a previous version is often impossible.

There are ways to make applications play nicer in these scenarios, such as using event queues and playback mechanisms, but since we're talking about deploying changes to something that is in use, there's really no fool proof way.

This is how I do it:

Absolute minimum system requirements:
1 server with

  • 1 load balancer/reverse proxy (e.g. nginx) running on port 80
  • 2 ASP.NET-Core/mono reverse-proxy/fastcgi chroot-jails or docker-containers listening on 2 different TCP ports
    (or even just two reverse-proxy applications on 2 different TCP ports without any sandbox)

Workflow:

start transaction myupdate

try
    Web-Service: Tell all applications on all web-servers to go into primary read-only mode 
    Application switch to primary read-only mode, and responds 
    Web sockets begin notifying all clients 
    Wait for all applications to respond

    wait (custom short interval)

    Web-Service: Tell all applications on all web-servers to go into secondary read-only mode 
    Application switch to secondary read-only mode (data-entry fuse)
    Updatedb - secondary read-only mode (switches database to read-only)

    Web-Service: Create backup of database 
    Web-Service: Restore backup to new database
    Web-Service: Update new database with new schema 

    Deploy new application to apt-repository 
    (for windows, you will have to write your own custom deployment web-service)
    ssh into every machine in array_of_new_webapps
    run apt-get update
    then either 
    apt-get dist-upgrade
    OR
    apt-get install <packagename>
    OR 
    apt-get install --only-upgrade <packagename>
    depending on what you need
    -- This deploys the new application to all new chroots (or servers/VMs)

    Test: Test new application under test.domain.xxx
    -- everything that fails should throw an exception here
    commit myupdate;

    Web-Service: Tell all applications to send web-socket request to reload the pages to all clients at time x (+/- random number)
    @client: notify of reload and that this causes loss of unsafed data, with option to abort 

    @ time x:  Switch load balancer from array_of_old_webapps to array_of_new_webapps 
    Decomission/Recycle array_of_old_webapps, etc.

catch
        rollback myupdate 
        switch to read-write mode
        Web-Service: Tell all applications to send web-socket request to unblock read-only mode
end try 

I would suggest keeping the old files there and simply overwriting them. That way the downtime is limited to single-file overwrite times and there is only ever one file missing at a time.

Not sure this helps in a "web application" though (i think you are saying that's what you're using), which is why we always use "web sites". Also with "web sites" deploying doesn't restart your site and drop all the user sessions.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top