Microservice Patterns - 3.4 Interprocess communication in a microservice architecture - Using asynchronous messaging to improve availability


Reference

  • synchronous communication with other services as part of request handling reduces application availability
  • As a result, you should design your services to use asynchronous messaging whenever possible

Synchronous communication reduces availability
  • Problem of "Use REST for inter-service communication" is "it's synchronous protocol"
  • Synchronous protocol => Reduce availability
  • If you want to maximize availability, you must minimize the amount of synchronous communication.

Eliminating synchronous interaction
ways to reduce the amount of synchronous communication with other services while handling synchronous requests
  • defining services that only have asynchronous APIs (but  public APIs are commonly RESTful)

USE ASYNCHRONOUS INTERACTION STYLES

REPLICATE DATA
  • If a service has a synchronous API, one way to improve availability is to replicate data
  • A service maintains a replica of the data that it needs when processing requests.
  • It keeps the replica up-to-date by subscribing to events published by the services that own the data
  • Drawback
    • it can sometimes require the replication of large amounts of data, which is inefficient.
    • it doesn’t solve the problem of how a service updates data owned by other services

FINISH PROCESSING AFTER RETURNING A RESPONSE
handle a request as follows: 
  1. Validate the request using only the data available locally.
  2. Update its database, including inserting messages into the OUTBOX table.
  3. Return a response to its client.
it asynchronously sends messages to other services

Drawback:
  • makes the client more complex


UP學:所有經理人相見恨晚的一本書 What Got You Here Won't Get You There


Reference
UP學:所有經理人相見恨晚的一本書

Notes
  • 應該
    • 知道該停止做甚麼 => 認清沉沒成本, 勇敢不做
    • 調整成中立的 => 不用當混蛋, 不用太討好人. 甚麼都不做
  • 不該
    • 贏太多 => 太專注於贏別人
    • 加值過度 => 聽到好的提案, 應該說謝謝以及考慮執行, 不用再加上自己的意見, 以為會讓提案好上加好, 事實上只會讓人掃興
    • 打分數 => 把自己的標準套用在別人身上
    • 惡言批評 => 自以為求好心切, 自以為講了一些很聰明的話, 其實只有刻薄
    • 用 "不是" "但是" 或 "然而" 來開頭說話 => 就是想表達自己才是對的
    • 告訴全世界我多聰明
    • 生氣時發言 => 以為可以用情緒做為管理工具
    • 否定, 或 "讓我告訴你為何這行不通" => 就算別人沒問也要散發負面思考
    • 壟斷訊息 => 有意或無意
    • 不能適時讚賞別人 => 好像讚賞別人就是讓自己看起來沒那麼好
    • 搶別人的功勞
    • 找藉口 => 想把自己的缺點當成特質, 而希望別人不要計較
    • 怪罪過去 => 怪到以前的經驗塑造現在的自己而拒絕改變
    • 偏心 => 需要時時警惕, 每個人都喜歡說好話的人, 無意識中待人不公平
    • 拒絕說對不起 => 對不起的威力強大, 有時候就缺一個道歉, 就算很難說誰對誰錯
    • 不聽別人說話 => 即使是不專心也一樣, 應該要讓人覺得倍感尊重
    • 不表達感謝 => 沒禮貌
    • 懲罰傳訊息的人 => 就克制不住脾氣攻擊傳訊息且想幫忙的人
    • 推卸責任 => 犯錯都跟我無關
    • 過多的我 => 我我我
    • 目標成癮 => 放錯目標, 原本的目標應該是做好產品, 最後目標卻變成設定一堆汲汲營營討好老板的目標.


別名演算法 Alias Method

 題目 每個伺服器支援不同的 TPM (transaction per minute) 當 request 來的時候, 系統需要馬上根據 TPM 的能力隨機找到一個適合的 server. 雖然稱為 "隨機", 但還是需要有 TPM 作為權重. 解法 別名演算法...