Marsen
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # [異常記錄]多語系架構上線 --- ## Agenda - 前情提要,「跨國多語系」上線 - 錯誤原因,技術細節與流程 - RD Sharing - 問題處理經過 - Demo 會議 - 回饋 --- ## 前情提要 ---- 很久很久很久以前, 【跨國語系基礎架構】上線了. 又過了很久很久 **我們評估要上 CDN** ![](https://i.imgur.com/0g5HL2z.jpg) ---- - 8/16 要 release 什麼? 我們要將多語系開始開發的項目一次回台灣正式環境。 ---- - 我們作了什麼 - sp23/sp24/sp25/sp26/sp27 - 前端多語系底層架構的調整(含CDN) - 國別設定 - 還有一大堆 Merge 解衝突的項目... ---- - 為什麼要等這麼久才上線 ? 風險考量,我們先上了基礎架構, 在G3環境上觀察了一段時間確定沒有問題才上線。 ---- - 講到風險,我們有多少保險 ? - 只上基礎架構 (讓異動最小) - 只上G3環境 (讓impact最小) - 藍綠部署 (標配,讓壞掉的時間儘可能縮短) - Merge Before Build (讓原始碼不受影響,rollback時不會拔掉其它團隊的功能) ---- 講那麼多,還不是壞掉了。 --- ## 錯誤原因 ---- ### 錯誤畫面 ![](https://i.imgur.com/Etwq8nY.jpg) ### 錯誤原因 ![](https://i.imgur.com/Ujy0Z4v.jpg) 多語系 CDN 的 Response Header Access-Control-Allow-Origin Protocol 與主頁面不符; ---- ### 流程面 | 測試環境 | 測試結果 | | -------- | -------- | | QA8 | OK | | QA | OK | | PP | OK | | 鎖Host測試 | OK | | 半數機器上線 | OK | | 全數機器上線 | ~~OK,好~~壞了 | ---- 為什麼全數機器上線才發生異常。 ---- - QA8 沒有 CDN - 鎖Host/半數機器上線未開 CDN - QA / PP CND 設定與正式環境不一致 - RD 並未 Check 設定的一致性 - RD 沒有權限 ---- ### 技術細節 ---- 1. 使用 Partial View 與 OutputCache 2. 小心 Borwser Cache 3. 站台上會有跨Domain的存取行為 - Service to Official - Service to CDN - Official to Service 4. CDN & Access-Control-Allow-Origin 5. 稍微提一下 CorsModule ---- ### 錯誤原因 ---- ![](https://i.imgur.com/GmBULAQ.jpg) TranslationCDN : 用來防止瞬間量對 Server 的 Impact FingerprintTag : 一份Cache的時戳, 用以取得新版多語系 Json 檔 site : BrowserCache 遇到跨 Domain 存取時, 會發生 CORS Error ---- ![](https://i.imgur.com/Dw2yIvG.jpg) ---- ![](https://i.imgur.com/GmBULAQ.jpg) 1. Partial View 會有 OutputCache → 保得了一時,保不了一世 2. 為了 Borwser Cache ,F2E 在 QueryString 作了加工。 3. 網站跨Domain的存取行為,歷史共業。 4. CDN & Access-Control-Allow-Origin 5. CorsModule,有必要區分protocol嗎 ? ---- CorsModule ```csharp=93 //// Step3. 檢查呼叫webapi是否需要https if (httpContext.Request.Url.Scheme == Uri.UriSchemeHttps && (sourceUri == null || sourceUri.Scheme == Uri.UriSchemeHttps)) { allowOrigin = allowOrigin.Replace("http:", "https:"); } ``` --- ### 問題處理經過 ---- 1. 第一時間 QA 有看到異常, 但是在 PO 的環境無法重現 , RD 初步判斷為快取的問題, 並嚐試重現錯誤 。 ---- 2. SRG 收到通報有**客戶反應**顯示異常,立即啟動藍綠部署,**耗時 93 分鐘**。 ---- 3. 縮小範圍至 CDN 與 Access-Control-Allow-Origin 異常, 但是仍然**無法完整重現錯誤**(時好時壞) ---- 4. **申請 CDN 權限**,確認各環境的設定值。 ---- 5. **申請 QAn 測試用CDN**,在 QA8 環境反覆測試, 發現**頁面 OutputCache 會影響測試** ---- 關閉QA8 OutputCache 測試步驟如下: ---- - Case1. http 強制更新後,連線 https - http://8.qa.demo/index?r=t - ts = 2387 - ao = http://8.qa.demo/index - http://8.qa.demo/index - ts = 2387 - ao = http://8.qa.demo/index - https://8.qa.demo/index => **Error** - ts = 2387 - ao = http://8.qa.demo/index ---- - Case2. https 強制更新後,連線 http - https://8.qa.demo/index?r=t - ts = 8458 - ao = https://8.qa.demo/index - http://8.qa.demo/index - ts = 8458 - ao = https://8.qa.demo/index - https://8.qa.demo/index => **Error** - ts = 8458 - ao = https://8.qa.demo/index ---- 6. 確認 Prod CDN 的 WhiteList Header 的設定有問題, 那為什麼 PP/G3 不會有問題呢 ? => **在 PP/G3 設定為 Referrer** ---- 7. 測試過程發現 x-cache Header 常常 `Miss from cloudfront`, 表示資料並非來自 CDN . 實際測試 Origin 比 Referrer 更適合 --- ### 回饋與後續 1. 團隊評估欠缺數據 → 2. 客戶反應異常。→ 3. 藍綠部署異常回覆速度,耗時 93 分鐘 → `已有RD著手改善` 4. 無法完整重現錯誤 → 見6、7、9 5. RD 沒有 CDN 權限 → `已申請` 6. QAn 沒有設定 CDN → `沒有CDN的Issue沒必要特別設定(因為需要對外)` 7. 頁面 OutputCache 會影響測試。→ 必要之惡 ? 8. PP / G3 與 Prod CDN設定不一致 → `webapi/transalte/* 已調整一致` 9. Release 三步驟 , 最後一步才會開啟 CDN → ? ---- Q. 下次我們怎麼作 ? --- ## 我們的社會責任 --- ### 補充資料 - 什麼是 CDN ? ![](https://raw.githubusercontent.com/hungys/azure-blog/master/media/14-using-azure-cdn/cdn-concept.png) Server跟CDN就像工廠與便利店的關係, 你要買東西不用跑到工廠 只要在離自已最近的便利店買就好了, 過期的商品(資料)會被丟掉 重新跟工廠進貨(拉新資料)。 ---- - 什麼是 [CORS](https://developer.mozilla.org/zh-TW/docs/Web/HTTP/CORS) ? - 什麼是 [Origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin) - 什麼是 [Referrer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer) --- (fin)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully