SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
Running a Service in Production
without Losing Your Sanity
poga 

2019/10/24
Service?
• 24/7

• 持續不斷的更更新

• Web Service 為主,其他領
域也可適⽤用

• 衛星上的軟體很多概念念也相同

• Computer Science 不會教
Service!
• 早已是社會的⼀一部份

• Uber, Food Panda, Google, Facebook, Github, Slack, Telegram

• ⼀一個開發完成的 service:

• 在 production (real-world) 裡會動

• 能有效率的在 production (real-world) 中維護
Service Team Performance
• Time to Delivery

• Time to Recovery

• # of Failed Deploys

• Frequency of Deploys
Reliability Engineering
Designing Service
Reliability Engineering
Designing Service
Service 101
• 永遠先訂 Service-Level Objective

• SLO = 願意花多少資源維護

• Define SLO likes a User
「我們很厲害,所以
SLO 100%」?
「我們很厲害,所以
SLO 100%」?
SLO 不可以 100%
• 永遠不能出錯的系統 = 永遠沒辦法更更新的系統

• 極度保守 = 僵化 = 無法⾯面對變化 = 死亡

• SLO = 成本,⼯工程問題永遠是在有限的資源下做 trade off

• ⼈人⼒力力、成本、時程、邊際效應

• 你跟客⼾戶的距離,其實很遠

• 海海纜斷掉、天災、⾰革命、宇宙射線
「系統不應該出錯」?
「系統不應該出錯」?
Error Budget
• SLO = 99.5%, Error Budget = 0.5%

• 每年年有 1.83 天可以出包

• 就應該拿來來出包

• ⽤用來來⾯面對風險

• 架構調整,實驗、升級,各種改善
「SLO 是 Engine
Team 的事」?
「SLO 是 Engine
Team 的事」?
Production = Real World
• 開發產品

• 在真實世界中給⽤用⼾戶⽤用

• 在真實世界中維護

• SLO don't matter when USERS aren't HAPPY

• Developer 要能維護⾃自⼰己的產出
瞭解你的⽤用⼾戶
• 流量量的形狀狀

• 售票系統:peak 極⾼高,平時沒有流量量

• 2B:下班時間沒⼈人⽤用

• 2C:穩定的流量量?是否定期舉辦活動?

• 發佈的⽅方式

• 盛⼤大記者會?⼩小規模漸進式發佈?2B or 2C?
瞭解你的⽤用⼾戶
• 流量量「塑形」Traffic Shaping

• 把 peak traffic 攤平、打散

• Message Queue

• Load Balancing

• 直接篩選流量量:Cache

• QoS... etc
Design for Chaos
• 出錯是正常

• 系統出錯是⼀一件平凡無奇的事情

• 實作時就要考慮
Design for Chaos
• 爆炸範圍 Blast Radius

• 如果這個 component 出錯,會有多少其他 component
⼀一起被拖下⽔水?

• DNS = Blast Radius 極⼤大

• Blast Radius 越⼩小越好

• Blast Radius 越⼤大,越難除錯
Design for Chaos
• Service State

• 200:運作正常

• 500:爆炸了了

• 常被忽略略的 Lame Duck State

• Service 還在運作,但是已經不能接受更更多的負載

• 讓上游知道,才能作對應處置
Design for Chaos
• Back pressure / cancellation

• 下游撐不住了了,上游該怎麼辦?

• 取消

• 暫時等⼀一陣⼦子,retry

• exponential fallback

• thundering herd

• 50%+ 的 global outage 都是因為 back pressure 沒做好⽽而發⽣生的 cascading
Failure
• 這類 outage 非常難解決,會像葡萄串串⼀一樣⼀一個⼀一個把系統拉垮
瞭解你的資料
• Transactional

• semi-realtime,不能錯

• 銀⾏行行、售票、⾦金金流

• Analytical

• batch、資料量量⼤大、可以重試

• 資料分析、訓練模型

• Design for WRITE or READ
Security
• 70% 的 CVE 都是 memory safety 問題
Security
• 太多了了講不完

• OWASP top 10

• SQL Injection

• select * from users where id = {}

• {} = "105 or 1 = 1"

• 少寫 C/C++
Designing Service
• 訂定 SLO

• 瞭解你的⽤用⼾戶

• Traffic Shaping

• Design for Chaos

• 瞭解你的資料

• Security
RECAP
Reliability Engineering
Designing Service
Service Reliability Engineering (SRE)
• Reliable Service = Observable Service

• SRE Team IS NOT Operation Team
Capacity Planning
• 永遠不準

• N + 2 原則
Observability
• 從外部變量量推測內部系統運作

• 控制理理論

• or「沒有 log 就不⽤用想 debug 了了,都是通靈」
Dashboard?
Dashboard
• 幾乎沒有實際⽤用處

• 架起來來很簡單,看起來來很酷

• 「dashboards are the devil. they make you a passive
consumer of static data, not an engineer constructing
falsifiable hypotheses」

• 「If you are debugging with aggregates you are screwed.
You gotta have that source of truth to drill down to」
⽤用 alert 發現問題
⽤用 log 除錯
Alert
• 從使⽤用者的⾓角度發 Alert - E2E alert

• Only Actionable Alerts

• e.g.

• Alert: 80% Disk Usage - 無法得知是否會影響 User

• Alert: LB 500 rate > 10% - 會影響 User,立刻開始處理理
Alert ~= Incidents
• First Step: Don't Panic

• 通常沒有⼈人會受傷

• 頂多就是整個 Internet 掛了了,⼩小事

• 深呼吸
Incidents
• Incident Management Process

• 分⼯工、分⼯工、分⼯工

• 所有修改跟診斷都要共享

• 不可以有⼈人⾃自⼰己 ssh 進去亂改

• 溝通、溝通、溝通

• Incident Commander

• 寫 Postmortem - Learning from Failure
Log Everything
• 沒有 log 就不⽤用想 debug

• Tracing、Logging、Feature Flag

• 不光只是存 log,還要能向 log 問問題
Tracing
Log for Answering Questions
• 「我們最⼤大的客⼾戶的 request failure rate 是多少?」

• 「Latency 突然變⾼高,是影響所有⽤用⼾戶,還是只是某個⽤用⼾戶
撞到 edge case?」

• 「機器負載很重,是該加機器,還是有某個⽤用⼾戶在 abuse
我們的服務,應該 ban 他?」
Feature Flag
• 不改變程式的情況下改變系統⾏行行為

• 透過外部變數開啟/關閉某些功能

• if (ENABLE_SUPER_FEATURE) { ... }
Test in Production
「程式 release 之前測
到完美」?
「程式 release 之前測
到完美」?
Production = Real World
• 沒有進 Production 前,所有測試都是假的

• 只有在真實世界才能測到真實世界的狀狀況

• Test in Production

• Service 永遠都在改變,永遠都在 Release
「Deploy 是⼀一件很可
怕的事?」
「Deploy 是⼀一件很可
怕的事?」
「週五不能 Deploy」
「週五不能 Deploy」
First Step
• Faster Deploy

• Easier Rollback

• Feature Flag
Reliability Engineering
• 建立 actionable alert

• Log everything

• Faster Deploy

• Easier Rollback

• Test in Production
RECAP
Service Team Performance
• Time to Delivery

• Time to Recovery

• # of Failed Deploys

• Frequency of Deploys
SRE is Highly Creative
SRE is Disciplined
People are fighting for freedom with web services
How can we help?
Thanks

Contenu connexe

Similaire à Running a Service in Production without Losing Your Sanity

Nb的敏捷
Nb的敏捷Nb的敏捷
Nb的敏捷oulan
 
From Coders to Builders of the Intelligent World
From Coders to Builders of the Intelligent WorldFrom Coders to Builders of the Intelligent World
From Coders to Builders of the Intelligent WorldHuawei Technologies
 
Query store查詢調校新利器
Query store查詢調校新利器Query store查詢調校新利器
Query store查詢調校新利器Rico Chen
 
Open source的devops工具箱 公開版@coscup2016
Open source的devops工具箱 公開版@coscup2016Open source的devops工具箱 公開版@coscup2016
Open source的devops工具箱 公開版@coscup2016Kirk Chen
 
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?Miles Chou
 
Mobile app的測試v2
Mobile app的測試v2Mobile app的測試v2
Mobile app的測試v2Mr PM
 
Joomla! 網站規劃 簡報-i love joomla! 5月小聚
Joomla! 網站規劃 簡報-i love joomla! 5月小聚Joomla! 網站規劃 簡報-i love joomla! 5月小聚
Joomla! 網站規劃 簡報-i love joomla! 5月小聚Asika Simon
 
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚Joomla! 網站規劃 簡報 - I love joomla! 5月小聚
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚ilovejoomla
 
Angular 深入淺出測試篇:新手入門
Angular 深入淺出測試篇:新手入門Angular 深入淺出測試篇:新手入門
Angular 深入淺出測試篇:新手入門志龍 陳
 
Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Fong Liou
 
架構設計好簡單系列 設計符合團隊的範本精靈 (Project template)
架構設計好簡單系列   設計符合團隊的範本精靈 (Project template)架構設計好簡單系列   設計符合團隊的範本精靈 (Project template)
架構設計好簡單系列 設計符合團隊的範本精靈 (Project template)Gelis Wu
 
Geo science cafe 如何找到一份满意的工作
Geo science cafe 如何找到一份满意的工作Geo science cafe 如何找到一份满意的工作
Geo science cafe 如何找到一份满意的工作kewuc
 
The clean coder
The clean coderThe clean coder
The clean coderAndy Cheng
 
軟體專案管理與開源精神
軟體專案管理與開源精神軟體專案管理與開源精神
軟體專案管理與開源精神承澤 林
 
DevOps的神鬼奇航
DevOps的神鬼奇航DevOps的神鬼奇航
DevOps的神鬼奇航Edward Kuo
 
Djt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comDjt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comdrewz lin
 
Djt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comDjt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comdrewz lin
 
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean StartupWen-Tien Chang
 
姚彤 从360手机卫士的研发经历看大型移动应用开发
姚彤 从360手机卫士的研发经历看大型移动应用开发姚彤 从360手机卫士的研发经历看大型移动应用开发
姚彤 从360手机卫士的研发经历看大型移动应用开发Trinea Trinea
 

Similaire à Running a Service in Production without Losing Your Sanity (20)

Nb的敏捷
Nb的敏捷Nb的敏捷
Nb的敏捷
 
Nb的敏捷
Nb的敏捷Nb的敏捷
Nb的敏捷
 
From Coders to Builders of the Intelligent World
From Coders to Builders of the Intelligent WorldFrom Coders to Builders of the Intelligent World
From Coders to Builders of the Intelligent World
 
Query store查詢調校新利器
Query store查詢調校新利器Query store查詢調校新利器
Query store查詢調校新利器
 
Open source的devops工具箱 公開版@coscup2016
Open source的devops工具箱 公開版@coscup2016Open source的devops工具箱 公開版@coscup2016
Open source的devops工具箱 公開版@coscup2016
 
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?
2019/7/27 先別開 Branch 了,你聽過 Feature Toggle 嗎?
 
Mobile app的測試v2
Mobile app的測試v2Mobile app的測試v2
Mobile app的測試v2
 
Joomla! 網站規劃 簡報-i love joomla! 5月小聚
Joomla! 網站規劃 簡報-i love joomla! 5月小聚Joomla! 網站規劃 簡報-i love joomla! 5月小聚
Joomla! 網站規劃 簡報-i love joomla! 5月小聚
 
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚Joomla! 網站規劃 簡報 - I love joomla! 5月小聚
Joomla! 網站規劃 簡報 - I love joomla! 5月小聚
 
Angular 深入淺出測試篇:新手入門
Angular 深入淺出測試篇:新手入門Angular 深入淺出測試篇:新手入門
Angular 深入淺出測試篇:新手入門
 
Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)Legacy code 讀書會 1st (Ch1 - Ch5)
Legacy code 讀書會 1st (Ch1 - Ch5)
 
架構設計好簡單系列 設計符合團隊的範本精靈 (Project template)
架構設計好簡單系列   設計符合團隊的範本精靈 (Project template)架構設計好簡單系列   設計符合團隊的範本精靈 (Project template)
架構設計好簡單系列 設計符合團隊的範本精靈 (Project template)
 
Geo science cafe 如何找到一份满意的工作
Geo science cafe 如何找到一份满意的工作Geo science cafe 如何找到一份满意的工作
Geo science cafe 如何找到一份满意的工作
 
The clean coder
The clean coderThe clean coder
The clean coder
 
軟體專案管理與開源精神
軟體專案管理與開源精神軟體專案管理與開源精神
軟體專案管理與開源精神
 
DevOps的神鬼奇航
DevOps的神鬼奇航DevOps的神鬼奇航
DevOps的神鬼奇航
 
Djt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comDjt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.com
 
Djt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.comDjt22 justinliu djt.qq.com
Djt22 justinliu djt.qq.com
 
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
 
姚彤 从360手机卫士的研发经历看大型移动应用开发
姚彤 从360手机卫士的研发经历看大型移动应用开发姚彤 从360手机卫士的研发经历看大型移动应用开发
姚彤 从360手机卫士的研发经历看大型移动应用开发
 

Plus de Poga Po

g0v.social:分散式社群媒體的四年旅程
g0v.social:分散式社群媒體的四年旅程g0v.social:分散式社群媒體的四年旅程
g0v.social:分散式社群媒體的四年旅程Poga Po
 
Writing Redis Module with Rust
Writing Redis Module with RustWriting Redis Module with Rust
Writing Redis Module with RustPoga Po
 
萬事萬物皆是 LOG - 系統架構也來點科普
萬事萬物皆是 LOG - 系統架構也來點科普萬事萬物皆是 LOG - 系統架構也來點科普
萬事萬物皆是 LOG - 系統架構也來點科普Poga Po
 
Full-stack go with GopherJS
Full-stack go with GopherJSFull-stack go with GopherJS
Full-stack go with GopherJSPoga Po
 
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015Poga Po
 

Plus de Poga Po (7)

g0v.social:分散式社群媒體的四年旅程
g0v.social:分散式社群媒體的四年旅程g0v.social:分散式社群媒體的四年旅程
g0v.social:分散式社群媒體的四年旅程
 
Writing Redis Module with Rust
Writing Redis Module with RustWriting Redis Module with Rust
Writing Redis Module with Rust
 
Wtt#20
Wtt#20Wtt#20
Wtt#20
 
萬事萬物皆是 LOG - 系統架構也來點科普
萬事萬物皆是 LOG - 系統架構也來點科普萬事萬物皆是 LOG - 系統架構也來點科普
萬事萬物皆是 LOG - 系統架構也來點科普
 
Full-stack go with GopherJS
Full-stack go with GopherJSFull-stack go with GopherJS
Full-stack go with GopherJS
 
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
 
Gtg12
Gtg12Gtg12
Gtg12
 

Running a Service in Production without Losing Your Sanity