Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mongrel 2

Mongrel 2

A quick introduction to the Mongrel 2 webserver protocol.

F51da3602a201d3dca41fa924e29b29d?s=128

Will Speak

March 30, 2016
Tweet

Transcript

  1. MONGREL 2 Will Speak

  2. A STORY or how Mongrel 2 came to be

  3. RAGEL in the beginning there was the state machine compiler

  4. RAGEL STATE MACHINE COMPILER ⇒ Compiles state machines into code

  5. tokenising, regex & parser combines

  6. fast and efficient parsing

  7. MONGREL then came a

  8. Ruby webserver Rock solid HTTP parser Easily scalable

  9. ØMQ along came a whole lot of nothing

  10. Provides a brokerless messaging architecture where clients and servers communicate

    via a Berkeley Sockets style interface “
  11. a standard socket looks just like

  12. a standard socket far more than

  13. MONGREL 2 Add them all together and you get

  14. fast and efficient parsing tried and tested HTTP support brokerless

    scalability from Mongrel Ragel ZeroMQ
  15. fast and efficient parsing tried and tested HTTP support brokerless

    scalability from Mongrel Ragel ZeroMQ
  16. fast and efficient parsing tried and tested HTTP support brokerless

    scalability from Mongrel Ragel ZeroMQ
  17. synchronous http requests offloads

  18. persistent state async protocols &

  19. A PROTOCOL or what Mongrel 2 can do for us

  20. REQUEST/RESPONSE a millisecond in the life of a mongre2 request

  21. None
  22. Request 1 Server IIS-01 Headers { “method”: “post”, … }

    Path /LockedQueueNoSql Body { “name”: “willspeak”, “affiliates”: [ …. ]}
  23. Request 1 Server IIS-01 Headers { “method”: “post”, … }

    Path /LockedQueueNoSql Body { “name”: “willspeak”, “affiliates”: [ …. ]}
  24. Request 1 Server IIS-01 Response [ { … }, {

    … }, …. ]
  25. Request 1 Server IIS-01 Response [ { … }, {

    … }, …. ]
  26. None
  27. None
  28. None
  29. None
  30. None
  31. NETSTRINGS simple data serialisation

  32. 12:hello world!, prefixed by length data encoded as UTF-8 assemble

    the delimiter committee
  33. PACKETS inside the envelope

  34. 12:hello world!, prefixed by length data encoded as UTF-8 assemble

    the delimiter committee
  35. REQUEST PACKET FORMAT IIS-01 1 hello/world 2:{},4:body, webserver id requested

    path numeric request id netstring encoded json request headers netstring encoded request body
  36. RESPONSE PACKET FORMAT IIS-01 1:1, hello Mongrel2 webserver id response

    data space-separated netstring of response ids
  37. DEMO what you’ve all been waiting for

  38. USEFUL LINKS Mongrel 2 http://mongrel2.org/ https://github.com/mongrel2/mongrel2 Ragel http://www.colm.net/open-source/ragel/ http://zedshaw.com/archive/ragel-state-charts/ ØMQ

    http://zeromq.org/ http://netmq.readthedocs.org/ netstrings https://cr.yp.to/proto/netstrings.txt