Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Ruby

Citadel Architecture at AppSignal: Unified Monolith & Specialized Outposts

DHH เพิ่ง coined term "Citadel" ซึ่งสุดท้ายให้เรา excellent way อ้างอิง how we approach tech ที่ AppSignal เราบอกว่า "Hey, this is us! Our thing has a name now"

เพื่ออธิบาย AppSignal ใช้ Citadel pattern จะ share บิตรับบ้างเกี่ยวกับ system ของเรา AppSignal เป็น monitoring product ที่มี user-facing application และ API ที่ monitoring agent ส่ง data ไป Data นี้จะ processed และกลายเป็น graphs และ insights

Monolith

Application ที่ customers interact คือ monolithic Rails app พร้อมส่วน front-end เขียนใน React Backend เขียน entirely ใน Ruby และพูดคุยกับหลาย databases (split ข้อมูลจาก customers ต่างๆ ไป separate clusters สำหรับ scaling reasons) Rails app นี้ยัง handle tasks อื่นๆ เช่นส่ง alerts ไป external services

ตอนเริ่ม Rails app นี้ process incoming data จาก monitoring agent ด้วย เรา foresaw data ingestion จะกลายเป็น bottleneck ใช้ Sinatra app รันบน subdomain ingest data และสร้าง Sidekiq jobs ที่ processed โดย Rails app

Growing Pains (ความเจ็บปวดการเติบโต)

Architecture นี้ work well หลายปี ธุรกิจโต ชัดเจนว่า task เฉพาะ processing incoming data จาก agents จะต้อง special treatment เมื่อ monitor billions และ billions ของ requests จะเจอ hard limits Main limiting factor ไม่ใช่ Ruby ช้า (เรารู้ทั้งหมดว่าไม่ช้า 😉) แต่วิธีที่เรา architect things caused too much locking ใน databases

An Outpost (สเต็ปหน้าที่)

ดู several possibilities แล้วตัดสินใจ Kafka เป็น best fit สำหรับสถานการณ์เรา มี experience กับ Rust คิดว่า speed และ reliability จะ fit ดีสำหรับ system นี้ Rewrite data ingestion และ processing system ใน Rust ใช้ Kafka as combination ของ queue และ storage system

ย้ายแค่ incoming data processing part ของ Rails app ไป outpost service นี้ ส่วนที่เหลือของ systems ทำงานดีในรูป monolithic app เราเข้าใจมันลึก และชอบเก็บสิ่งๆ ให้ simple Monolith ยัง handle logic ส่วนใหญ่และ interact กับ Kafka เข้มข้น ความอยากเก็บ monolith นำไปสู่การเขียน Kafka gem เพื่อ main app communicate กับ outpost ได้ง่าย

อยากเรียนรู้เพิ่มเติม Kafka works ที่ AppSignal เช็ค Railsconf talk ที่ผมให้

Life at the Citadel (ชีวิตที่ Citadel)

นี่นำไปสู่ current situation ที่เรา very happy ใน citadel ตาม DHH กล่าว:

A single Majestic Monolith captures the majority mass of the app with a few auxiliary outpost apps for highly specialized and divergent needs.

ในกรณีเรา มี single outpost service สำหรับ highly specialized needs ถ้ามี RailsConf ปีนี้ เราจะให้ DHH extra stroopwafels เป็น appreciation สำหรับการตั้งชื่อ 🍪