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

Testing in Production, Deploy on Fridays

Yi-Feng Tzeng
November 14, 2020

Testing in Production, Deploy on Fridays

本議題是去年 ModernWeb'19 「Progressive Deployment & NoDeploy」的延伸。雖然已提倡 Testing in Production 多年,但至今願意或敢於實踐的團隊並不多,背後原因多是與文化及態度有些關係。

此次主要分享推廣過程中遇到的苦與甜,以及自己親力操刀幾項達成 Testing in Production, Deploy on Fridays 成就的產品。

Yi-Feng Tzeng

November 14, 2020
Tweet

More Decks by Yi-Feng Tzeng

Other Decks in Technology

Transcript

  1. 曾義峰 (aka Ant) ➔ LeadBest Consulting Group 首席執行顧問 ➔ TGO

    台北分會學習委員 ➔ 臺灣資安社群 CHROOT 成員 ➔ 曾任資安顧問及電子票證公司顧問 ➔ 開源人年會 (COSCUP) 2009 及 2012 講師 ➔ 臺灣駭客年會 (HITCON) 2008 及 2009 講師 ➔ 臺灣 Modern Web 2015/2016/2017/2018/2019 講師
  2. 4/111 Deploy on ... Fridays No NoNoNO Don't Do tha

    t Image Credit : https://kknews.cc/pet/pqbxb8.html Font Credit : https://www.dafont.com/theme.php?cat=109 (Defused) 技術在我們手上 世界就在我們手上
  3. Progressive Deployment & NoDeploy 曾義峰 (Ant) [email protected] 2019-08-28 Credit :

    https://www.slideshare.net/yftzeng/progressive-deployment-nodeploy
  4. 18/111 ~Dark 1980s 2008 2014 ITIL Design for Anti-Fragility Design

    for Robustness Design for Resilience DevOps 堅實性設計 抗脆性設計 復原性設計 精心設計。 嚴格管控。 故障被設計為需要異常 處理。 將開發及維運為一體。 視故障為正常狀態。 為故障發生設計隔離。 將維運視為工程。 最小化人為錯誤。 為故障復原至正常狀態。 轉型 轉型 進化 SRE Dev(ops) Design for Deployless Partial Credit : https://noops.connpass.com NoDeploy 2019 想像 想像 進化 無部署設計
  5. 19/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE Commit Dev Test Staging Test Deploy Prod Continuous Deployment Local Dev Staging Prod Environments Chaos Test
  6. 20/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE Image Credit : https://software.af.mil/training/devops/ 技術在我們手上 世界就在我們手上
  7. 21/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE Deploy on Fridays Image Credit : https://software.af.mil/training/devops/ 技術在我們手上 世界就在我們手上
  8. 22/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE Image Credit : https://software.af.mil/training/devops/ 技術在我們手上 世界就在我們手上
  9. 23/111 Image Credit : https://www.freepik.com/free-icon/silo_869863.htm Sales Marketing Dev Ops Compliance

    (Security) Value DevOps Cost Cost 技術在我們手上 世界就在我們手上
  10. 31/111 技術在我們手上 世界就在我們手上 No-Deploy-Fridays No-Merge-Fridays Conflicts ⬆ Trunk Trunk PUSH

    ⬇️ No-Merge-Fridays PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ PUSH ⬇️ time
  11. 32/111 技術在我們手上 世界就在我們手上 No-Deploy-Fridays No-Merge-Fridays Conflicts ⬆ Image Credit :

    https://www.git-tower.com/help/guides/branches-and-tags/merge-conflicts/windows
  12. 34/111 技術在我們手上 世界就在我們手上 No-Deploy-Fridays No-Merge-Fridays Conflicts ⬆ Lead Time ⬆

    Image Credit : https://www.qualysoft.com/en/blog/tech-blog-introduction-part-2-cicd-patterns-and-best-practices
  13. 35/111 技術在我們手上 世界就在我們手上 No-Deploy-Fridays No-Merge-Fridays Conflicts ⬆ Lead Time ⬆

    Image Credit : https://www.qualysoft.com/en/blog/tech-blog-introduction-part-2-cicd-patterns-and-best-practices
  14. 38/111 技術在我們手上 世界就在我們手上 Image Credit : https://doc.oroinc.com/cloud/environments/ Image Credit :

    https://oroinc.com/b2b-ecommerce/blog/testing-and-staging-environments-in-ecommerce-implementation/
  15. 39/111 技術在我們手上 世界就在我們手上 Image Credit : https://doc.oroinc.com/cloud/environments/ Image Credit :

    https://oroinc.com/b2b-ecommerce/blog/testing-and-staging-environments-in-ecommerce-implementation/
  16. 40/111 技術在我們手上 世界就在我們手上 Image Credit : https://www.slideshare.net/cPrime/kanban-testing-54239643 Image Credit :

    https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.slideshare.net/LaunchDarkly/the-staging-server-is-dead-long-live-the-staging-server
  17. 41/111 技術在我們手上 世界就在我們手上 Image Credit : https://www.slideshare.net/cPrime/kanban-testing-54239643 Image Credit :

    https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.slideshare.net/LaunchDarkly/the-staging-server-is-dead-long-live-the-staging-server
  18. 42/111 技術在我們手上 世界就在我們手上 Image Credit : https://www.slideshare.net/cPrime/kanban-testing-54239643 Image Credit :

    https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.slideshare.net/LaunchDarkly/the-staging-server-is-dead-long-live-the-staging-server
  19. 43/111 技術在我們手上 世界就在我們手上 Image Credit : https://www.slideshare.net/cPrime/kanban-testing-54239643 Image Credit :

    https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.slideshare.net/LaunchDarkly/the-staging-server-is-dead-long-live-the-staging-server 這些網站都告訴我們應該這麼做,好像世界就應該要長成這個樣子
  20. 44/111 技術在我們手上 世界就在我們手上 Image Credit : https://www.slideshare.net/cPrime/kanban-testing-54239643 Image Credit :

    https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.slideshare.net/LaunchDarkly/the-staging-server-is-dead-long-live-the-staging-server 這些網站都告訴我們應該這麼做,好像世界就應該要長成這個樣子 缺點是什麼?
  21. 45/111 Staging Staging 環境必須與 Production 環境幾乎 相同,這十分困難,否則測試就不準了。 Trying to mirror

    your staging environment to production is a fool’s errand. Just give up. 嘗試將 Staging 視為 Production 是一個愚蠢的事。放棄吧。 Partial Credit : https://thenewstack.io/honeycombs-charity-majors-go-ahead-test-in-production/
  22. 48/111 Image Credit : https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.reddit.com/r/ProgrammerHumor/comments/ing3jx/works_on_my_machine/ Image

    Credit : https://www.pngitem.com/middle/hwwmRmi_dove-clipart-flame-clipart-flame-png-transparent-png/ 技術在我們手上 世界就在我們手上 在我電腦環境就沒問題
  23. 52/111 Chaos Engineering @ Netflix 這些是需要整合測試的故障模式示例,因為它們涉及服務之間的互動。在某 些情況下,可能只能在 Production 進行完全整合測試。在 Netflix

    ,根本不 可能完全重現整個架構並運行端到端測試。 當可以在 Testing 環境中重現整個系統時,我們仍然相信需要在 Production 運行實驗,因為在 Testing 環境中永遠不可能完全重現系統的所有方面。總 是存在差異,例如合併客戶端與真實客戶端相比的行為方式或 DNS 配置問 題。 Credit : Chaos Engineering IEEE Software (2016-05-05).pdf Testing in Production
  24. 53/111 技術在我們手上 世界就在我們手上 “ If you aren't testing in prod

    you aren't testing in reality ” 如果不在正式環境測試, 你的測試就不會是真實的 Credit : https://twitter.com/mipsytipsy/status/1147863838647185408 Image Credit : https://store.steampowered.com/app/561970/REALITY/
  25. 54/111 技術在我們手上 世界就在我們手上 “ Dev will match Prod, if you

    develop on production ” 如果在正式環境上進行開發, 開發環境就會與正式環境相稱 Credit : Blue is the new green (2019-03-26).pdf Image Credit : https://tw.voicetube.com/videos/62711
  26. 55/111 Your aim won’t be perfect, control over the blast

    radius. 你的瞄準並不完美, 請控制好爆炸半徑。 Image Credit : https://www.behance.net/gallery/57558081/FREE-BUSINESS-ICONS Progressive Deployment
  27. 56/111 Credit : https://thenewstack.io/the-rise-of-progressive-delivery-for-systems-resilience/ Image Credit : https://www.trisignup.com/Race/24568/Sponsor/94608 Progressive deployment

    is continuous deploy with fine-grained control over the blast radius. 漸進式部署是對爆破半徑進行細部控制的連續部署。 Progressive Deployment
  28. 57/111 Credit : https://thenewstack.io/the-rise-of-progressive-delivery-for-systems-resilience/ Image Credit : https://support.google.com/optimize/answer/7012154?hl=en Deploying a

    service is not that same as activating it for all users. 部署一個服務,未必需要讓所有使用者皆同時生效。 Progressive Deployment
  29. 58/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE 技術在我們手上 世界就在我們手上
  30. 59/111 Code Test Acceptance Deploy Operate Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 DevOps / SRE 技術在我們手上 世界就在我們手上
  31. 60/111 Code Test Acceptance Deploy Release Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 Continuous Deployment + Feature Flag / 持續部署 + 功能標誌 技術在我們手上 世界就在我們手上 Operate DevOps / SRE
  32. 61/111 Code Test Acceptance Deploy Release Continuous Integration / 持續整合

    Continuous Delivery / 持續交付 Continuous Deployment / 持續部署 Continuous Deployment + Feature Flag / 持續部署 + 功能標誌 技術在我們手上 世界就在我們手上 Operate DevOps / SRE Code Push ➡ Deployment Developer Production Server User Feature Flaged ➡ Release
  33. 62/111 Feature Flag 01 所有程式皆為部署,並可控制開關,減少整合問題 All code is deployed, but

    control exposure, reduces integration issue. 02 控制細緻度可至特定層級或是開發分支 Flags provide runtime control down to individual user. 03 開發者可以增加或刪除功能,無需再次部署 Users can be added or removed with no redeployment 04 暗啟動 Enables dark launch Credit : Progressive Deployment, Experimentation, Multitenancy, No Downtime, Cloud Security (2018-02-23).pdf Image Credit : https://opensource.com/article/18/2/feature-flags-ring-deployment-model
  34. Cost in Time 時間成本 hours mins ~ hour secs ~

    mins Applicability 適用性 2% 8% 90% Toggle Feature Flag ReDeploy Previous Version Rollback Revert Commit Incident Recovery 事件恢復
  35. 65/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  36. 66/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  37. 67/111 技術在我們手上 世界就在我們手上 Group = Beta Group = Normal If

    ( group = “beta” ) { ... } else { ... } Beta Normal By User Group Time URI IP Address User Group
  38. 68/111 技術在我們手上 世界就在我們手上 IP = o.o.o.o IP = x.x.x.x If

    ( IP = “o.o.o.o” ) { ... } else { ... } Beta By IP Address Time URI IP Address User Group Normal
  39. 69/111 技術在我們手上 世界就在我們手上 URI ~ ?flag=1 If ( URI ~

    “flag=1” ) { ... } else { ... } Beta Normal By URI Time URI IP Address User Group
  40. 70/111 技術在我們手上 世界就在我們手上 URI ~ 20201005 If ( URI ~“20201005”)

    { ... } else { ... } Beta Normal By Time Time URI IP Address User Group
  41. 71/111 技術在我們手上 世界就在我們手上 Story Mapping Code Test Acceptance Deploy Release

    Done #19 Fix Login Bug #20 Fix Email Bug #21 Perf. Tuning #17 Sort By Date #18 Filter By Group #22 German i18n
  42. 72/111 技術在我們手上 世界就在我們手上 Story Mapping Code Test Acceptance Deploy Release

    Done #19 Fix Login Bug #20 Fix Email Bug #21 Perf. Tuning #17 Sort By Date Flag#3 #18 Filter By Group Flag#4 #22 German i18n Flag#5
  43. 73/111 技術在我們手上 世界就在我們手上 Story Mapping Code Test Acceptance Deploy Release

    Done #19 Fix Login Bug #20 Fix Email Bug #21 Perf. Tuning #17 Sort By Date Flag#3 #18 Filter By Group Flag#4 #22 German i18n Flag#5 #17 Sort By Date Flag#3
  44. 74/111 #22 German i18n Flag#5 技術在我們手上 世界就在我們手上 Story Mapping Code

    Test Acceptance Deploy Release Done #19 Fix Login Bug #20 Fix Email Bug #21 Perf. Tuning #17 Sort By Date Flag#3 #18 Filter By Group Flag#4
  45. 75/111 01 提交程式至主幹可能會影響其他功能 Commit code on trunk may affects other

    features. 02 未完成的功能可能也會部署,如果配置有誤可能將未完成的功能開啟 Unfinished features may be deployed, and turned on if the configuration is incorrect. Image Credit : https://opensource.com/article/18/2/feature-flags-ring-deployment-model Feature Flag
  46. 76/111 #22 German i18n Flag#5 技術在我們手上 世界就在我們手上 Story Mapping Code

    Test Acceptance Deploy Release Done #19 Fix Login Bug #20 Fix Email Bug #21 Perf. Tuning #17 Sort By Date Flag#3 #18 Filter By Group Flag#4
  47. 77/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  48. 79/111 Microsoft/Azure Image Credit : Progressive Deployment, Experimentation, Multitenancy, No

    Downtime, Cloud Security (2018-02-23).pdf 技術在我們手上 世界就在我們手上
  49. 80/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  50. 86/111 技術在我們手上 世界就在我們手上 Image Credit : https://jaxenter.com/deployment-best-practices-172662.html Code Push ➡

    5 mins ⬅ Data Sync ? mins Code Push ➡ 15 mins Code Push ➡ 15 mins ⬅ Data Sync ? mins ⬅ Data Sync ? mins Easy Hard
  51. 89/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  52. 97/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  53. 99/111 技術在我們手上 世界就在我們手上 01 Feature Flag with Story Mapping 功能標誌及使用者故事對照

    02 Progressive Deployment 漸進式部署 03 Data(base) Synchronization Strategy 資料 ( 庫 ) 同步策略 04 Pull Requests to Pair/Mob Programming 從 Pull Requests 轉為 Pair/Mob Programming 05 Service Mesh 服務網格 Testing in Production, Deploy on Fridays
  54. 106/111 Image Credit : https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.reddit.com/r/ProgrammerHumor/comments/ing3jx/works_on_my_machine/ Image

    Credit : https://www.pngitem.com/middle/hwwmRmi_dove-clipart-flame-clipart-flame-png-transparent-png/ 技術在我們手上 世界就在我們手上 在我電腦環境就沒問題
  55. 107/111 Image Credit : https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.reddit.com/r/ProgrammerHumor/comments/ing3jx/works_on_my_machine/ Image

    Credit : https://www.pngitem.com/middle/hwwmRmi_dove-clipart-flame-clipart-flame-png-transparent-png/ 技術在我們手上 世界就在我們手上 在我電腦環境就沒問題
  56. 108/111 Image Credit : https://jaxenter.com/deployment-best-practices-172662.html Image Credit : https://www.reddit.com/r/ProgrammerHumor/comments/ing3jx/works_on_my_machine/ Image

    Credit : https://www.pngitem.com/middle/hwwmRmi_dove-clipart-flame-clipart-flame-png-transparent-png/ 技術在我們手上 世界就在我們手上 在我電腦環境就沒問題 Confidence & Trust ⬆