Eventarc: Messaging Services สำหรับ Dev สายซิ่ง

Redbulls Thailand
Google Cloud Thailand
2 min readApr 26, 2023

#event-driven #eventarc #pubsub #integration #appdev

Eventarc (GA ในต้นปี 2021) เป็น Serverless Messaging Solution อีกรูปแบบนึงที่ต่อยอดจากบริการเดิมอย่าง Cloud Pub/Sub และ ทยอยเพิ่มความสามารถใหม่ๆให้รองรับ Native Events จาก Sources ต่างๆ ทั้งที่อยู่บน Google Cloud และ 3rd-Party Providers, รวมถึงรองรับ Targets ใหม่ๆในการ Trigger Events อย่าง Workflow & GKE:

ภาพรวมของ Eventarc

Eventarc Architecture Overview
  • Event Sources: ต้นทางที่ Generate Events และ รองรับโดย Eventarc เราสามารถแบ่ง Sources ได้ 2 แบบ คือ (1) Google Cloud Event Source (1-Party Events) ซึ่งมีทั้ง (a) Direct Events คือ Native Event จากตัว GCP Services เอง เช่น Cloud Storage และ Cloud Pub/Sub และ ยังมีอีกหลายตัวที่ยังเป็น Preview อยู่ (b) Cloud Audit Log Event คือ Events ที่ถูก Generate โดยการใช้ Cloud Audit Logs ซึ่งเป็นที่ทราบกันดีว่า Cloud Audit Logs สามารถรู้ว่า “ใครทำอะไร บน services ไหน เมื่อไหร่” และ (2) Third-Party (3P) Event Source ที่รองรับ เช่น Datadog, CloudGuard, ForgeRock และ Lacework ในอนาคตเราคงจะได้เห็น 3P Providers มากขึ้น
  • Event Targets/Event Trigger: ปลายทางที่ Events จะไป Trigger Application เพื่อทำงานต่อไป ปัจจุบันรองรับ 4 service — Cloud Functions (2nd Gen), Cloud Run, Workflow และ GKE (Preview)
  • Event Filter: Eventarc มีกลไกในการกรอง Event ที่สนใจผ่าน Event Filter เช่น สนใจเฉพาะ Event ที่มีการ Create/Update File บน Cloud Storage (Event Source = Google Cloud และ Event Provider = google.cloud.storage.object.v1.finalized), จากนั้น เมื่อ Event ที่สนใจเข้ามาแล้วก็จะนำไปสร้างเป็น CloudEvent เพื่อ Trigger Application ของเราต่อไป
  • CloudEvent: เป็นมาตรฐานกลาง (Specification)ในการกำหนดรูปแบบของ Event Data Format เพื่อให้สามารถสื่อสาร และ ทำงานร่วมกันได้ในหลากหลาย services และ platform. Specification นี้ยังถูกดูแลโดย Cloud-Native Computing Foundation (CNCF). ปัจจุบัน CloudEvent บน GCP ใช้เวอร์ชั่น 1.01 อยู่. Event ที่สนในเมื่อเข้ามาใน Eventarc แล้วก็จะถูกปั้นให้อยู่ในรูปแบบ CloudEvent JSON นั้นเอง แล้วส่งต่อไป Trigger Application. Application ปลายทางเพียง extract data (data field ใน JSON) จาก CloudEvent เพื่อนำไปใช้ประโยชน์ต่อไป
Specification of CloudEvent v1.01 on GCP

จุดเด่นของ Eventarc

  • เน้นความสะดวกรวดเร็วในการนำไปใช้การพัฒนา Event-Driven Application Development ได้ทันที และ ไม่ต้องลงแรงเยอะๆเหมือนอย่าง Cloud Pub/Sub เช่น การสร้างและจัดการเรื่อง Topic/Subscription. Eventarc จะช่วย abstract การสร้าง Cloud Topic/Subscription ให้อัตโนมัติ
  • Eventarc อาศัย Cloud Pub/Sub เป็น core messaging/transport layer ดังนั้นทั้งในแง่ Characteristics, Performance และ Cost จะเทียบเท่า Cloud Pub/Sub.
  • ราคา Eventarc แสนจะถูกเหมือนให้เปล่า โดยเฉพาะ Events ที่ถูก Generate ที่มาจาก Google Cloud Sources แล้วนำไปใช้ไม่ว่าจะกี่ร้อยล้าน Event ก็ตาม ราคาเป็น $0 !!!! อย่างไรก็ตาม services ค้างเคียงที่ Eventarc ใช้ อย่างเช่น Cloud Pub/Sub และ Cloud Audit Logs ลูกค้าก็ยังต้องจ่ายในราคาเดิมอยู่
Eventarc Pricing
  • ปัจจุบัน Eventarc รองรับ Google Cloud Events > 130 จากหลายๆ GCP Services จึงเหมาะสมต่อหลายๆ Use Cases ในการเขียน Event-Driven Application บนสิ่งที่อยู่บน Google Cloud เช่น (1) การ Process Orders/Transactions (2) การพัฒนา Workflow ต่างๆ ทั้งของ Application และ ของ ML pipeline (3) การทำ Real-Time Monitoring Events ต่างๆ

ใน Part ต่อไปเราจะมาลองเริ่มใช้งาน Eventarc กันน่ะครับ ^^

ติดตามต่อได้:

--

--