Event Driven Architecture

Event Driven Architecture

Have you ever wondered what ReactPHP/NodeJs meant by "non blocking I/O"? Or why would being "event-driven" allow nginx to be more efficient than Apache?

If you find it easier to understand abstract concepts like these by implementing them, then you're in luck because in this talk we'll create a simple HTTP server, then develop an event loop and finally create a simple Promise class.

A78c676a05cd6d653609b237ed515601?s=128

Loïc Faugeron

August 17, 2016
Tweet

Transcript

  1. 1.

    Event Driven Architecture Understanding Event Loops and the point of

    async Loïc Faugeron http://constant.co @epiloic
  2. 8.

    8 @epiloic Caution! When the queue is full... Picture: Nick

    Webb (CC BY 2.0 - https://flic.kr/p/5AykUp)
  3. 21.

    Handling 10 000 clients? If only we could do something

    else while waiting... 21 @epiloic See the C10K problem: http://www.kegel.com/c10k.html by Dan Kegel
  4. 23.

    Many implementations select, poll, epoll, kqueue, IOCP 23 @epiloic See

    epoll VS kqueue: http://www.eecs.berkeley.edu/~sangjin/2012/12/21/epoll-vs-kqueue.html by Sangjin Han
  5. 41.

    “Blocking, If it’s not solving all your problems, You simply

    aren’t using enough of it.” 41 @epiloic
  6. 54.

    “Waiting, If it’s not solving all your problems, You simply

    aren’t using enough of it.” 54 @epiloic
  7. 63.

    Chaining calls To make it feel sync Picture: Mark Skipper

    (CC BY 2.0 - https://flic.kr/p/4FQ8DU)
  8. 64.

    “Callback, If it’s not solving all your problems, You simply

    aren’t using enough of it.” 64 @epiloic
  9. 68.

    Poor non-blocking support Cannot be used with poll() 68 @epiloic

    See asynchronous disk I/O: http://blog.libtorrent.org/2012/10/asynchronous-disk-io/ by Arvid Norberg
  10. 74.

    “Threading, If it’s not solving all your problems, You simply

    aren’t using enough of it.” 74 @epiloic
  11. 75.

    “Threading, If it’s not solving all your problems, You simply

    aren’t using enough of it.” 75 @epiloic NOT! Limits are good
  12. 76.

    76 @epiloic Infinite pool Error cause: Filesystem limit Picture: Nick

    Webb (CC BY 2.0 - https://flic.kr/p/5AykUp)
  13. 77.

    77 @epiloic Infinite limit Error cause: HDD/SSD burned Picture: Nick

    Webb (CC BY 2.0 - https://flic.kr/p/5AykUp)
  14. 78.

    True story Usually pool of 4 threads 78 @epiloic See

    ReactPHP filesystem - a word of caution: https://blog.wyrihaximus.net/2015/03/reactphp-filesystem/#a-word-of-caution by Cees-Jan Kiewiet
  15. 80.

    Making use of waiting time, to handle more clients 80

    @epiloic Non blocking Idle Sync Feeling Blocking Event Loop Scheduling Promise Thread Pool
  16. 81.

    81 @epiloic Used by... nginx See how it outperforms Apache:

    https://www.nginx.com/blog/nginx-vs-apache-our-view/ Picture: Thijs Feryn (https://speakerdeck.com/thijsferyn/varnish-or-nginx-symfony-live)
  17. 82.

    82 @epiloic Used by... Libuv (Node.js) Node.js is a trademark

    of Joyent, Inc. and is used with its permission. We are not endorsed by or affiliated with Joyent. See an Introduction to libuv: https://nikhilm.github.io/uvbook/introduction.html by Nikhil Marathe
  18. 84.

    Thank you 84 @epiloic Transcript of this presentation, in a

    blog article: https://gnugat.github.io/2016/04/27/event-driven-architecture.html