萬事萬物皆是 LOG
Poga @ COSCUP 2016.08.20
LOG
If you want maintainable, understandable software system
什麼是 LOG
LOG 的性質
● 按照時間出現
● 出現過的就不會改變(append-only)
● 目的:記錄(某個時間)發生了(某件事)
○ 常常用來作為 debug 推理的依據
Things based on LOG
● Database
● Version Control
● Distributed System and Distributed Consensus
● Synchronization
● Replication
● Messaging
● UI Framework
● ...And almost EVERYTHING
聽完就理解了軟體架構的真理(誤)
POGA
Software Developer, g0v.tw, KKTIX(前)
資料庫
ID Username Balance
231 poga 100
7212 moon 12314
834 et 927
... ... ...Database
● 大量讀寫資料,長期儲存
● 確保資料正確性(relation, validation, schema, ACID)
● 支援多種高效查詢(SQL, index)
如果你從沒用過資料庫...
寫入資料時當機?
如何避免寫入資料時當機導致資料消失?
寫入:
ID Username Balance
231 poga 100
...
2016.08.20 13:40:05.0012621 Write {ID:231, Username:poga, Balance: 100}
...
真正寫入: Validation, Update Index… etc.
...
2016.08.20 13:40:05.0012621 Write {ID:231, Username:poga, Balance: 100}
...
時間 發生了什麼事
WRITE-AHEAD LOG
LOG
● Fast and simple
RECAP
資料庫
ID Username Balance
231 poga 100
7212 moon 12314
834 et 927
... ... ...Database
● 單一 Database 擴充性有其極限
● 多台 Database,分散負載
○ 需要確保多台 Database 之間資料同步
Replication
確保多台資料庫間資料同步?
寫入一台資料庫
寫入:
ID Username Balance
231 poga 100
...
2016.08.20 13:40:05.0012621 Write {ID:231, Username:poga, Balance: 100}
...
真正寫入: Validation, Update Index… etc.
一次寫入多台資料庫
寫入:
ID Username Balance
231 poga 100
...
2016.08.20 13:40:05.0012621 Write
{ID:231, Username:poga, Balance: 100}
...
真正寫入: Validation, Update Index… etc.
...
2016.08.20 13:40:05.0012621 Write {ID:231,
Username:poga, Balance: 100}
...
真正寫入: Validation, Update Index… etc.
DB1 DB2
LOG-SHIPPING
LOG
● Fast and simple
● Can be used to share “current state”
RECAP
微服務
Microservice
Monolith v.s. Microservice
Monolith
● 所有邏輯集中在單一系統中,共
享儲存運算資源
● 容易開發
● 不易擴充
Microservice
● 將邏輯按照 Domain 切割,有
獨立的儲存與運算資源
● 容易擴充,團隊間分責明確
● 門檻較高:不易維護,需要進階
系統維護能力
微服務間怎麼互相溝通?
Event Stream
EVENT STREAM = LOG
LOG
● Fast and simple
● Can be used to share “current state”
● LOG are easy to parse/understand, Universal Interface
RECAP
前端架構
Flux/Redux
● Many, many states
● Constantly changing state
○ User Interaction, Animation, Network
● Hard to reproduce bug and debug
UI State
前端介面狀態多變,如何維護?
Flux/Redux
● Unidirectional Data Flow
○ Append only
○ Handle action one by one, reasonable
● Immutable State
○ Produce new state based on previous state and action
● Everything else can be stateless(pure)
UNIDIRECTIONAL = LOG
LOG
● Fast and simple
● Can be used to share “current state”
● Text are easy to parse/understand, Universal Interface
● Append-only, easy to reason, everything else can be
stateless
RECAP
區塊鏈
Blockchain
● 2016.08.20 13:31:23, A 給 B 100 bitcoin
● State: A 跟 B 身上剩下多少 bitcoin
● Double Spend:
○ A 把 bitcoin 交給 B 後,不能再把同樣的 bitcoin 交給 C
Transaction
如何讓全世界都認知交易的成立?
a.k.a. Avoid Double-Spending
● 如果
○ 所有參與者都知道/可以驗證所有人的交易記錄
○ 既有的交易紀錄無法被竄改
○ 便沒有偽造空間
● Blockchain
○ 將所有的交易記錄用 block 封裝,每個 block 替之前的交易記錄加密驗證
○ 想要偽造一筆交易記錄 = 必須偽造整個 blockchain 上的交易記錄
○ 所有人都基於相同的 blockchain 驗證交易
Distributed Consensus
LOG AGREEMENT = CONSENSUS
Raft: A Consensus Algorithm for Replicated Logs
Apache Mesos - The Mesos Replicated Log (PAXOS)
LOG
● Fast and simple
● Can be used to share “current state”
● Text are easy to parse/understand, Universal Interface
● Append-only, Immutable, easy to reason, everything else
can be stateless
● Replicate log = consensus
RECAP
大數據
Data Pipeline
● > PB
● Data coming from everywhere
○ User Input
○ Business Data
○ Tracking
○ External Data
● ETL(Extract-Transform-Load)
● Analysis, Machine Learning… etc
BIG Data
如何處理雜亂、無序、大量的資料?
Data Pipeline
APPEND ONLY LOG = HIGH SCALABILITY
LOG
● Fast and simple
● Can be used to share “current state”
● Text are easy to parse/understand, Universal Interface
● Append-only, Immutable, easy to reason, everything else
can be stateless
● Replicate log = consensus
● High Scalability
RECAP
LOG = DETERMINISM
相同的過程 = 相同的結果
DETERMINISM
Make your system deterministic
● 容易理解
● 容易DEBUG
● 容易同步
● 容易儲存
● 容易擴展
LOG = DETERMINISM = 穩定的系統
設計系統架構時,先試著用 LOG 表示你的系統
Thanks!

More Related Content

PDF
Mercari JPのモノリスサービスをKubernetesに移行した話 PHP Conference 2022 9/24
PDF
大規模スクラムの失敗から学んだこと #AgileJapan2015
PDF
91APP API Gateway 導入之旅
PPTX
微服務基礎建設 - Message Queue
PDF
DevOps核心理念和實踐
PDF
結果的に組織がAgileな状態であること #agile #scrum #leanstartup
PPTX
大規模微服務導入 - #1, 從零開始的系統架構設計概觀
PPTX
脱 Excel設計書
Mercari JPのモノリスサービスをKubernetesに移行した話 PHP Conference 2022 9/24
大規模スクラムの失敗から学んだこと #AgileJapan2015
91APP API Gateway 導入之旅
微服務基礎建設 - Message Queue
DevOps核心理念和實踐
結果的に組織がAgileな状態であること #agile #scrum #leanstartup
大規模微服務導入 - #1, 從零開始的系統架構設計概觀
脱 Excel設計書

What's hot (20)

PDF
テストとリファクタリングに関する深い方法論 #wewlc_jp
PDF
マイクロサービス 4つの分割アプローチ
PDF
サイボウズの CI/CD 事情 〜Jenkins おじさんは CircleCI おじさんにしんかした!〜
PDF
REST API のコツ
PDF
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
PPTX
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
PDF
Agile Quality アジャイル品質パターン (QA2AQ)
PPTX
大規模微服務導入 - #2 從零開始的微服務 .NET Core 框架設計
PPTX
モノリスからマイクロサービスへの移行 ~ストラングラーパターンの検証~(Spring Fest 2020講演資料)
PDF
提到 DevOps 到底在談些什麼玩意兒?
PPTX
インセプションデッキ: やらないことリストと トレードオフスライダーをやってる話
PDF
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
PDF
Zabbix超入門
PDF
例外設計における大罪
PDF
從限制理論角度談敏捷導入階段 (Agile transition: a TOC perspective)
PDF
ゼロからはじめるKVM超入門
PPTX
.NET Conf 2018 - Message Queue Based RPC
PDF
Rest ful api設計入門
PPTX
NGINXをBFF (Backend for Frontend)として利用した話
PPTX
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
テストとリファクタリングに関する深い方法論 #wewlc_jp
マイクロサービス 4つの分割アプローチ
サイボウズの CI/CD 事情 〜Jenkins おじさんは CircleCI おじさんにしんかした!〜
REST API のコツ
SQLアンチパターン - 開発者を待ち受ける25の落とし穴 (拡大版)
[2022 DevOpsDays Taipei] 走過 DevOps 風雨的下一步
Agile Quality アジャイル品質パターン (QA2AQ)
大規模微服務導入 - #2 從零開始的微服務 .NET Core 框架設計
モノリスからマイクロサービスへの移行 ~ストラングラーパターンの検証~(Spring Fest 2020講演資料)
提到 DevOps 到底在談些什麼玩意兒?
インセプションデッキ: やらないことリストと トレードオフスライダーをやってる話
Swagger ではない OpenAPI Specification 3.0 による API サーバー開発
Zabbix超入門
例外設計における大罪
從限制理論角度談敏捷導入階段 (Agile transition: a TOC perspective)
ゼロからはじめるKVM超入門
.NET Conf 2018 - Message Queue Based RPC
Rest ful api設計入門
NGINXをBFF (Backend for Frontend)として利用した話
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
Ad

Viewers also liked (6)

PDF
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
PDF
Wtt#20
PDF
Full-stack go with GopherJS
PDF
Gtg12
PPTX
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
PPTX
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
聽說 KKTIX 都是用 Go 寫的 - ModernWeb 2015
Wtt#20
Full-stack go with GopherJS
Gtg12
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
Ad

Similar to 萬事萬物皆是 LOG - 系統架構也來點科普 (20)

PDF
Kafka’s New Control Plane: The Quorum Controller | Colin McCabe, Confluent
PDF
Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)
PDF
Security Monitoring for big Infrastructures without a Million Dollar budget
PDF
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
PPTX
Crypto & Crpyocurrencies Intro
PDF
Bitcoin Blockchain - Under the Hood
PDF
Streaming process with Kafka Connect and Kafka Streams
ODP
Log Management Systems
ODP
Blockchan For Developers
PDF
Blockchain with scala
PDF
Log Management: AtlSecCon2015
PDF
2019.06.27 Intro to Ceph
PDF
[db tech showcase Tokyo 2017] A11: SQLite - The most used yet least appreciat...
PDF
A Tour of Apache Kafka
PPTX
Bruno Lowagie (iText) #cfoconferenz
ODP
Blockchain Properties
PDF
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
PDF
On Private Blockchains, Technically
PDF
Kubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the Ugly
PDF
Distributed real time stream processing- why and how
Kafka’s New Control Plane: The Quorum Controller | Colin McCabe, Confluent
Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)
Security Monitoring for big Infrastructures without a Million Dollar budget
Eko10 - Security Monitoring for Big Infrastructures without a Million Dollar ...
Crypto & Crpyocurrencies Intro
Bitcoin Blockchain - Under the Hood
Streaming process with Kafka Connect and Kafka Streams
Log Management Systems
Blockchan For Developers
Blockchain with scala
Log Management: AtlSecCon2015
2019.06.27 Intro to Ceph
[db tech showcase Tokyo 2017] A11: SQLite - The most used yet least appreciat...
A Tour of Apache Kafka
Bruno Lowagie (iText) #cfoconferenz
Blockchain Properties
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
On Private Blockchains, Technically
Kubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the Ugly
Distributed real time stream processing- why and how

Recently uploaded (20)

PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
CloudStack 4.21: First Look Webinar slides
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
Configure Apache Mutual Authentication
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
1 - Historical Antecedents, Social Consideration.pdf
Abstractive summarization using multilingual text-to-text transfer transforme...
A proposed approach for plagiarism detection in Myanmar Unicode text
Getting started with AI Agents and Multi-Agent Systems
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Developing a website for English-speaking practice to English as a foreign la...
CloudStack 4.21: First Look Webinar slides
Final SEM Unit 1 for mit wpu at pune .pptx
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
OpenACC and Open Hackathons Monthly Highlights July 2025
Microsoft Excel 365/2024 Beginner's training
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
sbt 2.0: go big (Scala Days 2025 edition)
A review of recent deep learning applications in wood surface defect identifi...
Configure Apache Mutual Authentication
UiPath Agentic Automation session 1: RPA to Agents
Taming the Chaos: How to Turn Unstructured Data into Decisions
Hindi spoken digit analysis for native and non-native speakers
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx

萬事萬物皆是 LOG - 系統架構也來點科普