AWS ElasticBeanstalk — 101

Mart — Tanathip Viriya
1 min readJun 9, 2020

--

เป็น service ที่ช่วยในการ deploy และ scale web applications โดยรองรับหลายภาษามาก ซึ่งจะช่วยในการให้เราสนใจแต่ตัว code ของ application นั้นเอง ไม่ต้องสนใจเรื่องการสร้าง ingrastructure บน cloud เลย

ซึ่งรวมถึงการ Monitoring ซึ่งมัน integrated รวมกับ Cloudwatch และ X-ray ไว้แล้ว และดู application health ผ่าน dashboard ของ ElasticBeanstalk เอง

ElasticBeanstalk Configuration

แทนที่เราจะมา configuration เองผ่าน GUI เราใช้ configuration ที่เขียนด้วย YAML หรือ JSON ก็ได้ โดยขอให้มี extension ชื่อว่า .ebextensions

โดยให้สร้างไฟล์นี้ไว้ที่ Root directory เลย แล้วเวลา deploy application ขึ้นไป AWS ElasticBeanstalk จะหยิบขึ้นมาเอง

RDS กับ ElasticBeanstalk

มี 2 วิธีในการจัดการเรื่อง RDS กับ ElasticBeanstalk

  1. Launch within Elastic Beanstalk
    หมายถึง สร้างขึ้นมาใน EBS เลย เพียงแต่ว่าวิธีนี้จะทําให้เมื่อเรา terminate EBS environment มันก็จะ terminated ไปด้วย ซึ่งเหมาะกับ Dev และ Test เท่านั้น
  2. Launch outside of Elastic Beanstalk
    สร้างข้างนอก EBS environment แล้วใช้ configuration ชี้ไปที่ RDS ตัวนั้น โดยอาจจะต้องมี Security Group และ Connection information ที่ต้อง config เพิ่ม
    แต่เหมาะกับ Production environment เพราะมันยืดหยุ่นกว่า เมื่อมีการ terminate EBS environment ก็ยังสามารถใช้งานได้นั้นเอง

EBS Deployment Policies

  • All at once — ด้วยการ deploy แบบนี้คือ deploy all instance ในทีเดียว ทําให้มันเกิด downtime ไม่เหมาะกับ Production แน่นอน ซึ่งถ้าเกิดปัญหาเราต้อง manual redeploy
  • Rolling — deploy new version เป็น batches โดยค่อยๆ deploy ไปทีละ batch ซึ่งจะทําให้ capacity ลดลงระหว่าง deployment แต่ไม่หายไปในทีเดียว ไม่เหมาะกับ Performance sensitive system ซึ่งถ้าเกิดปัญหาเราต้อง manual redeploy
  • Rolling with additional batch — เพื่อที่จะไม่ทําให้ availability สูงตลอด ด้วยวิธีนี้ EBS สร้าง batch new instance แล้วค่อย rolling deployment เข้าไป ใช้งานพร้อม instance ปัจจุบัน ซึ่งถ้าเกิดปัญหาเราต้อง manual redeploy
  • Immutable — เป็นการ deployment ที่ช้าที่สุด โดยการสร้าง EC2 instance ใหม่ขึ้นมาเลยแทนที่จะทําการ Update ของเก่า ซึ่งมันดีเหมาะกับการทํา Safe Rollback มาก เพราะของเก่ายังอยู่บน instance เก่า ซึ่งถ้าเกิดปัญหาเราก็แค่ terminate instance เก่าๆออกไป

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response