Upgrade to Pro — share decks privately, control downloads, hide ads and more …

everything is log

Poga Po
August 20, 2016
1.8k

everything is log

請搭配逐字稿服用 https://medium.com/@poga/caf3029359f8

Poga Po

August 20, 2016
Tweet

Transcript

  1. Things based on LOG • Database • Version Control •

    Distributed System and Distributed Consensus • Synchronization • Replication • Messaging • UI Framework • ...And almost EVERYTHING
  2. 如何避免寫入資料時當機導致資料消失? 寫入: ID Username Balance 231 poga 100 ... 2016.08.20

    13:40:05.0012621 Write {ID:231, Username:poga, Balance: 100} ... 真正寫入: Validation, Update Index… etc.
  3. 寫入一台資料庫 寫入: ID Username Balance 231 poga 100 ... 2016.08.20

    13:40:05.0012621 Write {ID:231, Username:poga, Balance: 100} ... 真正寫入: Validation, Update Index… etc.
  4. 一次寫入多台資料庫 寫入: 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
  5. LOG • Fast and simple • Can be used to

    share “current state” RECAP
  6. LOG • Fast and simple • Can be used to

    share “current state” • LOG are easy to parse/understand, Universal Interface RECAP
  7. • Many, many states • Constantly changing state ◦ User

    Interaction, Animation, Network • Hard to reproduce bug and debug UI State
  8. 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)
  9. 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
  10. • 2016.08.20 13:31:23, A 給 B 100 bitcoin • State:

    A 跟 B 身上剩下多少 bitcoin • Double Spend: ◦ A 把 bitcoin 交給 B 後,不能再把同樣的 bitcoin 交給 C Transaction
  11. • 如果 ◦ 所有參與者都知道/可以驗證所有人的交易記錄 ◦ 既有的交易紀錄無法被竄改 ◦ 便沒有偽造空間 • Blockchain

    ◦ 將所有的交易記錄用 block 封裝,每個 block 替之前的交易記錄加密驗證 ◦ 想要偽造一筆交易記錄 = 必須偽造整個 blockchain 上的交易記錄 ◦ 所有人都基於相同的 blockchain 驗證交易 Distributed Consensus
  12. LOG AGREEMENT = CONSENSUS Raft: A Consensus Algorithm for Replicated

    Logs Apache Mesos - The Mesos Replicated Log (PAXOS)
  13. 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
  14. • > PB • Data coming from everywhere ◦ User

    Input ◦ Business Data ◦ Tracking ◦ External Data • ETL(Extract-Transform-Load) • Analysis, Machine Learning… etc BIG Data
  15. 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