$30 off During Our Annual Pro Sale. View Details »

Scaling event driven systems: Node.js and GraphQL

Scaling event driven systems: Node.js and GraphQL

Bogdan Nedelcu

May 31, 2020
Tweet

More Decks by Bogdan Nedelcu

Other Decks in Programming

Transcript

  1. @bogdanned
    Bogdan Nedelcu
    1
    Scaling event driven systems:
    Node.js and GraphQL
    Principal Software Engineer
    Node.js Global Summit 05.31.2020

    View Slide

  2. @bogdanned
    Once upon a time there was ...
    2

    View Slide

  3. @bogdanned
    … a monolith
    3

    View Slide

  4. @bogdanned
    … split into microservices
    4

    View Slide

  5. @bogdanned
    … choreographed by events
    5

    View Slide

  6. @bogdanned
    Event driven designs are focused on system
    behaviour rather than structure.
    6

    View Slide

  7. @bogdanned
    Node.js ...
    … an asynchronous event-driven runtime
    7

    View Slide

  8. @bogdanned
    How does Node scales?
    8

    View Slide

  9. @bogdanned
    Requirements
    - performant
    - cost effective
    - reliable, fail safe
    9

    View Slide

  10. @bogdanned
    Node performs well when the amount of
    CPU work per request is relatively “small”.
    10

    View Slide

  11. @bogdanned
    Scale Horizontally
    11

    View Slide

  12. @bogdanned
    Running more instances of a non
    performant app is not cost effective.
    12

    View Slide

  13. @bogdanned
    Scale Vertically
    13

    View Slide

  14. @bogdanned
    What about … building apps that leverage the
    hardware more?
    14

    View Slide

  15. @bogdanned
    Node inherits the Event Loop model that
    made Javascript successful in the
    browser.
    15

    View Slide

  16. @bogdanned
    Worker threads
    16

    View Slide

  17. @bogdanned 17

    View Slide

  18. @bogdanned
    Can I use worker threads for everything?
    18

    View Slide

  19. @bogdanned
    Spawning workers is expensive if done
    frequently.
    19

    View Slide

  20. @bogdanned
    How can I use this with GraphQL?
    20

    View Slide

  21. @bogdanned
    GraphQL subscriptions:
    - server: push data to client
    - clients: listen to real time messages
    21

    View Slide

  22. @bogdanned 22

    View Slide

  23. @bogdanned
    In the real world ...
    23

    View Slide

  24. @bogdanned 24

    View Slide

  25. @bogdanned
    Demo
    25

    View Slide

  26. @bogdanned 26

    View Slide

  27. @bogdanned
    Future work
    - deployment to cloud
    - add performance hooks
    - set up profiling
    27

    View Slide

  28. @bogdanned
    Summing Up
    - node is a perfect fit for event driven systems
    - worker threads improve performance
    - easily go fullstack with GraphQL
    28

    View Slide

  29. @bogdanned
    thank @you
    29

    View Slide

  30. @bogdanned
    Bogdan Nedelcu
    Entrepreneurial software engineer with a proven
    track record across large IT projects within the
    finance and construction industry.
    30

    View Slide