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

Nuxt マイクロサービスを 3つに分割した話 / Split A Nuxt Microservice to 3 Microservices

Nuxt マイクロサービスを 3つに分割した話 / Split A Nuxt Microservice to 3 Microservices

NuxtMeetUp#9 オールスターズ
https://nuxt-meetup.connpass.com/event/135514
#nuxtmeetup

tanakaworld

August 26, 2019
Tweet

More Decks by tanakaworld

Other Decks in Technology

Transcript

  1. メルペイの管理画面 CSTool MSTool Settings • Customer Support • お客さまの管理機能 •

    登録情報 • 取引情報 • あと払い • クーポン • Merchant Support • 加盟店さまの管理機能 • 審査機能 • 店舗情報 • 取引情報 • オペレータ管理 • 権限
  2. メルペイの管理画面 CSTool MSTool Settings • Customer Support • お客さまの管理機能 •

    登録情報 • 取引情報 • あと払い • クーポン • Merchant Support • 加盟店さまの管理機能 • 審査機能 • 店舗情報 • 取引情報 • オペレータ管理 • 権限
  3. デプロイフロー ••• ••• Build + Push Docker Image Deploy by

    Spinnaker GitHub Repository Nginx Nuxt (SSR) GKE Nginx Node.js
  4. 様々な課題 • 一つのアプリケーションに複数チームからの要望が来る • 変更が互いに影響してしまう • 複数の機能開発が並行して進み、feature ブランチが混在 • Conflict

    してマージできなくなる(機能を隠すフラグまみれ) • 毎週1・2回リリース • QAコスト増大 • スケジュール調整が手間 •••
  5. request path でサービスを分岐 • SSR リクエスト /cs → CS /ms

    → MS / → Common • Assets 取得リクエスト /cs/assets → CS /ms/assets → MS /common/assets → Common
  6. 2. publicPath を変更 • https://nuxtjs.org/api/configuration-build/#publicpath • /_nuxt/aaaaa.js → /cs/assets/aaaaa.js //

    nuxt.config.ts if (process.env.NODE_ENV === 'production') { // default: '/_nuxt' config.build.publicPath = '/cs/assets/'; }
  7. 2段階リリース • Step1: Nginx で routing ◦ 新 Nuxt *

    3、新 Nginx * 3 ◦ いつ API Gateway がリリースされてもいい状態にする • Step2: API Gateway で routing ◦ Step1 でリリースされた 新 Nginx に接続してもらう
  8. Canary Release • ダウンタイムを極力短くするため • routing 設定に注意が必要 • SSR 時のリクエストと

    assets 取得の リクエストが同じ Nginx を通過すると は限らないので、それらを考慮する Old CS MS Common ••• /cs /ms Canary other
  9. server { location /_nuxt/ { try_files $uri $uri/ @node; }

    location /cs { try_files $uri $uri/ @node-cs; } location /ms { try_files $uri $uri/ @node-ms; } location / { try_files $uri $uri/ @node-common; } } 新 Nginx の routing • SSR はすべて新 Nuxt へ routing • 旧 Nuxt の assets リクエストも routing する Old CS MS Common •••
  10. server { location /cs/assets { try_files $uri $uri/ @node-cs; }

    location /ms/assets { try_files $uri $uri/ @node-ms; } location /common/assets { try_files $uri $uri/ @node-common; } location / { try_files $uri $uri/ @node; } } 旧 Nginx の routing • SSR は旧 Nuxt にのみ routing • 新 Nuxt の assets リクエストも routing する Old CS MS Common •••