Efficient Web Applications with Erlang and Cowboy

The Web is made for Erlang

Loïc Hoguin - @lhoguin

Erlang Cowboy and Nine Nines Founder

The Web yesterday

The Web today

What makes it possible?

What does the Web needs exactly?

Efficiency?

Concurrency?

Availability?

According to Joe Armstrong, you need:

Trine

Erlang, Erlang, Erlang

Erlang models the real world

Error handling and recovery

Erlang is easy to read and write

Erlang systems grow naturally

What does a HTTP server look like?

This is what Cowboy is doing

Then is Cowboy sequential?

Is it really effi-- YES!

And then I realized...

Trying out Siege


% siege -b -c 100 -t 30s http://192.168.1.101:8080 
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
Transactions:                 518565 hits
Availability:                 100.00 %
Elapsed time:                  29.76 secs
Data transferred:               5.93 MB
Response time:                  0.01 secs
Transaction rate:           17424.90 trans/sec
Throughput:                     0.20 MB/sec
Concurrency:                   98.86
Successful transactions:      518565
Failed transactions:               0
Longest transaction:            0.06
Shortest transaction:           0.00

Bigger Siege


% siege -b -c 1000 -t 30s http://192.168.1.101:8080
** SIEGE 2.70
** Preparing 1000 concurrent users for battle.
Transactions:                 106280 hits
Availability:                 100.00 %
Elapsed time:                  52.41 secs
Data transferred:               1.22 MB
Response time:                  0.37 secs
Transaction rate:            2027.86 trans/sec
Throughput:                     0.02 MB/sec
Concurrency:                  747.29
Successful transactions:      106281
Failed transactions:               0
Longest transaction:            6.26
Shortest transaction:           0.00

The thing about benchmarks

The Horse project

Sweet Poney benchmark

Hardware

Hello world results

Raspberry Pi results

Raspberry Siege


% siege -b -c 100 -t 30s http://192.168.1.14:8080
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
Transactions:                   7986 hits
Availability:                 100.00 %
Elapsed time:                  29.58 secs
Data transferred:               0.09 MB
Response time:                  0.37 secs
Transaction rate:             269.98 trans/sec
Throughput:                     0.00 MB/sec
Concurrency:                   99.27
Successful transactions:        7986
Failed transactions:               0
Longest transaction:            0.52
Shortest transaction:           0.20

1KB static file

100KB static file

Integrate Cowboy in your applications

Hello PHP FCGI


% siege -b -c 100 -t 30s http://192.168.1.101:8080/hello.php
** SIEGE 2.70
** Preparing 100 concurrent users for battle.
Transactions:                  65535 hits
Availability:                 100.00 %
Elapsed time:                  29.94 secs
Data transferred:               0.75 MB
Response time:                  0.03 secs
Transaction rate:            2188.88 trans/sec
Throughput:                     0.03 MB/sec
Concurrency:                   56.34
Successful transactions:       65535
Failed transactions:               0
Longest transaction:            0.43
Shortest transaction:           0.00

Experimental FCGI code is experimental

wsdemo benchmark

Real world application stats

Is it webscale?

Is there a catch?

How is this possible?

Erlang the OS

Real world Erlang system design

Erlang system design 101

Architecture of an Erlang web app

Scale to the infinite and beyond

Erlang gives you the tools to measure

What you don't need anymore

Getting started

Questions?