<style> img { display: block; margin-left: auto; margin-right: auto; } </style> # 雲原生軟體開發與最佳實踐 - 黃俊龍、曾建超 (2024 Spring) ## Class info. [課程資訊](https://timetable.nycu.edu.tw/?r=main/crsoutline&Acy=112&Sem=2&CrsNo=535531&lang=zh-tw) Temporary Grading Policy: * Midterm: 35% * Final Projects: 35% * Class Participation and Quiz: 30% ## Date ### 2/21 :::info Cloud Native Course Introduction / The Twelve-Factor App ::: > Cloud native trail  > Cloud Native Computing Foundation (CNCF) [How CNCF Enables Crowdsourced Ecosystem Map with Netlify Deploy Previews](https://www.netlify.com/blog/2020/06/04/how-cncf-enables-community-sourced-ecosystem-map-with-netlify-deploy-previews/) > Sticky session 黏性會話是 Web 應用程式和負載平衡中的常見概念。 它們指的是一種機制,在該機制中,使用者的請求在會話期間一致地路由到同一伺服器實例。 這可確保特定於會話的資料(例如使用者身份驗證、購物車內容或其他上下文)在使用者與應用程式的互動過程中保持可用。 在黏性會話中,一旦使用者的初始請求被定向到特定伺服器,來自同一使用者的後續請求將被傳送到同一伺服器。 這種方法對於維護狀態資訊非常有用,而無需依賴共用儲存或複雜的同步機制。 然而,必須考慮權衡。 雖然黏性會話簡化了會話資料的處理,但它們可能導致伺服器負載分佈不均勻。 如果一台伺服器過載,其他伺服器可能仍未充分利用。 此外,如果伺服器發生故障,該伺服器上具有黏性會話的使用者可能會遇到服務中斷。 現代負載平衡器和應用程式架構通常使用替代方法,例如基於 cookie 或其他請求屬性的會話關聯性。 這些方法可以更均勻地分配請求,同時仍允許有效管理與會話相關的資料。 > Scale up / scale out  1. **Scale up(垂直縮放)**: - **描述**:擴展涉及向現有系統添加更多資源以提高其運算能力。 這些資源可能包括額外的記憶體、硬碟或處理能力。 - **用例**: - 當您需要快速解決無法透過經典資料庫最佳化技術(例如查詢變更或索引)解決的效能問題時。 - 處理目前效能等級無法滿足所有需求的工作負載尖峰。 - 當您想要透過調整服務層級來適應不斷變化的延遲要求。 - **好處**: - 透過增加更多資源輕鬆處理高峰工作負載。 - 當不再需要資源時縮小規模以節省成本。 2. **Scale out(水平擴展)**: - **描述**:橫向擴展涉及向架構添加更多伺服器,將工作負載分配到多台電腦上。 資料可以分為多個資料庫(分片),每個資料庫都可以獨立擴充。 - **用例**: - 即使在最高效能等級下,您也無法為工作負載獲得足夠的資源。 - 透過將資料劃分為更小的節點來提高處理能力。 - **好處**: - 透過在多個伺服器之間分配工作負載來提高可擴展性。 - 每個分片都可以獨立放大或縮小。 > [The 12 factor app](https://12factor.net/) 1. [Codebase](https://12factor.net/codebase) One codebase tracked in revision control, many deploys 2. [Dependencies](https://12factor.net/dependencies) Explicitly declare and isolate dependencies 3. [Config](https://12factor.net/config) Store config in the environment 4. [Backing services](https://12factor.net/backing-services) Treat backing services as attached resources 5. [Build, release, run](https://12factor.net/build-release-run) Strictly separate build and run stages 6. [Processes](https://12factor.net/processes) Execute the app as one or more stateless processes 7. [Port binding](https://12factor.net/port-binding) Export services via port binding 8. [Concurrency](https://12factor.net/concurrency) Scale out via the process model 9. [Disposability](https://12factor.net/disposability) Maximize robustness with fast startup and graceful shutdown 10. [Dev/prod parity](https://12factor.net/dev-prod-parity) Keep development, staging, and production as similar as possible 11. [Logs](https://12factor.net/logs) Treat logs as event streams 12. [Admin processes](https://12factor.net/admin-processes) Run admin/management tasks as one-off processes ### 2/28 放假 ### 3/6 :::info Design Thinking / UX / User Story ::: ```mermaid graph LR; 假設-->設計 設計-->MVP MVP--->驗證 驗證--->假設 ``` > 假設 [Persona](https://welly.tw/digital-marketing/how-to-make-persona) / [User story](https://ithelp.ithome.com.tw/articles/10282382) User story: 一句話從用戶角度寫事情 (who/what/why) ```mermaid graph TD; Epic--->UserStory_1 Epic--->UserStory_2 UserStory_1--->Task_1 UserStory_1--->Task_2 UserStory_2--->Task_3 ``` > 設計 協作設計 / UI/UX設計 * 閃電型示範 * 四步驟畫圖法 - 筆記 - 構想 - 瘋狂八 - 方案草圖 - UI Flow / Wireframe - UI Mockup - UI Library 格式塔理論 - 接近原則 - 相似原則 > MVP (minimum viable product) 用最低沉沒成本,驗證最多 User Story  > 驗證 驗證MVP 建立下一個假設 ### 3/13 :::info Software Architecture Design ::: > 編程歷史 - 結構化編程 - 物件導向編程 - 軟體架構 - 企業應用架構 > 功能性與非功能性需求 - 功能性需求 - 非功能性需求 - 可用性 - 可維護性 - 可擴充性 - 可測試性 - 安全性 - 效能表現 ```mermaid graph LR; 系統需求--->功能性需求 系統需求--->非功能性需求 非功能性需求--->品質需求 非功能性需求--->外部/其他約束 品質需求--->系統架構 品質需求--->應用軟體架構 系統架構--->可用性 系統架構--->容錯性 系統架構--->伸縮性 系統架構--->可降級性 系統架構--->安全性 應用軟體架構--->可維護性 應用軟體架構--->可擴充性 應用軟體架構--->可測試性 應用軟體架構--->可部屬性 ``` > 架構相關術語 - Daily Active Users (DAU) - Page View (PV): 網頁被讀者調用瀏覽的次數 - Queries per Second (QPS) - Transaction per Second (TPS) - Response Time (RT) ### 3/20 :::info System Architecture Design ::: 高可用關鍵三要素 - 節點/資料的冗餘 (ex: AP 多個節點、Database的多個 slave/replica) - 節點健康肚的監控與協調機制 (ex: nginx、heartbeat/keepalive) - 流量的自動 failover 的機制 (ex: nginx、VIP) > Load Balancer / Reverse Proxy - F5 > Scheduling Algorithm - Random - Round Robin - Smart scheduling > Application Cluster > 容量評估 1. 評估總訪問量 2. 評估平均 qps 3. 評估高峰 qps 4. 評估單機極限 qps 5. 根據線上系統冗餘進行決策 > NoSQL  > 系統架構演進的各項重點 - 小型 (<十萬) - 分層架構 - 中小型 (十萬) - 反向代理/負載平衡 - 資料庫主從架構 - 中型 (百萬) - 服務化架構 - 資料庫表架構 - 動靜分離/讀寫分離 - 穩定性保障/監控/SRE - Cache (Redis) - 大型 (千萬) - 微服務架構 - Message Queue - 服務容錯與降級 - 服務災備 - 巨型 (>億) - 多地多活 - 分庫分表 - ... ### 3/27 :::info Container / Kubernetes ::: - [Container / Docker](https://ithelp.ithome.com.tw/articles/10199339) - [Kubernetes](https://ithelp.ithome.com.tw/articles/10192401) ### 4/3 清明連假 ### 4/10 :::info 【Lab 1】Testing ::: ### 4/17 :::info 【Lab 2】Git + CI ::: ### 4/24 :::info 【Lab 3】CD + Container ::: ### 5/8 :::info Observability ::: ### 5/15 :::info Cloud Native ::: ### 5/22 :::info TSMC DevOps Case Sharing ::: ## Reference
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.