@josevalim / phoenixframework.org Glossary Phoenix (web framework) - - PowerPoint PPT Presentation

josevalim phoenixframework org glossary
SMART_READER_LITE
LIVE PREVIEW

@josevalim / phoenixframework.org Glossary Phoenix (web framework) - - PowerPoint PPT Presentation

@josevalim / phoenixframework.org Glossary Phoenix (web framework) Elixir (programming language) Erlang VM Switch Switch Browser Switch Server Endpoint http://stackoverflow.com/questions/1636455/where-is-


slide-1
SLIDE 1

@josevalim / phoenixframework.org

slide-2
SLIDE 2

Glossary

  • Phoenix (web framework)
  • Elixir (programming language)
  • Erlang VM
slide-3
SLIDE 3
slide-4
SLIDE 4

Switch Switch

slide-5
SLIDE 5

Switch

Browser Endpoint

Server

slide-6
SLIDE 6

http://stackoverflow.com/questions/1636455/where-is- erlang-used-and-why

slide-7
SLIDE 7

http://blog.whatsapp.com/index.php/ 2012/01/1-million-is-so-2011/

2 million connections

  • n a single node
slide-8
SLIDE 8

Intel Xeon CPU X5675 @ 3.07GHz 24 CPU - 96GB Using 40% of CPU and Memory

slide-9
SLIDE 9

Phoenix Channels

slide-10
SLIDE 10

var socket = new Phoenix.Socket("/ws"); socket.connect(); var channel = socket.channel(“chat:lobby"); channel.on("user_joined", function(message){ // ... }); channel.on("new_message", function(msg){ // ... }); $input.on("enter", function(e){ channel.push("new_message", { content: $input.val(), username: App.username }); }); channel.join();

slide-11
SLIDE 11

defmodule Chat.UserSocket do

use Phoenix.Socket

channel "chat:lobby", Chat.LobbyChannel channel "room:*", Chat.RoomChannel # def connect(params, socket) # def id(socket) end

slide-12
SLIDE 12

defmodule Chat.LobbyChannel do use Phoenix.Channel def join("chat:lobby", message, socket) do broadcast! socket, “user_joined”, %{username: message[“username"]} {:ok, socket} end def handle_in("new_message", message, socket) do broadcast socket, "new_message", %{content: message["content"], username: messages[“username"]} socket end end

slide-13
SLIDE 13

Server

Browser Native Mobile Embedded Device “Browser" (IE)

Outside view

Server

slide-14
SLIDE 14

Switch

Phone Phone Phone Phone

Outside view

Switch

slide-15
SLIDE 15

Inside view

Client Server Transport socket.connect() Channels socket.join(channel)

Pubsub

  • Distributed Erlang
  • Redis
  • PostgreSQL?
  • XMPP?
  • Isolated
  • Concurrent
slide-16
SLIDE 16

phoenixframework.org

slide-17
SLIDE 17
slide-18
SLIDE 18

Performance

slide-19
SLIDE 19

Channels Performance

slide-20
SLIDE 20

Subscribers per second

Time (s) Clients

slide-21
SLIDE 21

htop

slide-22
SLIDE 22

HTTP(S) Performance

slide-23
SLIDE 23

Library Throughput (req/s) Latency (ms) Plug (elixir) 198 328 0.63 Phoenix (elixir) 179 685 0.61 Gin (go) 176 156 0.65 Play (scala) 171 236 1.89 Express Cluster (node) 92 064 1.24 Martini (go) 32 077 3.35 Sinatra (ruby) 30 561 3.50 Rails (ruby) 11 903 8.50

$ wrk -t20 -c100 -d30S --timeout 2000 https://github.com/mroth/phoenix-showdown

slide-24
SLIDE 24

Inside view

Client Server

  • Isolated
  • Concurrent

/users /users / /admin /search?q=elixir

slide-25
SLIDE 25

Isolated and Concurrent

  • Crashes are isolated
  • Data is isolated


(GC is per process, no global pauses)

  • Load balances on IO and CPU


(efficient on multicore)

slide-26
SLIDE 26

Productivity

slide-27
SLIDE 27

Productivity

  • Short-term productivity
  • Documentation / Guides
  • Workflows / Generators
  • Long-term productivity
  • Introspection
  • Maintainability
slide-28
SLIDE 28
slide-29
SLIDE 29
slide-30
SLIDE 30

Generators as learning tools

$ mix phoenix.gen.html $ mix phoenix.gen.json $ mix phoenix.gen.channel

slide-31
SLIDE 31

More…

  • Form builders
  • Static build tools with ES6 as default
  • Live reloading
  • Pretty error pages
  • First-class concurrent test tools
  • Packages via hex.pm
slide-32
SLIDE 32

Long term productivity: Functional Programming

slide-33
SLIDE 33

Long term productivity: Applications

slide-34
SLIDE 34

Application

Pubsub Super visor TCP

Client

slide-35
SLIDE 35

Applications

  • Package and run our code
  • Can be started and stopped as a unit
  • Provide unified configuration
  • Hold processes and state in the

supervision tree

slide-36
SLIDE 36

Observer Demo

slide-37
SLIDE 37

Applications

  • Introspection & Monitoring
  • Visibility of the application state
  • Easy to break into "components"
  • Reasoning when things go wrong
slide-38
SLIDE 38

Summing up

slide-39
SLIDE 39

phoenixframework.org

slide-40
SLIDE 40
slide-41
SLIDE 41

elixir-lang.org

slide-42
SLIDE 42
slide-43
SLIDE 43

consulting and software engineering

slide-44
SLIDE 44

consulting and software engineering

Elixir coaching Elixir design review Custom development

slide-45
SLIDE 45

@josevalim / phoenixframework.org