Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance

28 views

Published on

In this talk, attendees will see examples to improve their Javascript Performance making a few changes in their existent application. We will talk about Cache, Node.js common flow, and best practices. They'll see how to avoid performance problems working in Javascript loops, tips to work with Web APIs and best practices javascript applications.

Published in: Education
  • Be the first to comment

  • Be the first to like this

JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance

  1. 1. @erickwendel_ 10 secrets to improve Javascript Performance ERICKWENDEL
 LEADSOFTWAREARCHITECTANDTRAINER @ERICKWENDEL_
  2. 2. @erickwendel_ Backenders ?
  3. 3. @erickwendel_ Experience With Node.js?
  4. 4. @erickwendel_ Who has worked with Node since ES5?
  5. 5. @erickwendel_ Why should we care about application lifecycle?
  6. 6. @erickwendel_ Some errors could crash your app and turn it off
  7. 7. @erickwendel_ Small changes would fix big problems
  8. 8. #10 - Understand the Javascript workflow
  9. 9. @erickwendel_ What is the hardest behaviour on the Javascript language?
  10. 10. Synchronise operations
  11. 11. @erickwendel_ How to?
  12. 12. @erickwendel_ Do you really need to wait for an execution?
  13. 13. #9 - Write effective Loops
  14. 14. @erickwendel_ Is Javascript a functional language?
  15. 15. Inspects all collection
  16. 16. #8 - Cache as much as possible
  17. 17. @erickwendel_ User Experience is important!
  18. 18. ▪ How often would the data change? #JSFEST ▪ How many requests do you plan to support? ▪ How much would it cost? ▪ Where is the bottleneck? CACHING NEEDS FAQ
  19. 19. https://medium.com/@MatthewFTech/spring-boot-cache-with-redis-56026f7da83a
  20. 20. https://developer.mozilla.org/en-US/docs/Web/API/Cache
  21. 21. #7 - Use PM2 instead Node
  22. 22. #6 - Implement SSL/TLS and HTTP/2
  23. 23. ▪ Multiplexing #JSFEST ▪ Header Compression ▪ Server Push ▪ Binary Format BENEFITS
  24. 24. https://www.medianova.com/en-blog/2016/09/29/50-faster-websites-with-http2
  25. 25. #5 - Optimise your response
  26. 26. @erickwendel_ Understand your external dependencies and inspect them
  27. 27. @erickwendel_ Create indexes for known queries
  28. 28. @erickwendel_ Define boundaries for accessing your APIs
  29. 29. @erickwendel_ GraphQL x Restfull APIs
  30. 30. GraphQL Request Simple HTTP Request myapi.com/heroes? id=123&name=batman& skip=0&limit=10& fields=id,name,power
  31. 31. #4 - Inspect performance issues
  32. 32. @erickwendel_ How do I know if I have a performance issue?
  33. 33. @erickwendel_ Tooling
  34. 34. https://clinicjs.org/doctor/
  35. 35. https://nodejs.org/api/perf_hooks.html
  36. 36. #3 - Use Realtime App Monitoring to analyse your app
  37. 37. @erickwendel_ Observability is much more than logs
  38. 38. #2 - Use Node.js Streams
  39. 39. @erickwendel_ Readable streams vs fs.readfile
  40. 40. Example redable file
  41. 41. #1 - Learn about Node.js native modules
  42. 42. @erickwendel_ What Node can’t do it delegates to someone else
  43. 43. @erickwendel_ We can create our own module to extend v8 behaviour
  44. 44. Questions?
  45. 45. Conclusions
  46. 46. @erickwendel_ Most performance problems are human errors
  47. 47. @erickwendel_ Be always aware about what your app is responsible for
  48. 48. @erickwendel_ Keep Javascript packages up-to-date
  49. 49. @erickwendel_ Learn Javascript <3
  50. 50. erickwendel.com
  51. 51. ERICKWENDEL
 INDEPENDENTSOFTWARECONSULTANT @ERICKWENDEL_|@ERICKWENDEL СПАСИБІ! @erickwendel_
  52. 52. • https://erickwendel.com/ • contato@erickwendel.com.br • https://medium.com/@erickwendel • http://fb.com/page.erickwendel • https://twitter.com/erickwendel_ • http://meetup.com/nerdzao • http://meetup.com/nodebr • https://github.com/ErickWendel/10- tips-js-perf-jsfest-ukraine • http://bit.ly/10-tips-jsperf-jsfestua KEEP IN TOUCH! @erickwendel_
  53. 53. https://dzone.com/ articles/5-tips-to-increase- nodejs-application- performance https://www.nginx.com/ blog/10-tips-for-10x- application-performance/ https://expressjs.com/en/ advanced/best-practice- performance.html https:// www.slideshare.net/ CodeFireTech/web- application-performance https://www.infoq.com/ articles/node-micro- optimizations-javascript https://blog.ghaiklor.com/ profiling-nodejs- applications-1609b77afe4 e https://stackoverflow.com/ questions/41986066/ performance-and- reliability-when-using- multiple-docker-containers- vs-standard-no https://dzone.com/ articles/nine-tips-to- improve-wordpress- performance-with-ng? fromrel=true https://stackoverflow.com/ questions/9420014/what- does-it-mean-scalability https://pt.wikipedia.org/ wiki/Escalabilidade https://pt.slideshare.net/ ratankadam/scalability- using-nodejs https://botleg.com/stories/ auto-scaling-with-docker/ http://ivanjov.com/ running-express-koa-and- hapi-on-http-2/ http:// anandmanisankar.com/ posts/docker-container- nginx-node-redis- example/ https://hapijs.com/ tutorials/caching https://www.ibm.com/ support/knowledgecenter/ en/SS4PJT_5.2.0/ com.ibm.help.cd52.unix.doc / com.ibm.help.cdunix_secplu s.doc/ CDU_Benefits_of_TLS.html http:// brycebaril.github.io/glitch- perf-talk/ https://medium.com/ skyshidigital/6-tricks-to- speed-up-and-improve- your-node-js-performance- fadc06d15cbe https:// www.nearform.com/blog/ tuning-node-js-app- performance-with- autocannon-and-0x/ https://www.youtube.com/ watch?v=gltzZjKYK1I https://nodejs.org/uk/ docs/guides/dont-block- the-event-loop/ https:// www.smashingmagazine.co m/2018/06/nodejs-tools- techniques-performance- servers/ https://snyk.io/blog/ nodejs-how-even-quick- async-functions-can-block- the-event-loop-starve-io/ (IMPORTANT) https://itnext.io/streams- for-the-win-a- performance-comparison- of-nodejs-methods-for- reading-large-datasets- pt-2-bcfa732fa40e (IMPORTANT) https://zaiste.net/ nodejs_10_asynchronous_it eration_async_generators/ (IMPORTANT) https://v8.dev/blog/fast- async https://stackoverflow.com/ questions/86513/why-is- using-the-javascript-eval- function-a-bad-idea https://thoughts.t37.net/ how-we-reindexed-36- billions-documents-in-5- days-within-the-same- elasticsearch-cluster- cd9c054d1db8 https://www.youtube.com/ watch?v=EGMacfyuA9w (new relic) https://scotch.io/tutorials/ how-to-optimize-node- requests-with-simple- caching-strategies https:// www.medianova.com/en- blog/2016/09/29/50- faster-websites-with-http2 https://www.youtube.com/ watch?v=7uNGKCao8gA https://w3c.github.io/ ServiceWorker/#cache https://nodejs.org/api/ perf_hooks.html#perf_hoo ks_examples https://techsparx.com/ nodejs/howto/csv- transformation.html https://medium.com/ @atulanand94/beginners- guide-to-writing-nodejs- addons-using-c-and-n-api- node-addon- api-9b3b718a9a7f https:// www.smashingmagazine.co m/2017/04/guide-http2- server-push/ @erickwendel_

×