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
Server Side Rendering Tuning with Next.js
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yutaro Miyazaki
July 03, 2019
Technology
1.7k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Server Side Rendering Tuning with Next.js
Yutaro Miyazaki
July 03, 2019
More Decks by Yutaro Miyazaki
See All by Yutaro Miyazaki
React + Apollo Client (GraphQL) により変化するアプリケーション設計
vwxyutarooo
6
3.3k
The challenge of Mercari Web Re-Architecture Project
vwxyutarooo
1
200
ゼロから始めるっぽい Service Worker
vwxyutarooo
5
1.1k
Other Decks in Technology
See All in Technology
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
770
取引先から届く 「セキュリティチェックシート」の読み解き方
kamadamakoto
0
140
GitHub CopilotのFinOps- AI CreditのObservabilityと価値を生むためのエージェント設計
yuriemori
0
140
MIRU 2026 チュートリアル
keisuke198619
0
870
第3回しろおびセキュリティスポンサーセッション
log0417
0
160
Issue設計から始める仕様駆動開発 / 20260731 Mizuki Hirata
shift_evolve
PRO
1
150
JavaScript 研修 (2026)
recruitengineers
PRO
2
460
システム思考で問題に対処する
yussak
0
210
AI ネイティブな組織に Gemini Enterprise Agent Platform がなぜ必要なのか
asei
1
190
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.1k
LLM・AIエージェントシステムベストプラクティス
shibuiwilliam
2
550
Goでデータパイプラインを作ろう
sansantech
PRO
1
360
Featured
See All Featured
Scaling GitHub
holman
464
140k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.7k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
340
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
GitHub's CSS Performance
jonrohan
1033
470k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Transcript
Server Side Rendering Tuning with Next.js Server Side Rendering Tuning
with Next.js Mercari x Merpay Frontend Tech Talk vol.2 @vwxyuratoooo
Yutaro Miyazaki (@vwxyutarooo) Yutaro Miyazaki (@vwxyutarooo) 2012~ Jobless 2013~ Freelance
2016~ Startup 2018~ Mercari
My Talk is About... My Talk is About... Our new
architecture of Mercari Web The performance issue of Server Side Rendering with Next.js
Topics Topics Mercari Web Re-Architecture Apollo Next.js Performance Tuning Conclusion
What Web Re-Architecture is What Web Re-Architecture is
Ancient Huge PHP Code ↓ Modern Architecture
None
None
None
None
Topics Topics Mercari Web Re-Architecture Apollo Next.js Performance Tuning Conclusion
Apollo Apollo
None
None
Topics Topics Mercari Web Re-Architecture Apollo Next.js Performance Tuning Conclusion
None
Next.js Upside Next.js Upside Build System Smart Chunk System Various
Practices
Next.js Downside Next.js Downside Folder Structure Router We hit the
Server Side Rendering Performance issue...?
Server Side Rendering Performance?
None
100 requests per second. 40 CPU cores were waste. It
still doesn't reaches to 100 requests per second On the production environment It's supposed to spend 800 CPU cores.
None
Topics Topics Mercari Web Re-Architecture Apollo Next.js Performance Tuning Conclusion
Performance Tuning Performance Tuning How can we solve this catastrophic
performance issue
Render method tuning renderToNodeStream for example. Cache
Investigation Investigation
What We Learned is What We Learned is Styled Components
CategoryLists component Contained regular expression. renderToStaticMarkup and renderToHTML .
Things we've adopted: Prevent HTML from rendering twice. Client Side
Render Component.
1. Prevent HTML From Rendered Twice 1. Prevent HTML From
Rendered Twice
Why Why It's rendered twice by renderToStaticMarkup and renderToHTML ?
None
The case of React Apollo const Dogs = ({ onDogSelected
}) => ( <Query query={GET_DOGS}> {({ loading, error, data }) => { if (loading) return 'Loading...'; if (error) return `Error! ${error.message}`; return ( <select name="dog" onChange={onDogSelected}> {data.dogs.map(dog => ( <option key={dog.id} value={dog.breed}> {dog.breed} </option> ))} </select> ); }} </Query> );
None
None
For general purpose, React Apollo needs to correct all queries
from component tree.
Our Solution Our Solution Fragments + React Apollo Fragments +
Apollo Client
Fragments: query GetPerson { people(id: "7") { firstName lastName avatar(size:
LARGE) } } fragment NameParts on Person { firstName lastName } query GetPerson { people(id: "7") { ...NameParts avatar(size: LARGE) } }
None
const data = (await apolloClientInstance.query(queryOptions)).data;
Measuring Performance (again) Measuring Performance (again)
None
2. Client Side Render Component 2. Client Side Render Component
None
None
By DynamicComponent: import dynamic from 'next/dynamic'; const DynamicComponentWithNoSSR = dynamic(
() => import('../components/hello3'), { ssr: false } ); export default const Index = () => <div><DynamicComponentWithNoSSR /></div>;
Measuring Performance (again) Measuring Performance (again)
Topics Topics Mercari Web Re-Architecture Apollo Next.js Performance Tuning Conclusion
Additionally The Latency Duration has Improved P50: 1,000ms -> 600ms
Also we saved nearly 1.5 million yen per month.
It doesn't matter which frame work you choose, the performance
needs to be considered by application.
Don't Guess, Measure.