Lightning Node Performance

Lightning Node Performance

54134c841d22c77be422a8bba5560761?s=128

Josh Ghent

August 07, 2018
Tweet

Transcript

  1. Lightning O D E A P P P E R

    F O R M A N C N E
  2. Hi! cloudcall.com + we're hiring! Josh Ghent @joshghent

  3. None
  4. Bundle size Server latency Client broadband speed Disk I/O Database

    Availability Node Engine Parse Times Network I/O Server hardware speed Client device thermal throttling Cold starts Third-party code Why is it loading slow? Well...
  5. < 200ms - feels instant < 1s - performing smooth

    < 5s - kinda slow Stats: Speed Matters Vol.3 < 8s - user has lost attention Response Times
  6. You don't truly know someone until you have seen them

    with a slow internet connection - Sigmund Freud* *probably
  7. Evidence around dropoff rates

  8. Sitting down Take a Seat

  9. MEASURE

  10. TEST https://artillery.io

  11. SpeedCurve https://speedcurve.com

  12. Add Grafana picture here ANALYSE bit.ly/statsd-nodejs

  13. Budgets gif

  14. PERFORMANCE PRINCIPLES LESS IS MORE OPTIMIZE FOR PRODUCTION ONLY SHIP

    WHAT IS USED NODE_ENV="production" Abstract common libraries out 'depcheck' module to remove unused modules Respect data plans Use 'bundlesize' to set limits Code split Javascript ✂ Reduce cold starts for Lamdas ❄ Be network resilient Utilize Webpack Treeshaking Remove unused imports Minify Pool DB Connections , Use inbuilt language features Application caching ⚡
  15. Set Budgets bundlesize -f "dist/*.js" -s 300kB bit.ly/bundlesize-npm

  16. Sunburst chart showing CPU activity. Left shows the express app

    running with NODE_ENV omitted. Right, is when NODE_ENV was set to "production"
  17. Removing unused code will reduce memory usage, cut down load

    times, and alleviate intensive CPU parsing
  18. https:// youmightnotneed.com/ lodash/ youmightnotneed.com/lodash Utilize Inbuilt Language Features UTILIZE INBUILT

    FEATURES
  19. depcheck VSCode

  20. Your Server is Lazy

  21. WHAT YOU CAN'T SEE HURTS!

  22. Offline Ready

  23. Offline-ready Check if the User is Offline/Online

  24. Listen for Offline/Online Events

  25. ASYNCHRONOUS

  26. Your Server Might be a Bit Busy...

  27. bit.ly/digg-nodejs

  28. Do I look fat in these?

  29. Processing Power!

  30. PM2 Cluster Monitoring Nginx Load Balancing pm2.io bit.ly/nginx-lb

  31. Rate limit image Oh no, it's the Rate Limit Police!

    Ello, ello, what's all this then? Looks like it's the 100th request this second! RATE LIMIT
  32. None
  33. How? Why? Customers stop using an app if it is

    slow Measure, Budget, Optimize, Measure How? What?
  34. Small change leads to Big Impact

  35. Thanks! Josh Ghent @joshghent cloudcall.com blog.joshghent.com github.com/joshghent/talks