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
Yutaro Miyazaki
July 03, 2019
Technology
1.6k
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
190
ゼロから始めるっぽい Service Worker
vwxyutarooo
5
1.1k
Other Decks in Technology
See All in Technology
「最後に責任を取るのはチーム」— 人間のPRレビューを最小化してアップデートしたメンタルモデル
jnishime_dresscode
0
920
AIと共生する開発者プラットフォーム:バクラクのモノレポ×マイクロサービス基盤
sakajunquality
2
3.8k
AI Agent SaaS を支える自社仮想化基盤への挑戦と実運用 / ai-agent-saas-virtualization
flatt_security
3
4.2k
【Claude Code】鹿野さんに聞く 私の推しの並行開発環境 大公開 / claude-code-parallel-2026-07-15
tonkotsuboy_com
12
8.7k
DatabricksにおけるMCPソリューション
taka_aki
1
280
AIレビューはどこまで任せられるのか?自動化と人が背負うレビューの境界
sansantech
PRO
3
1.1k
シンガポールで登壇してきます
yama3133
0
240
Gen3R: 3D Scene Generation Meets Feed-Forward Reconstruction
spatial_ai_network
0
130
個人開発で育てる「大規模設計の苗床」 - AI時代の1人開発から始める業務への知識接続 / The Seedbed for Large-Scale Design - From AI-Era Solo Projects to Professional Knowledge
bitkey
PRO
1
280
Amazon EVS で VCF 9.0 / 9.1 のサポート開始まとめ
mtoyoda
0
310
非定型なドキュメントを効率よくリファクタする 〜えぇ!?仕様書27本の移行が1日で終わったって!?〜
subroh0508
2
560
SRE Next 2026 何でも屋からの脱却
bto
0
960
Featured
See All Featured
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
Odyssey Design
rkendrick25
PRO
2
730
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
260
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
190
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
280
Designing for humans not robots
tammielis
254
26k
Statistics for Hackers
jakevdp
799
230k
Amusing Abliteration
ianozsvald
1
230
[SF Ruby Conf 2025] Rails X
palkan
2
1.2k
Documentation Writing (for coders)
carmenintech
77
5.4k
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.