C# Blazor Zero Downtime Deployment — Deploy

Blazor Zero Downtime

C# Blazor Zero Downtime Deployment Rolling Update Blue-Green Canary SignalR Health Check Graceful Shutdown Kubernetes Production
| Strategy | Downtime | Rollback | Resource | Complexity |
|---|---|---|---|---|
| Rolling Update | Zero | Rolling Back | +1 Pod | ต่ำ |
| Blue-Green | Zero | Instant (สลับ Traffic) | 2x Resource | ปานกลาง |
| Canary | Zero | ส่ง 100% กลับเวอร์ชันเก่า | +10-20% Resource | สูง |
| Recreate | มี Downtime | Deploy เวอร์ชันเก่า | ปกติ | ต่ำ |
Rolling Update Configuration
# === Blazor Server Rolling Update === # apiVersion: apps/v1 # kind: Deployment # metadata: # name: blazor-app # spec: # replicas: 3 # strategy: # type: RollingUpdate # rollingUpdate: # maxSurge: 1 # maxUnavailable: 0 # template: # spec: # terminationGracePeriodSeconds: 60 # containers: # - name: blazor # image: registry.example.com/blazor-app:v2.0 # ports: # - containerPort: 8080 # lifecycle: # preStop: # exec: # command: ["/bin/sh", "-c", "sleep 15"] # readinessProbe: # httpGet: # path: /health/ready # port: 8080 # initialDelaySeconds: 5 # periodSeconds: 5 # failureThreshold: 3 # livenessProbe: # httpGet: # path: /health # port: 8080 # initialDelaySeconds: 15 # periodSeconds: 10 # minReadySeconds: 10 # Program.cs - Graceful Shutdown # var builder = WebApplication.CreateBuilder(args); # builder.Services.AddHealthChecks() # .AddDbContextCheck("database") # .AddCheck("signalr", () => HealthCheckResult.Healthy()); # # var app = builder.Build(); # app.MapHealthChecks("/health"); # app.MapHealthChecks("/health/ready"); # # app.Lifetime.ApplicationStopping.Register(() => { # Log.Information("Shutting down gracefully..."); # Thread.Sleep(10000); // Wait for connections to drain # }); from dataclasses import dataclass @dataclass class RollingConfig: setting: str value: str purpose: str blazor_note: str configs = [ RollingConfig("maxSurge", "1", "เพิ่ม Pod ใหม่ 1 ตัวก่อนลบ Pod เก่า", "Pod ใหม่ต้อง Ready ก่อนรับ SignalR Connections"), RollingConfig("maxUnavailable", "0", "ห้ามลด Pod จนกว่า Pod ใหม่ Ready", "ป้องกัน Connection Drop ระหว่าง Deploy"), RollingConfig("minReadySeconds", "10", "รอ 10 วินาทีหลัง Ready ก่อนดำเนินการต่อ", "ให้ SignalR Hub เริ่มต้นเสร็จสมบูรณ์"), RollingConfig("terminationGracePeriodSeconds", "60", "รอ 60 วินาทีก่อน Force Kill", "ให้เวลา SignalR Connection Drain"), RollingConfig("preStop sleep 15", "sleep 15", "รอ 15 วินาทีก่อน SIGTERM", "ให้ Endpoint ถูกถอดจาก Service ก่อน"), ] print("=== Rolling Update Config ===") for c in configs: print(f" [{c.setting}] = {c.value}") print(f" Purpose: {c.purpose}") print(f" Blazor: {c.blazor_note}")เคล็ดลับ

- preStop: ใช้ preStop sleep 15 ก่อน SIGTERM ให้ Endpoint ถูกถอด
- Drain: ตั้ง terminationGracePeriodSeconds 60 รอ Connection Drain
- Redis: ใช้ Redis Backplane สำหรับ SignalR Multi-pod
- Blue-Green: เก็บ Environment เก่าไว้ 24 ชม. ก่อนลบ
- Test: รัน Smoke Test ก่อน Switch Traffic ทุกครั้ง
Zero Downtime Deployment คืออะไร
Deploy ไม่หยุดบริการ Rolling Update Blue-Green Canary SignalR Graceful Shutdown Circuit Reconnect Kubernetes ผู้ใช้ไม่รู้สึก
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ PostgreSQL JSONB Learning Path Roadmap
Rolling Update ทำอย่างไร
maxSurge 1 maxUnavailable 0 minReadySeconds 10 terminationGracePeriod 60 preStop sleep Readiness Probe PDB SignalR Drain
แนะนำเพิ่มเติม — อีบุ๊กการลงทุน SiamCafeBook
เนื้อหาเกี่ยวข้อง — ดูเพิ่มเติมเรื่อง Jaeger Tracing Production Setup Guide
Blue-Green Deployment ทำอย่างไร
2 Environment Blue Green Deploy Green Test Switch Traffic Service Selector Instant Rollback 2x Resource Smoke Test Monitor
Health Check ตั้งอย่างไร
ASP.NET Core AddHealthChecks Liveness /health Readiness /health/ready Startup Probe Database Redis SignalR Graceful Shutdown SIGTERM
แนะนำเพิ่มเติม — iCafeForex
เนื้อหาเกี่ยวข้อง — อ่านต่อ: interest rate แปลว่า
สรุป
C# Blazor Zero Downtime Rolling Update Blue-Green Canary SignalR preStop Graceful Shutdown Health Check Redis Backplane Kubernetes Production
เนื้อหาเกี่ยวข้อง — บทความที่เกี่ยวข้อง: Htmx Alpine.js Monitoring และ Alerting





