SlideShare a Scribd company logo
1 of 58
Misultin
                      [pron.: Mee-sool-téen]



An Erlang library for building fast lightweight HTTP(S) servers




>-|-|(°>
  Erlang User Group London - May 16th, 2011
Who am I?
Technologist and Entrepreneur. I am
particularly interested in Erlang, Python,
scalability, research, development and
integration of the multiple technologies
behind the creation of ubiquitous
computing. I’m currently co-founder
and CTO of WideTag Inc [widetag.com].


e: roberto@ostinelli.net
t: @ostinelli
<1>
What are Misultins?
Misultin are a culinary specialty of the Lake of Como.
They are lake fishes that go by the latin name of Alosa
fallax lacustris, treated and cooked in a traditional
and specific way.
What is Misultin?
Misultin (pronounced mee-sool-téen) is an Erlang
library for building fast lightweight HTTP(S) servers,
which also supports websockets.




   >-|-|(°>
Why another lib?
When do programmers start a new lib?

  ‣ Nothing similar exists
  ‣ Different Approach / Focus
  ‣ Total Control / Knowledge
  ‣ Experiment/Hack/Academic
Features v0.7.1
‣ Embedded, not application
‣ ~ HTTP/1.1
‣ Support for GET, POST, HEAD, PUT, DELETE, TRACE and CONNECT
‣ SSL
‣ Output compression            [gzip, deflate]


‣ Chunked / Stream / File sending [attachment, visualization]
‣ Customizable parameters               [max_connections, post_max_size, get_url_max_size, ...]


‣ Multiple servers on a single node                [custom name / nameless]


‣ Websockets    [also on SSL]


‣ Trapping of client closing a browser in Comet applications
‣ With / without Parametrized Modules
</1>
<2>
Code | “Hello World”
Simple “Hello World” using parametrized modules.
Code | “Hello World”
Simple “Hello World” not using parametrized modules.
Code | File Sending
Simple file sending.
Code | REST
Code | Websocket
1. Start Misultin specifying a Websocket loop.
Code | Websocket
2. Send the HTML + Js page.
Code | Websocket
3. Handle Websocket Data on server.
Code | Websocket
Live Demo.
Code | Server Options
start_link(Options) -> Result

Options = [Option]
Option = {ip, list() | tuple()} |
 {port, integer()} |
 {name, atom()|false} |
 {max_connections, integer()} |
 {post_max_size, integer()} |
 {get_url_max_size, integer()} |
 {compress, true|false} |
 {loop, fun()} |
 {autoexit, true|false} |
 {ws_loop, fun()|none} |
 {ws_autoexit, true|false} |
 {backlog, integer()} |
 {acceptors_poolsize, integer()} |
 {recv_timeout, integer()} |
 {ssl, SslOptions}
  SslOptions = [SslOption(§)]
</2>
<3>
Design | Overview
                 proc_lib:spawn_link/3
   gen_server
                                          Acceptor          TCP Acceptor
    [misultin]
                                                        . erlang:spawn/1
                        Acceptor
                                                           . gen_tcp:controlling_process/2
Main gen_server                                             . call to gen_server to:
                                                                  - http_pid_ref_add/2: add new pid to ref
                                                                  - erlang:monitor/2: for gen_server count



                    Http Process         Http Process       Http Process        HTTP Logic



                                                                      erlang:spawn_link/1




                                                              HttpLoop          Application Logic
Design | Crash: Acceptor
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: Acceptor
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: Acceptor
                 proc_lib:spawn_link/3
   gen_server
                                          Acceptor       TCP Acceptor
    [misultin]
                    'EXIT' message:                  . erlang:spawn/1
                    gen_server respawns                 . gen_tcp:controlling_process/2
                    a new acceptor                         . call to gen_server to:
Main gen_server
                                                                 - http_pid_ref_add/2: add new pid to ref
                                                                 - erlang:monitor/2: for gen_server count



                                                         Http Process         HTTP Logic



                                                                    erlang:spawn_link/1




                                                           HttpLoop           Application Logic
Design | Crash: HttpProcess
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: HttpProcess
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count
                                                        1.


                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: HttpProcess
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count
                                                        1.


                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1

                                                       2.


                                                            HttpLoop         Application Logic
Design | Crash: HttpProcess
                 proc_lib:spawn_link/3
   gen_server
                                           Acceptor       TCP Acceptor
    [misultin]
                                                      . erlang:spawn/1
                                                         . gen_tcp:controlling_process/2
Main gen_server                                             . call to gen_server to:
                                                                  - http_pid_ref_add/2: add new pid to ref
                                                                  - erlang:monitor/2: for gen_server count
                     3. 'DOWN' message:
                                                          1.
                     decrease open
                     connections counter
                                                          Http Process         HTTP Logic



                                                                     erlang:spawn_link/1

                                                         2.


                                                              HttpLoop         Application Logic
Design | Crash: HttpLoop
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: HttpLoop
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: HttpLoop
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic

                                           'EXIT' message:
                                           HttpProcess sends
                                           HTTP 500 error          erlang:spawn_link/1
                                           message to client




                                                          HttpLoop           Application Logic
Design | Crash: gen_server
                 proc_lib:spawn_link/3
   gen_server
                                         Acceptor       TCP Acceptor
    [misultin]
                                                    . erlang:spawn/1
                                                       . gen_tcp:controlling_process/2
Main gen_server                                           . call to gen_server to:
                                                                - http_pid_ref_add/2: add new pid to ref
                                                                - erlang:monitor/2: for gen_server count



                                                        Http Process         HTTP Logic



                                                                   erlang:spawn_link/1




                                                          HttpLoop           Application Logic
Design | Crash: gen_server
  1.
                     proc_lib:spawn_link/3
       gen_server
                                             Acceptor       TCP Acceptor
        [misultin]
                                                        . erlang:spawn/1
                                                           . gen_tcp:controlling_process/2
Main gen_server                                               . call to gen_server to:
                                                                    - http_pid_ref_add/2: add new pid to ref
                                                                    - erlang:monitor/2: for gen_server count



                                                            Http Process         HTTP Logic



                                                                       erlang:spawn_link/1




                                                              HttpLoop           Application Logic
Design | Crash: gen_server
  1.                                         2.
                     proc_lib:spawn_link/3
       gen_server
                                                  Acceptor       TCP Acceptor
        [misultin]
                                                             . erlang:spawn/1
                                                                . gen_tcp:controlling_process/2
Main gen_server                                                    . call to gen_server to:
                                                                         - http_pid_ref_add/2: add new pid to ref
                                                                         - erlang:monitor/2: for gen_server count



                                                                 Http Process         HTTP Logic



                                                                            erlang:spawn_link/1




                                                                   HttpLoop           Application Logic
Design | Crash: gen_server
  1.                                          2.
                     proc_lib:spawn_link/3
       gen_server
                                                    Acceptor       TCP Acceptor
        [misultin]
                                                               . erlang:spawn/1
                                                                  . gen_tcp:controlling_process/2
Main gen_server                                                      . call to gen_server to:
                                                                           - http_pid_ref_add/2: add new pid to ref
                          terminate(_,_) ->                                - erlang:monitor/2: for gen_server count
                             exit(HttpPid, kill).                  3.


                                                                   Http Process         HTTP Logic



                                                                              erlang:spawn_link/1




                                                                     HttpLoop           Application Logic
Design | Crash: gen_server
  1.                                          2.
                     proc_lib:spawn_link/3
       gen_server
                                                    Acceptor       TCP Acceptor
        [misultin]
                                                               . erlang:spawn/1
                                                                  . gen_tcp:controlling_process/2
Main gen_server                                                      . call to gen_server to:
                                                                           - http_pid_ref_add/2: add new pid to ref
                          terminate(_,_) ->                                - erlang:monitor/2: for gen_server count
                             exit(HttpPid, kill).                  3.


                                                                   Http Process         HTTP Logic



                                                                              erlang:spawn_link/1

                                                                  4.



                                                                       HttpLoop         Application Logic
</3>
<4>
Benchmarks | Foreword
‣ No such thing as generic benchmarks: specific case
 [fast application times, loads of connections, small data]


‣ ‘Fast’ is only 1 of the ‘n’ features you want
 [stability, features, ease of maintenance, low standard deviation, code usability, ...]


‣ This is no ‘pissing’ contest. *Not* what I wanted to see:
Benchmarks | Test
‣ Not only Erlang

‣ Chosen libraries are all lightweight & dynamic
 [compare apple with apples: no Yaws, no Nginx]


‣ Periodically close down the TCP connection

‣ All tests run on a single CPU

‣ No RAM/CPU considerations
Benchmarks | Test
‣ ‘Dynamic’ tests: no “Hello world”

The test basically asks servers to:

 • check if a GET variable is set

 • if the variable is not set, reply with an XML stating the error:

   <http_test><error>no value specified</error></http_test>

 • if the variable is set, echo it inside an XML

   <http_test><value>MYVALUE</value></http_test>
Benchmarks | Setup
‣ Patched HttPerf
 [for higher file handling]


‣ Virtualized Up-to-date Ubuntu 10.04 LTS, 2CPU, 1.5G Ram
 [tuning of /etc/sysctl.conf and /etc/security/limits.conf]


‣ Libraries:

 •   Misultin 0.7.1 (Erlang R14B02)
 •   Mochiweb 1.5.2 (Erlang R14B02)
 •   Cowboy master 420f5ba (Erlang R14B02)
 •   NodeJS 0.4.7
 •   Tornadoweb 1.2.1 (Python 2.6.5)

‣ All the libraries have been run with the standard settings. Erlang
  was launched with Kernel Polling enabled, and with SMP
  disabled so that a single CPU was used by all the libraries.
Benchmarks | Results
Benchmarks | Results
Benchmarks | Results
Benchmarks | Results
</4>
<5>
Comet | Practical issues
       HTTP Logic



       Http Process




spawn_link/1




         HttpLoop



    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                        1. Building Req: {active, once} | gen_tcp:recv/3
                        2. Spawn HttpLoop, enter socket_loop/3


spawn_link/1




         HttpLoop



    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                         1. Building Req: {active, once} | gen_tcp:recv/3
                         2. Spawn HttpLoop, enter socket_loop/3
               Actual TCP
               sending
spawn_link/1



               Data to be Sent




         HttpLoop



    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                         1. Building Req: {active, once} | gen_tcp:recv/3
                         2. Spawn HttpLoop, enter socket_loop/3
               Actual TCP
               sending           => monitor Socket while in socket_loop?
spawn_link/1



               Data to be Sent




         HttpLoop



    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                         1. Building Req: {active, once} | gen_tcp:recv/3
                         2. Spawn HttpLoop, enter socket_loop/3
               Actual TCP
               sending           => monitor Socket while in socket_loop?
spawn_link/1                     => get data from Socket while in socket_loop?

               Data to be Sent




         HttpLoop



    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                         1. Building Req: {active, once} | gen_tcp:recv/3
                         2. Spawn HttpLoop, enter socket_loop/3
               Actual TCP
               sending           => monitor Socket while in socket_loop?
spawn_link/1                     => get data from Socket while in socket_loop?

               Data to be Sent           CONFLICT:

                                         • Catch Client’s Socket closed event
         HttpLoop                        • Support HTTP pipelining

    Application Logic
Comet | Practical issues
       HTTP Logic



       Http Process
                         1. Building Req: {active, once} | gen_tcp:recv/3
                         2. Spawn HttpLoop, enter socket_loop/3
               Actual TCP
               sending           => monitor Socket while in socket_loop?
spawn_link/1                     => get data from Socket while in socket_loop?

               Data to be Sent           CONFLICT:

                                         • Catch Client’s Socket closed event
         HttpLoop                        • Support HTTP pipelining
                                          SOLUTION:
    Application Logic
                                          handle_http(Req) ->
                                             Req:options([{comet, true}]),
                                             ...
</5>
Thank you
e: roberto@ostinelli.net
t: @ostinelli




   >-|-|(°>

More Related Content

Similar to Misultin 0.7.1 Presentation

Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Naoya Nakazawa
 
Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHPchobi e
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Tim Burks
 
Nginx internals
Nginx internalsNginx internals
Nginx internalsliqiang xu
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Puppet
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientKnoldus Inc.
 
Introduction enovy
Introduction enovyIntroduction enovy
Introduction enovy岩 夏
 
NGINX: HTTP/2 Server Push and gRPC – EMEA
NGINX: HTTP/2 Server Push and gRPC – EMEANGINX: HTTP/2 Server Push and gRPC – EMEA
NGINX: HTTP/2 Server Push and gRPC – EMEANGINX, Inc.
 
OpenShift/Kubernetes to Splunk log integration
OpenShift/Kubernetes to Splunk log integrationOpenShift/Kubernetes to Splunk log integration
OpenShift/Kubernetes to Splunk log integrationMichiel Kalkman
 
Vault Secrets Via API for the REST of Us
Vault Secrets Via API for the REST of UsVault Secrets Via API for the REST of Us
Vault Secrets Via API for the REST of UsMitchell Pronschinske
 
JDO 2019: Service mesh with Istio - Mariusz Gil
JDO 2019: Service mesh with Istio - Mariusz GilJDO 2019: Service mesh with Istio - Mariusz Gil
JDO 2019: Service mesh with Istio - Mariusz GilPROIDEA
 
Managing the logs of your (Rails) applications - Arrrrcamp 2011
Managing the logs of your (Rails) applications - Arrrrcamp 2011Managing the logs of your (Rails) applications - Arrrrcamp 2011
Managing the logs of your (Rails) applications - Arrrrcamp 2011lennartkoopmann
 
Observability tips for HAProxy
Observability tips for HAProxyObservability tips for HAProxy
Observability tips for HAProxyWilly Tarreau
 
Pandora FMS: Sun One webserver
Pandora FMS: Sun One webserverPandora FMS: Sun One webserver
Pandora FMS: Sun One webserverPandora FMS
 
NGINX: HTTP/2 Server Push and gRPC
NGINX: HTTP/2 Server Push and gRPCNGINX: HTTP/2 Server Push and gRPC
NGINX: HTTP/2 Server Push and gRPCNGINX, Inc.
 
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"Flink Forward
 
Monitoring Flink with Prometheus
Monitoring Flink with PrometheusMonitoring Flink with Prometheus
Monitoring Flink with PrometheusMaximilian Bode
 

Similar to Misultin 0.7.1 Presentation (20)

Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24
 
Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHP
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
Nginx internals
Nginx internalsNginx internals
Nginx internals
 
Php version 5
Php version 5Php version 5
Php version 5
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP Client
 
Introduction enovy
Introduction enovyIntroduction enovy
Introduction enovy
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
NGINX: HTTP/2 Server Push and gRPC – EMEA
NGINX: HTTP/2 Server Push and gRPC – EMEANGINX: HTTP/2 Server Push and gRPC – EMEA
NGINX: HTTP/2 Server Push and gRPC – EMEA
 
OpenShift/Kubernetes to Splunk log integration
OpenShift/Kubernetes to Splunk log integrationOpenShift/Kubernetes to Splunk log integration
OpenShift/Kubernetes to Splunk log integration
 
Vault Secrets Via API for the REST of Us
Vault Secrets Via API for the REST of UsVault Secrets Via API for the REST of Us
Vault Secrets Via API for the REST of Us
 
JDO 2019: Service mesh with Istio - Mariusz Gil
JDO 2019: Service mesh with Istio - Mariusz GilJDO 2019: Service mesh with Istio - Mariusz Gil
JDO 2019: Service mesh with Istio - Mariusz Gil
 
Managing the logs of your (Rails) applications - Arrrrcamp 2011
Managing the logs of your (Rails) applications - Arrrrcamp 2011Managing the logs of your (Rails) applications - Arrrrcamp 2011
Managing the logs of your (Rails) applications - Arrrrcamp 2011
 
Observability tips for HAProxy
Observability tips for HAProxyObservability tips for HAProxy
Observability tips for HAProxy
 
Pandora FMS: Sun One webserver
Pandora FMS: Sun One webserverPandora FMS: Sun One webserver
Pandora FMS: Sun One webserver
 
NGINX: HTTP/2 Server Push and gRPC
NGINX: HTTP/2 Server Push and gRPCNGINX: HTTP/2 Server Push and gRPC
NGINX: HTTP/2 Server Push and gRPC
 
Http2 kotlin
Http2   kotlinHttp2   kotlin
Http2 kotlin
 
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"
Flink Forward Berlin 2018: Maximilian Bode - "Monitoring Flink with Prometheus"
 
Monitoring Flink with Prometheus
Monitoring Flink with PrometheusMonitoring Flink with Prometheus
Monitoring Flink with Prometheus
 

Recently uploaded

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Recently uploaded (20)

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Misultin 0.7.1 Presentation

  • 1. Misultin [pron.: Mee-sool-téen] An Erlang library for building fast lightweight HTTP(S) servers >-|-|(°> Erlang User Group London - May 16th, 2011
  • 2. Who am I? Technologist and Entrepreneur. I am particularly interested in Erlang, Python, scalability, research, development and integration of the multiple technologies behind the creation of ubiquitous computing. I’m currently co-founder and CTO of WideTag Inc [widetag.com]. e: roberto@ostinelli.net t: @ostinelli
  • 3. <1>
  • 4. What are Misultins? Misultin are a culinary specialty of the Lake of Como. They are lake fishes that go by the latin name of Alosa fallax lacustris, treated and cooked in a traditional and specific way.
  • 5. What is Misultin? Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets. >-|-|(°>
  • 6. Why another lib? When do programmers start a new lib? ‣ Nothing similar exists ‣ Different Approach / Focus ‣ Total Control / Knowledge ‣ Experiment/Hack/Academic
  • 7. Features v0.7.1 ‣ Embedded, not application ‣ ~ HTTP/1.1 ‣ Support for GET, POST, HEAD, PUT, DELETE, TRACE and CONNECT ‣ SSL ‣ Output compression [gzip, deflate] ‣ Chunked / Stream / File sending [attachment, visualization] ‣ Customizable parameters [max_connections, post_max_size, get_url_max_size, ...] ‣ Multiple servers on a single node [custom name / nameless] ‣ Websockets [also on SSL] ‣ Trapping of client closing a browser in Comet applications ‣ With / without Parametrized Modules
  • 9. <2>
  • 10. Code | “Hello World” Simple “Hello World” using parametrized modules.
  • 11. Code | “Hello World” Simple “Hello World” not using parametrized modules.
  • 12. Code | File Sending Simple file sending.
  • 14. Code | Websocket 1. Start Misultin specifying a Websocket loop.
  • 15. Code | Websocket 2. Send the HTML + Js page.
  • 16. Code | Websocket 3. Handle Websocket Data on server.
  • 18. Code | Server Options start_link(Options) -> Result Options = [Option] Option = {ip, list() | tuple()} | {port, integer()} | {name, atom()|false} | {max_connections, integer()} | {post_max_size, integer()} | {get_url_max_size, integer()} | {compress, true|false} | {loop, fun()} | {autoexit, true|false} | {ws_loop, fun()|none} | {ws_autoexit, true|false} | {backlog, integer()} | {acceptors_poolsize, integer()} | {recv_timeout, integer()} | {ssl, SslOptions} SslOptions = [SslOption(§)]
  • 19. </2>
  • 20. <3>
  • 21. Design | Overview proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 Acceptor . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process Http Process Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 22. Design | Crash: Acceptor proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 23. Design | Crash: Acceptor proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 24. Design | Crash: Acceptor proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] 'EXIT' message: . erlang:spawn/1 gen_server respawns . gen_tcp:controlling_process/2 a new acceptor . call to gen_server to: Main gen_server - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 25. Design | Crash: HttpProcess proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 26. Design | Crash: HttpProcess proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count 1. Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 27. Design | Crash: HttpProcess proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count 1. Http Process HTTP Logic erlang:spawn_link/1 2. HttpLoop Application Logic
  • 28. Design | Crash: HttpProcess proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count 3. 'DOWN' message: 1. decrease open connections counter Http Process HTTP Logic erlang:spawn_link/1 2. HttpLoop Application Logic
  • 29. Design | Crash: HttpLoop proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 30. Design | Crash: HttpLoop proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 31. Design | Crash: HttpLoop proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic 'EXIT' message: HttpProcess sends HTTP 500 error erlang:spawn_link/1 message to client HttpLoop Application Logic
  • 32. Design | Crash: gen_server proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 33. Design | Crash: gen_server 1. proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 34. Design | Crash: gen_server 1. 2. proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref - erlang:monitor/2: for gen_server count Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 35. Design | Crash: gen_server 1. 2. proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref terminate(_,_) -> - erlang:monitor/2: for gen_server count exit(HttpPid, kill). 3. Http Process HTTP Logic erlang:spawn_link/1 HttpLoop Application Logic
  • 36. Design | Crash: gen_server 1. 2. proc_lib:spawn_link/3 gen_server Acceptor TCP Acceptor [misultin] . erlang:spawn/1 . gen_tcp:controlling_process/2 Main gen_server . call to gen_server to: - http_pid_ref_add/2: add new pid to ref terminate(_,_) -> - erlang:monitor/2: for gen_server count exit(HttpPid, kill). 3. Http Process HTTP Logic erlang:spawn_link/1 4. HttpLoop Application Logic
  • 37. </3>
  • 38. <4>
  • 39. Benchmarks | Foreword ‣ No such thing as generic benchmarks: specific case [fast application times, loads of connections, small data] ‣ ‘Fast’ is only 1 of the ‘n’ features you want [stability, features, ease of maintenance, low standard deviation, code usability, ...] ‣ This is no ‘pissing’ contest. *Not* what I wanted to see:
  • 40. Benchmarks | Test ‣ Not only Erlang ‣ Chosen libraries are all lightweight & dynamic [compare apple with apples: no Yaws, no Nginx] ‣ Periodically close down the TCP connection ‣ All tests run on a single CPU ‣ No RAM/CPU considerations
  • 41. Benchmarks | Test ‣ ‘Dynamic’ tests: no “Hello world” The test basically asks servers to: • check if a GET variable is set • if the variable is not set, reply with an XML stating the error: <http_test><error>no value specified</error></http_test> • if the variable is set, echo it inside an XML <http_test><value>MYVALUE</value></http_test>
  • 42. Benchmarks | Setup ‣ Patched HttPerf [for higher file handling] ‣ Virtualized Up-to-date Ubuntu 10.04 LTS, 2CPU, 1.5G Ram [tuning of /etc/sysctl.conf and /etc/security/limits.conf] ‣ Libraries: • Misultin 0.7.1 (Erlang R14B02) • Mochiweb 1.5.2 (Erlang R14B02) • Cowboy master 420f5ba (Erlang R14B02) • NodeJS 0.4.7 • Tornadoweb 1.2.1 (Python 2.6.5) ‣ All the libraries have been run with the standard settings. Erlang was launched with Kernel Polling enabled, and with SMP disabled so that a single CPU was used by all the libraries.
  • 47. </4>
  • 48. <5>
  • 49. Comet | Practical issues HTTP Logic Http Process spawn_link/1 HttpLoop Application Logic
  • 50. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 spawn_link/1 HttpLoop Application Logic
  • 51. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 Actual TCP sending spawn_link/1 Data to be Sent HttpLoop Application Logic
  • 52. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 Actual TCP sending => monitor Socket while in socket_loop? spawn_link/1 Data to be Sent HttpLoop Application Logic
  • 53. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 Actual TCP sending => monitor Socket while in socket_loop? spawn_link/1 => get data from Socket while in socket_loop? Data to be Sent HttpLoop Application Logic
  • 54. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 Actual TCP sending => monitor Socket while in socket_loop? spawn_link/1 => get data from Socket while in socket_loop? Data to be Sent CONFLICT: • Catch Client’s Socket closed event HttpLoop • Support HTTP pipelining Application Logic
  • 55. Comet | Practical issues HTTP Logic Http Process 1. Building Req: {active, once} | gen_tcp:recv/3 2. Spawn HttpLoop, enter socket_loop/3 Actual TCP sending => monitor Socket while in socket_loop? spawn_link/1 => get data from Socket while in socket_loop? Data to be Sent CONFLICT: • Catch Client’s Socket closed event HttpLoop • Support HTTP pipelining SOLUTION: Application Logic handle_http(Req) -> Req:options([{comet, true}]), ...
  • 56. </5>
  • 57.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. Http Process survives to handle persistent connections\n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n