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

Server Side Rendering Tuning with Next.js

Server Side Rendering Tuning with Next.js

Yutaro Miyazaki

July 03, 2019
Tweet

More Decks by Yutaro Miyazaki

Other Decks in Technology

Transcript

  1. Server Side Rendering Tuning with Next.js Server Side Rendering Tuning

    with Next.js Mercari x Merpay Frontend Tech Talk vol.2 @vwxyuratoooo
  2. My Talk is About... My Talk is About... Our new

    architecture of Mercari Web The performance issue of Server Side Rendering with Next.js
  3. Next.js Downside Next.js Downside Folder Structure Router We hit the

    Server Side Rendering Performance issue...?
  4. 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.
  5. What We Learned is What We Learned is Styled Components

    CategoryLists component Contained regular expression. renderToStaticMarkup and renderToHTML .
  6. 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> );
  7. 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) } }
  8. By DynamicComponent: import dynamic from 'next/dynamic'; const DynamicComponentWithNoSSR = dynamic(

    () => import('../components/hello3'), { ssr: false } ); export default const Index = () => <div><DynamicComponentWithNoSSR /></div>;