SlideShare a Scribd company logo
微服務基礎建設 – Message Queue
Andrew Wu, Chief Architect @ 91APP
Jan 28, 2019
Andrew Wu 是誰?
● 經歷: 91APP, Chief Architect
○ Microsoft MVP
○ 資策會 雲端系列課程 Azure PaaS 講師
○ Microsoft Azure Cafe, TechDays,
TechEd 講師
○ 專欄作家
談論各種軟體開發與設計的大小事,有 20 年的大型與雲端服務的開發經驗。喜歡研究各種技術背後的
原理與實作細節,期許自己做個優秀的架構師。研究主題以: .NET / C# / OOP / Container /
Microservices / Distributed System 為主軸,同時在部落格上也持續分享相關主題的一系列文章。期許
能將這些領域的實作經驗分享到社群。
.NET Microservices
AGENDA
● Message Queue Concepts
● NineYi.Msa.Infra.Messaging.*
● Inside Messaging:
○ Thread Sync Basic
○ Graceful Shutdown
○ Auto Scaling In Infra Way, Not In Developer Way
● Demo & QA
What is a Message Queue?
https://aws.amazon.com/message-queue/
Benefits of Message Queues
● Better Performance
● Increased Reliability
● Granular Scalability
https://aws.amazon.com/message-queue/benefits/
Asynchronous communication, optimizing data flow.
Consumers process messages only when they are available.
Queues make your data persistent, and reduce the errors
that happen when different parts of your system go offline.
Message queues make it possible to scale precisely where
you need to. Producers, consumers and the queue itself can
all grow and shrink on demand.
Benefits of Message Queues
● Simplified Decoupling
○ Break Up Apps
○ Migrate to Microservices
○ Shift to Serverless
Message queues remove dependencies between components and significantly simplify
the coding of decoupled applications. Message queues are an elegantly simple way to decouple
distributed systems, whether you're using monolithic applications, microservices or serverless architectures.
Microservices integration patterns that are based on events and asynchronous messaging
optimize scalability and resiliency. Use message queuing services to coordinate multiple
microservices, notify microservices of data changes, or as an event firehose to process IoT,
social and real-time data.
Rabbit MQ: Queue + Exchange
http://www.rabbitmq.com/getstarted.html
First Looks Of:
NineYi.Msa.Infra.Messaging.*
Design Goal
● 隱藏不必要的彈性
● 充分運用 C# 的語意,最小化自訂介面
● 充分整合 91APP 的系統架構
○ 整合 Track Context
○ 整合 Microsoft.Extensions.DependencyInjection
○ 整合 Logger*, Configuration* … etc
● 充分整合 Infra, 降低 Ops 的負擔
○ Design for Operation
Track Context {
RequestId,
SessionId,
MemberId,
ShopId
}
Track Context {
RequestId,
SessionId,
MemberId,
ShopId
}
Design Concept (One-Way Async)
MessageClient<Message> MessageWorker<Message>
Serialization Data Of Message
TrackContext Transform
Design Concept (Two-Way RPC)
MessageClient<Input, Output> MessageWorker<Input, Output>
Serialization Data Of InputMessage
Serialization Data Of OutputMessage
除了這些,其他都抽象化封裝起來…
● Developer Must Know:
○ Input Message
○ Output Message
○ Worker Process (msg) => { … }
● Misc:
○ Multi-Threads
○ Async / Await
○ Serialization, TrackContext Transform
DEMO #1
Basic Work Queue(s) with TrackContext
DEMO #1
Exchange Usage: Topic
DEMO #2
RPC: Remote Procedure Call
http://www.rabbitmq.com/tutorials/tutorial-six-dotnet.html
Inside Messaging.*
What Architect Thinks…
● Async (Notify, not Pooling)
● Parallel Processing
○ Inside Worker – threading, synchronize
○ Outside Worker – graceful shutdown & auto scaling
Demo #3
Synchronization Basic, Async & WaitHandle
ThreadSyncDemo, AsyncDemo
Synchronize Basic:
https://docs.microsoft.com/zh-tw/dotnet/api/system.threading.waithandle?view=netframework-4.7.2
Async / Await
● Wrap Async Call In Separate Process…
● Inside .NET Async & Await
● Inside .NET Thread Sync
caller
worker
A(5)
B(3)
C(5)
D(10)
E(10)
clock
call worker
return worker’s Task
start await await complete
0 5 8 13
?
18+? 28+?
Demo #4
Support Graceful Shutdown
Scaling (Use Docker-Compose)
Auto Scaling In Infra Way
● Basic Concept: Scale In / Out Automation
● Your Application Must (when Scale Out):
○ Self Host
○ Pull Config
○ Pull Message
● Your Application Must (when Scale In):
○ Handle OS Shutdown Event / Signal
○ Do Graceful Shutdown
Graceful Shutdown
● When VM / Container Being Shutdown…
{
○ Receive OS shutdown signal
○ Stop Receive Newer Message
○ Wait Until All Messages Ack
○ Exit Process Normally
}
● Successful Shutdown VM / Container
微服務基礎建設 - Message Queue
微服務基礎建設 - Message Queue
first await
wait shutdown signal
do graceful shutdown
https://columns.chicken-house.net/2007/12/17/threadpool-%E5%AF%A6%E4%BD%9C-3-autoresetevent-manual
https://columns.chicken-house.net/2018/05/10/tips-handle-shutdown-event/
Question?
【我們正在招募】
● 架構師
● C# Asp.Net MVC開發工程師
https://www.91app.com/careers/
新零售就要Line一起
~~現在就加入~~
* 技術課程&講座優先報名 *
* 講師簡報獨家提供 *
* 新零售市場訊息搶先報 *

More Related Content

PPTX
微服務的基礎建設 - Service Discovery, Andrew Wu
PPTX
大型 Web Application 轉移到 微服務的經驗分享
PPTX
我們與Azure DevOps的距離
PDF
91APP: 從 "零" 開始的 DevOps
PPTX
與大師對談: 轉移到微服務架構必經之路 ~ 系統與資料庫重構
PPTX
Kubernetes環境に対する性能試験(Kubernetes Novice Tokyo #2 発表資料)
PDF
PFNのML/DL基盤を支えるKubernetesにおける自動化 / DevOpsDays Tokyo 2021
PDF
我的 DevOps 故事
微服務的基礎建設 - Service Discovery, Andrew Wu
大型 Web Application 轉移到 微服務的經驗分享
我們與Azure DevOps的距離
91APP: 從 "零" 開始的 DevOps
與大師對談: 轉移到微服務架構必經之路 ~ 系統與資料庫重構
Kubernetes環境に対する性能試験(Kubernetes Novice Tokyo #2 発表資料)
PFNのML/DL基盤を支えるKubernetesにおける自動化 / DevOpsDays Tokyo 2021
我的 DevOps 故事

What's hot (20)

PDF
Dapr × Kubernetes ではじめるポータブルなマイクロサービス(CloudNative Days Tokyo 2020講演資料)
PDF
DockerとPodmanの比較
PPTX
Istioサービスメッシュ入門
PDF
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
PDF
超実践 Cloud Spanner 設計講座
PPTX
Azure API Management 俺的マニュアル
PPTX
大規模微服務導入 - #1, 從零開始的系統架構設計概觀
PDF
從零開始做架構圖
PDF
Azure Monitor Logで実現するモダンな管理手法
PPTX
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
PDF
コンテナ未経験新人が学ぶコンテナ技術入門
PPTX
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
PDF
ネットワークでなぜ遅延が生じるのか
PDF
BuildKitの概要と最近の機能
PDF
[AKIBA.AWS] VGWのルーティング仕様
PDF
リクルートのWebサービスを支える共通インフラ「RAFTEL」
PPTX
Dockerからcontainerdへの移行
PDF
Grafana LokiではじめるKubernetesロギングハンズオン(NTT Tech Conference #4 ハンズオン資料)
PDF
十二項架構設計原則
PDF
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
Dapr × Kubernetes ではじめるポータブルなマイクロサービス(CloudNative Days Tokyo 2020講演資料)
DockerとPodmanの比較
Istioサービスメッシュ入門
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
超実践 Cloud Spanner 設計講座
Azure API Management 俺的マニュアル
大規模微服務導入 - #1, 從零開始的系統架構設計概觀
從零開始做架構圖
Azure Monitor Logで実現するモダンな管理手法
Kubernetesでの性能解析 ~なんとなく遅いからの脱却~(Kubernetes Meetup Tokyo #33 発表資料)
コンテナ未経験新人が学ぶコンテナ技術入門
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
ネットワークでなぜ遅延が生じるのか
BuildKitの概要と最近の機能
[AKIBA.AWS] VGWのルーティング仕様
リクルートのWebサービスを支える共通インフラ「RAFTEL」
Dockerからcontainerdへの移行
Grafana LokiではじめるKubernetesロギングハンズオン(NTT Tech Conference #4 ハンズオン資料)
十二項架構設計原則
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
Ad

Similar to 微服務基礎建設 - Message Queue (20)

PPTX
Microservices at ibotta pitfalls and learnings
PDF
Migrate to Microservices Judiciously!
PPTX
Gab 2018 seguridad y escalado en azure service fabric
PPTX
Gab 2018 seguridad y escalado en azure service fabric
DOCX
Resume: DevOps/Technology Architect - Satya Prakash
DOCX
Prashant_Resume_DotNET
PDF
Ahmed El Mawaziny CV
PDF
Microservices (msa) insights with comments
PDF
From prototype to production - The journey of re-designing SmartUp.io
PDF
JavaScript for Enterprise Applications
PDF
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
PDF
Python Conference Singapore - 19 Jun 2025
PDF
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
PDF
Cloud Native Applications on Kubernetes: a DevOps Approach
PDF
2015-06-10 Ceus by IberianSPC - new options for SharePoint 2016 and Office 36...
PDF
Life as a SRE at Instana
PPTX
Running Distributed TensorFlow with GPUs on Mesos with DC/OS
PPTX
Micro Front-End & Microservices - Plansoft
PDF
CloudNativeLondon 2018: "In Search of the Perfect Cloud Native Developer Expe...
PDF
Experienced Dotnet Resume 1
Microservices at ibotta pitfalls and learnings
Migrate to Microservices Judiciously!
Gab 2018 seguridad y escalado en azure service fabric
Gab 2018 seguridad y escalado en azure service fabric
Resume: DevOps/Technology Architect - Satya Prakash
Prashant_Resume_DotNET
Ahmed El Mawaziny CV
Microservices (msa) insights with comments
From prototype to production - The journey of re-designing SmartUp.io
JavaScript for Enterprise Applications
Building and Managing your Virtual Datacenter using PowerShell DSC - Florin L...
Python Conference Singapore - 19 Jun 2025
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
Cloud Native Applications on Kubernetes: a DevOps Approach
2015-06-10 Ceus by IberianSPC - new options for SharePoint 2016 and Office 36...
Life as a SRE at Instana
Running Distributed TensorFlow with GPUs on Mesos with DC/OS
Micro Front-End & Microservices - Plansoft
CloudNativeLondon 2018: "In Search of the Perfect Cloud Native Developer Expe...
Experienced Dotnet Resume 1
Ad

More from Andrew Wu (7)

PPTX
微服務資料管理的天堂路 - CQRS / Event Sourcing 的應用與實踐
PPTX
大規模微服務導入 - #2 從零開始的微服務 .NET Core 框架設計
PPTX
.NET Conf 2018 - Message Queue Based RPC
PPTX
Monitoring Tools 大亂鬥 - Consul
PPTX
容器驅動開發 - .NET Conf 2017 @ 台中
PPTX
API Token 入門
PPTX
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務資料管理的天堂路 - CQRS / Event Sourcing 的應用與實踐
大規模微服務導入 - #2 從零開始的微服務 .NET Core 框架設計
.NET Conf 2018 - Message Queue Based RPC
Monitoring Tools 大亂鬥 - Consul
容器驅動開發 - .NET Conf 2017 @ 台中
API Token 入門
微服務架構 導入經驗分享 吳剛志 - Community Open Camp

Recently uploaded (20)

PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
ai tools demonstartion for schools and inter college
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Operating system designcfffgfgggggggvggggggggg
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How Creative Agencies Leverage Project Management Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms I-SECS-1021-03
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
2025 Textile ERP Trends: SAP, Odoo & Oracle
Upgrade and Innovation Strategies for SAP ERP Customers
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
L1 - Introduction to python Backend.pptx
Odoo Companies in India – Driving Business Transformation.pdf
ai tools demonstartion for schools and inter college
Odoo POS Development Services by CandidRoot Solutions
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Operating system designcfffgfgggggggvggggggggg

微服務基礎建設 - Message Queue

Editor's Notes

  • #5: 課程目標: 讓 server group developer 了解 “如何使用” MessageClient / MessageWorker 了解怎麼用的同時,能理解背後設計理念,甚至進一步了解該怎麼設計這樣的元件給團隊使用的技巧。 架構性的思考: 專注再要解決的問題,不重新發明 framework, 盡可能地用基礎元件 (如 language 內建的 BCL), 讓 developer team 能套用在自己的框架內使用。 替團隊做好抽象畫 (不綁定特定 services), 及整合其他環節。這是團隊自行開發,而非專注再選擇 framework 的主要原因。
  • #6: Notes: Cloud Service / Cloud native / Container / Microservices …. 線上服務的複雜度越來越高,服務數量變多,服務的 instance 也變多 管理的挑戰也變大
  • #7: Granular 粒狀的
  • #14: 除了數量之外,複雜度也隨之升高。 每個服務 (service) 及每個個體 (instance) 都必須更精準的掌握其他服務的狀態 (availability, endpoitns) 服務之間的通訊也越來越複雜
  • #22: DEMO worker thread count effect DEMO manual / auto reset event