Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Nuxt マイクロサービスを 3つに分割した話 / Split A Nuxt Microser...
Search
tanakaworld
August 26, 2019
Technology
3
11k
Nuxt マイクロサービスを 3つに分割した話 / Split A Nuxt Microservice to 3 Microservices
NuxtMeetUp#9 オールスターズ
https://nuxt-meetup.connpass.com/event/135514
#nuxtmeetup
tanakaworld
August 26, 2019
Tweet
Share
More Decks by tanakaworld
See All by tanakaworld
Automatic Code Generation for SPA
tanakaworld
2
1.3k
Replace wicked_pdf with puppeteer
tanakaworld
1
830
How fast "dev.to" is?
tanakaworld
2
550
Replace View of Backbone with Vue
tanakaworld
2
2.2k
Other Decks in Technology
See All in Technology
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.2k
技術スタックだけじゃない、業務ドメイン知識のオンボーディングも同じくらいの量が必要な話
niftycorp
PRO
0
110
脳波を用いた嗜好マッチングシステム
hokkey621
0
290
Change Managerを活用して本番環境へのセキュアなGUIアクセスを統制する / Control Secure GUI Access to the Production Environment with Change Manager
yuj1osm
0
100
Amazon Aurora のバージョンアップ手法について
smt7174
2
150
Oracle Database Technology Night #87-1 : Exadata Database Service on Exascale Infrastructure(ExaDB-XS)サービス詳細
oracle4engineer
PRO
1
180
ExaDB-XSで利用されているExadata Exascaleについて
oracle4engineer
PRO
3
260
LINE NEWSにおけるバックエンド開発
lycorptech_jp
PRO
0
250
IAMポリシーのAllow/Denyについて、改めて理解する
smt7174
2
210
RayでPHPのデバッグをちょっと快適にする
muno92
PRO
0
190
ABWG2024採択者が語るエンジニアとしての自分自身の見つけ方〜発信して、つながって、世界を広げていく〜
maimyyym
1
180
AIエージェント時代のエンジニアになろう #jawsug #jawsdays2025 / 20250301 Agentic AI Engineering
yoshidashingo
8
3.7k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
158
23k
The Cult of Friendly URLs
andyhume
78
6.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Building Adaptive Systems
keathley
40
2.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
510
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
Transcript
Nuxt マイクロサービスを 3つに分割した話 NuxtMeetUp#9 オールスターズ 2019/08/26 @_tanakaworld
About Me • Twitter: @_tanakaworld • GitHub: tanakaworld • Software
Engineer (Frontend) ◦ CSTool ◦ MSTool
マイクロサービスを3つに分割した話 共通化 分割
1つのアプリケーションを分割するための コンポーネント管理方法 共通化 http://bit.ly/2zkXMU1
1. メルペイの管理画面 2. 背景 3. 方針 4. 配信環境のポイント 5. まとめ
今日は分割について話します 分割
メルペイの管理画面
メルペイの管理画面 CSTool MSTool Settings • Customer Support • お客さまの管理機能 •
登録情報 • 取引情報 • あと払い • クーポン • Merchant Support • 加盟店さまの管理機能 • 審査機能 • 店舗情報 • 取引情報 • オペレータ管理 • 権限
メルペイの管理画面 CSTool MSTool Settings • Customer Support • お客さまの管理機能 •
登録情報 • 取引情報 • あと払い • クーポン • Merchant Support • 加盟店さまの管理機能 • 審査機能 • 店舗情報 • 取引情報 • オペレータ管理 • 権限
初期のアーキテクチャ API Gateway https://admin.xxx.com Nuxt (SSR) Nginx
デプロイフロー ••• ••• Build + Push Docker Image Deploy by
Spinnaker GitHub Repository Nginx Nuxt (SSR) GKE Nginx Node.js
分割に至る背景
プロダクトチームが2つに分離された • 当初は1つのプロダクトチームだった • CSTool、MSTool でプロダクトチームが分離された • 異なる PdM、Operation •
やりたいこと・時期、プロジェクトの進め方が異なる
様々な課題 • 一つのアプリケーションに複数チームからの要望が来る • 変更が互いに影響してしまう • 複数の機能開発が並行して進み、feature ブランチが混在 • Conflict
してマージできなくなる(機能を隠すフラグまみれ) • 毎週1・2回リリース • QAコスト増大 • スケジュール調整が手間 •••
分割の方針
前提条件 • 独立した開発・リリースが行えること • メルペイ全体で技術的負債解消の時間を確保する方針に • 対応期間は2ヶ月 制約 • デザインは共通
→ 共通 Component リポジトリを使う • 配信ドメインは変更しない • GCP Project は共通
プロダクトチーム軸 + 機能軸で分割 CSTool MSTool Common
分割後のアーキテクチャ API Gateway https://admin.xxx.com /cs /ms other CS MS Common
request path でサービスを分岐 • SSR リクエスト /cs → CS /ms
→ MS / → Common • Assets 取得リクエスト /cs/assets → CS /ms/assets → MS /common/assets → Common
1. pages に階層構造をつくる • e.g. https://admin.xxx.com/cs • 各 Nuxt アプリは他の
Nuxt アプリと prefix が被らないようにする
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/'; }
/cs でリクエストされた結果の HTML
配信環境のポイント
2段階リリース • Step1: Nginx で routing ◦ 新 Nuxt *
3、新 Nginx * 3 ◦ いつ API Gateway がリリースされてもいい状態にする • Step2: API Gateway で routing ◦ Step1 でリリースされた 新 Nginx に接続してもらう
Step1: Nginx で routing
Canary Release • ダウンタイムを極力短くするため • routing 設定に注意が必要 • SSR 時のリクエストと
assets 取得の リクエストが同じ Nginx を通過すると は限らないので、それらを考慮する Old CS MS Common ••• /cs /ms Canary other
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 •••
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 •••
完了したら古い環境は停止 API Gateway Old CS MS Common ••• /cs /ms
Canary other
Step2: API Gateway で routing
API Gateway のリリース API Gateway CS MS Common /cs /ms
other
旧 Nginx は停止 API Gateway CS MS Common /cs /ms
other
まとめ
• プロダクトチームの粒度にあわせてマイクロサービスを分割 • request path に応じてマイクロサービスを分岐 まとめ API Gateway /cs
/ms other
• Pros ◦ 独立して開発・運用・リリースができるようになった ◦ 同じドメインで複数 Nuxt アプリ ▪ 新しいマイクロサービスに横展開
▪ 肥大化した機能を切り出す • Cons ◦ 共通化できていない対象の更新が 3倍 Pros / Cons
Thanks