分散式系統 Distributed Systems_Time, clocks, and ordering of events_Week3筆記
時間、時脈與事件排序 分散式系統中時間的重要性-歷史重大事件 2012 年 6 月 30 日至 7 月 1 日(英國時間),全球許多線上服務和系統曾同時崩潰 (crashed simultaneously),伺服器鎖定並停止回應。航空公司數小時無法處理預訂或登機手續。 時間測量的應用 (Clocks and time in distributed systems) ► Schedulers, timeouts, failure detectors, retry timers ► 效能量測、統計、效能剖析 Performance measurements, statistics, profiling ► Log files & databases: record when an eventoccurred ► Data with time-limited validity (e.g. cache entries) ► 跨多個節點判定事件的先後順序 Determining order of events across several nodes 時脈的區分,兩種時脈: • 實體時脈 (physical clocks):計算經過的秒數 (count number of seconds elapsed)。 • 邏輯時脈 (logical clocks):計算事件數,例如發送的訊息數。(count events, e.g. messages sent) 注意:數位電子產品中的時脈(振盪器 (oscillator)) 並不等同於分散式系統中的時脈(時間戳記的來源 (source of timestamps)) 1.石英時脈 (Quartz clocks) ->日常使用時鐘(手機、手錶、掛鐘、數位顯示器內建) 基於石英(二氧化矽)晶體經雷射修剪 (laser-trimmed),以特定頻率機械共振 (mechanically resonate) 利用壓電效應 (Piezoelectric effect) : 一塊石英若用槌子敲打或稍微彎曲,會發出微小電脈衝。若施加一些電流,也類似讓其被彎曲或敲打般。 振盪器電路 (Oscillator circuit) 在共振頻率 (resonant frequency) 產生訊號,計算循環次數來測量經過時間。 就好比如手錶的心臟會跳...