การ Scaling แอปพลิเคชันใน AKS

Azure Compute Solutions

Florin Angelescu

Azure Cloud Architect

ทำไม Scaling จึงสำคัญ

 

ทราฟฟิกต่ำ

ทราฟฟิกสูง

 

  • แอปพลิเคชันแทบไม่เคยมีทราฟฟิกคงที่:

    • บางช่วงเวลาอาจเงียบสงัด
    • บางช่วงมีการใช้งานพุ่งสูง
  • หากไม่มีการ scaling:

    • Workload เสี่ยงต่อการโอเวอร์โหลด
    • ส่งผลให้ประสิทธิภาพตกหรือระบบล่ม
Azure Compute Solutions

ทำไม Scaling จึงสำคัญ

 

Kubernetes

 

  • Kubernetes มีกลไกสำหรับปรับทรัพยากรได้แบบไดนามิก
  • แอปพลิเคชันรับมือกับความต้องการได้อย่างมีประสิทธิภาพ
  • Scaling ช่วยให้:
    • ผู้ใช้ได้รับประสบการณ์ที่สม่ำเสมอ
    • องค์กรบริหารต้นทุนได้อย่างเหมาะสม
Azure Compute Solutions

Manual Scaling

Manual Scaling

เพิ่มหรือลดจำนวน replica ใน deployment ด้วย kubectl scale

Azure Compute Solutions

Manual Scaling

Manual Scaling

การ scale web app จาก 2 replica เป็น 4:

  • ทำให้มี pod พร้อมรับ request มากขึ้น
Azure Compute Solutions

Manual Scaling

 

Manual Scaling

Manual Scaling

 

 

เหมาะสำหรับ:

  • การเปิดตัวสินค้าที่วางแผนไว้
  • โปรโมชัน
  • การลดราคาสินค้า
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

ตรวจสอบ metric (การใช้ CPU และหน่วยความจำ) แล้วปรับจำนวน replica โดยอัตโนมัติ

Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

การใช้งานเกินค่าที่กำหนด:

  • สร้าง pod เพิ่มขึ้น
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

ความต้องการลดลง:

  • ลบ pod ที่ไม่จำเป็นออก
Azure Compute Solutions

Horizontal Pod Autoscaler (HPA)

HPA

  • ทำงานร่วมกับ Azure Monitor
  • รองรับ custom metric (request latency, queue length)
Azure Compute Solutions

Cluster Autoscaler

 

Autoscaler

 

 

  • เพิ่มหรือลบ node ตามความต้องการ
  • เมื่อ pod ไม่สามารถ schedule ได้เนื่องจากทรัพยากรไม่เพียงพอ:
    • จะเพิ่ม node ใหม่โดยอัตโนมัติ
Azure Compute Solutions

Cluster Autoscaler

 

Autoscaler

 

 

  • ความต้องการลดลง:

    • ลบ node ที่ไม่ได้ใช้เพื่อประหยัดต้นทุน
  • โครงสร้างพื้นฐานสอดคล้องกับความต้องการของ workload:

    • โดยไม่ต้องจัดสรรทรัพยากรเกินความจำเป็น
Azure Compute Solutions

แนวปฏิบัติที่ดีสำหรับการ Scaling

Metrics

กำหนด resource request และ limit ที่สมเหตุสมผล

Combine

ใช้ Horizontal Pod Autoscaler ร่วมกับ Cluster Autoscaler

Test

ทดสอบพฤติกรรมการ scaling ภายใต้โหลด

Cost

ติดตามต้นทุน

Azure Compute Solutions

สรุป

 

Kubernetes

  • Scaling ใน AKS ช่วยให้แอปพลิเคชันปรับตัวตามความต้องการโดยอัตโนมัติ:
    • Manual scaling
    • Horizontal Pod Autoscaler
    • Cluster Autoscaler
  • สมดุลระหว่างประสิทธิภาพและความคุ้มค่า
Azure Compute Solutions

มาฝึกกันเถอะ!

Azure Compute Solutions

Preparing Video For Download...