23
Supporting large scale React apps Maurice de Beijer @mauricedb

Supporting large scale React applications

Embed Size (px)

Citation preview

Page 1: Supporting large scale React applications

Supporting large scale React apps

Maurice de Beijer@mauricedb

Page 2: Supporting large scale React applications

Safety in hard to reach places

2

Page 3: Supporting large scale React applications

Who am I?

• Maurice de Beijer

• The Problem Solver

• Microsoft Azure MVP

• Freelance developer/instructor

• Twitter: @mauricedb and @React_Tutorial

• Web: http://www.TheProblemSolver.nl

• E-mail: [email protected]

3

Page 4: Supporting large scale React applications

Overview

• HTTP and Ajax requests

• Scaling out

• Programming language and code quality

• Webpack

• Error logging and collection

Page 5: Supporting large scale React applications

HTTP is hard

Page 6: Supporting large scale React applications

Swagger for HTTP contracts

Page 7: Supporting large scale React applications

Chaos Monkey

• Http request have a tendency of failing

• Simulate this behavior when developing

Page 8: Supporting large scale React applications

Retry on errors

• Retry requests that fail

• After a brief pause

Page 9: Supporting large scale React applications

HTTP Caching is hard

• Caching static data can help performance

– But cache invalidation is hard

• Use the HTTP vary header

– Accept header

– Authorization header

Page 10: Supporting large scale React applications

Scaling out

Page 11: Supporting large scale React applications

Scaling out is hard

• When going to the second web server

– But easy going from the second to the third

Page 12: Supporting large scale React applications

Chaos Monkey

• Middleware to randomly route all requests to a different server when developing

Page 13: Supporting large scale React applications

WritingCode

Page 14: Supporting large scale React applications

TypeScript

• Or use another type checker like Flow

Page 15: Supporting large scale React applications

ESLint & TSLint

• Use ESLint and/or TSLint

• Use eslint-plugin-react for React code

• Airbnb publish a great configuration

– The eslint-config-airbnb NPM package

Page 16: Supporting large scale React applications

Webpack

Page 17: Supporting large scale React applications

Avoid the CommonsChunkPlugin

• Build shared library bundles just once

– Using DllPlugin& DllReferencePlugin

– Better performance then using the CommonsChunkPlugin

Page 18: Supporting large scale React applications

Use HappyPack caching

• Speed up Webpack builds

– Use Awesome Typescript Loader for TypeScript

Page 19: Supporting large scale React applications

Error logging

• Errors will happen

• Don’t assume you are online

Page 20: Supporting large scale React applications

Errors in React components

Page 21: Supporting large scale React applications

Display with redbox-react

Page 22: Supporting large scale React applications

Conclusion

• HTTP and Ajax requests can be unreliable– Specially on remote and mobile connections

• Scaling out– Isn’t hard if you do so from day one

• Programming language and code quality– JavaScript and JSX is fine for small projects– Big projects need more help

• Webpack is awesome– But rebuild times add up with a large codebase

• Error logging and collection– Error will happen– Make sure you know about them

Page 23: Supporting large scale React applications

Thank you

Maurice de Beijer - @mauricedb