Slack

เมื่อต้นปีที่ผ่านมา Slack มีเหตุล่ม 3 ชั่วโมง สัปดาห์นี้ทีมงานก็ออกมารายงานถึงสาเหตุของการล่มครั้งนั้น โดยจุดเริ่มต้นเกิดระหว่างการอัพเกรด Consul แม้จะอัพเกรดเพียงบางส่วน

ทาง Slack ใช้ Consul สำหรับทำ service discovery ให้กับ memcached กระบวนการอัพเกรดครั้งนั้นเป็นการอัพเกรดทีละ 25% โดยอัพเกรด 25% แรกไปก่อนแล้วและไม่มีปัญหาอะไร โดยระหว่างอัพเกรด โหนดที่อัพเกรดจะถอดตัวออกไปและใส่โหนดใหม่ที่ cache ว่างเข้ามาแทน แต่ระหว่างการอัพเดตครั้งนั้นระบบมีโหลดสูง และเมื่อกำลังอัพเกรดก็มี memcached บางส่วนถูกล้างข้อมูล

ปัญหาเกิดขึ้นเมื่อการคิวรี Group Direct Message (GDM) นั้น ไม่ได้ค้นหาแยกตาม shard ของคลัสเตอร์ Vitess (คลัสเตอร์ MySQL) แต่กลับทำ scatter query ส่งคิวรีไปทุก shard เพื่อหาข้อมูล และเมื่อแคชหายไป ตัวไคลเอนต์ก็จะยิงคิวรีเข้า Vitess ทำให้โหลดโดยรวมสูงขึ้น คลัสเตอร์ Vitess เริ่มเกิด timeout ทำให้ข้อมูลไม่ถูกแคช เกิดเป็นปัญหาวนลูปคือไคลเอนต์ที่ขอข้อมูลไม่ได้ก็พยายามยิงคิวรีเข้าไปเรื่อยๆ และแคชก็ไม่มีข้อมูลทำให้ยิงคิวรีตรงเข้า Vitess ไปเรื่อยๆ อีกเช่นกัน

ทาง Slack สรุปบทเรียนโดยปรับกระบวนการอัพเกรด Consul ไม่ให้สร้างปัญหาแบบนี้อีก และแก้ไข scatter query เดิมให้คิวรีแยกตาม shard เพื่อไม่ให้เกิดโหลดสูงอีกครั้ง

ที่มา - Slack

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ยิ่งระบบซับซ้อนยิ่งประเมินยากครับ บางทีคิดว่าออกแบบไว้ดีมากแล้ว แต่โดน "พฤติกรรมการทำงานร่วมกันระหว่าง service" (ทำงานเดี่ยวๆ ไม่เป็น แต่พอไปใช้ x คู่กับ y แล้วเป็น) บางอย่างเข้าไป ก็ระเบิดกันมาเยอะแล้วครับ

ลักษณะนี้ก็น่าจะเข้าข่าย

กำลังอยากเก่งด้าน availability เลยครับ แต่เคสแบบนี้ถ้ากันได้ 100% เรียกว่าเทพคงยังดูเก่งไม่พอใช่มั้ยครับ

ระบบที่ซับซ้อนขนาดนี้ มักไม่ใช่ระบบที่เกิดจากคนคนเดียว (หรือหลักหน่วยคน) ครับ มันคือระบบที่เกิดจากคนหลายสิบคน หลายแผนก หลายหน่วยงานมาร่วมกันสร้างขึ้นมา

ซึ่งความเข้าใจการทำงานของระบบของแต่ละคนมีจำกัด จะเก่งแค่ไหนก็ไม่มีวันไปเข้าใจทุกอย่างในระบบได้ ก็ต้องอาศัย learn by mistake แบบนี้ไปเรื่อยๆ ครับ

อย่างกรณีนี้

  • ทีม upgrade Consul แค่ทีละ 25% ไม่เป็นอะไรหรอก แคชไม่ได้ดับหมด
  • คนเขียน GDM ถ้า cache missed บางส่วนก็คิวรีตรงไปเลย ไม่เป็นไรหรอก โหลดไม่ได้มาก
  • คนออกแบบคิวรี เราคิวรีตาม shard แทบหมด มีแค่บางอันจะกระจายทุก shard บ้างไม่น่าเป็นอะไร โหลดไม่ได้มากมาย

พอประกอบร่างในเวลาเดียวกัน ก็กลายเป็น Transformer

มันเป็น Murphy's Law น่ะครับ เก่งแค่ไหนมันก็จะมีจุดที่พังได้เสมอ หน้าที่ของชาวเรา (หมายถึงทั้ง Engineer ต่างๆ) ก็คือทำให้มันมีโอกาสพังน้อยที่สุด แล้วถ้ามันพังอยู่ก็ให้มันกระทบน้อยที่สุด