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
850
How fast "dev.to" is?
tanakaworld
2
560
Replace View of Backbone with Vue
tanakaworld
2
2.2k
Other Decks in Technology
See All in Technology
Cross Data Platforms Meetup LT 20250422
tarotaro0129
1
850
Dataverseの検索列について
miyakemito
1
150
Dynamic Reteaming And Self Organization
miholovesq
3
690
GraphQLを活用したリアーキテクチャに対応するSLI/Oの再設計
coconala_engineer
0
160
AWS全冠芸人が見た世界 ~資格取得より大切なこと~
masakiokuda
6
6.5k
Terraform Cloudで始めるおひとりさまOrganizationsのすゝめ
handy
2
210
日経電子版 for Android の技術的課題と取り組み(令和最新版)/android-20250423
nikkei_engineer_recruiting
1
590
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
850
10ヶ月かけてstyled-components v4からv5にアップデートした話
uhyo
5
440
より良い開発者体験を実現するために~開発初心者が感じた生成AIの可能性~
masakiokuda
0
220
Mastraに入門してみた ~AWS CDKを添えて~
tsukuboshi
0
370
Рекомендации с нуля: как мы в Lamoda превратили главную страницу в ключевую точку входа для персонализированного шоппинга. Данил Комаров, Data Scientist, Lamoda Tech
lamodatech
0
860
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.4k
What's in a price? How to price your products and services
michaelherold
245
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
A Tale of Four Properties
chriscoyier
158
23k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Designing for humans not robots
tammielis
253
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.2k
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