Slide 1

Slide 1 text

Phoenix @sasajuric

Slide 2

Slide 2 text

concurrency scalability fault tolerance predictable latency distributed systems high availability

Slide 3

Slide 3 text

“MVC” router sessions assets real-time communication dev productivity

Slide 4

Slide 4 text

Phoenix/Elixir Nginx Redis Sidekick/Resque Cron theerlangelist.com

Slide 5

Slide 5 text

OTP Erlang VM (BEAM) Cowboy Elixir Plug Phoenix Ecto

Slide 6

Slide 6 text

defmodule Math do def sum(x, y) do x + y end end Math.sum(2, 3)

Slide 7

Slide 7 text

m1 = Map.new m2 = Map.put(m1, :x, 1) m3 = Map.put(m2, :y, 2)

Slide 8

Slide 8 text

bar(foo(x), y, z) foo(x) |> bar(y, z)

Slide 9

Slide 9 text

a |> b |> c c(b(a))

Slide 10

Slide 10 text

a |> b |> c

Slide 11

Slide 11 text

Map.new |> Map.put(:x, 1) |> Map.put(:y, 2) m1 = Map.new m2 = Map.put(m1, :x, 1) m3 = Map.put(m2, :y, 2)

Slide 12

Slide 12 text

defmodule MyRouter do get "/some_path", MyModule, :some_fun end defmodule MyRouter do def route(conn, "GET", "/some_path") do MyModule.some_fun(conn) end end

Slide 13

Slide 13 text

defmodule MyRouter do use Phoenix.Router get "/some_path", MyModule, :some_fun end

Slide 14

Slide 14 text

scheduler scheduler scheduler scheduler CPU CPU CPU CPU VM

Slide 15

Slide 15 text

Plug.Adapters.Cowboy.http( MyServer, [], port: 5454 )

Slide 16

Slide 16 text

%Plug.Conn{ remote_ip: {151, 236, 219, 228}, host: "www.example.com", request_path: "/bar/baz", method: "GET", # ... }

Slide 17

Slide 17 text

defmodule MyServer do def init(opts), do: opts def call(conn, _opts) do conn |> Plug.Conn.put_resp_header("foo", "bar") |> Plug.Conn.put_resp_cookie("baz", "42") |> Plug.Conn.resp(200, "Hi!") end end

Slide 18

Slide 18 text

listener request 1 request 2 request 3 conn |>... conn |>... conn |>...

Slide 19

Slide 19 text

defmodule MyServer do use Plug.Builder plug Plug.RequestId plug Plug.Logger plug Plug.Static, at: "/static", from: "/folder" plug MyAuth plug :my_handle def my_handle(conn, opts) do # ... end end

Slide 20

Slide 20 text

Endpoint Router Controller View conn Model

Slide 21

Slide 21 text

$ mix phoenix.new hello --no-ecto # ... Fetch and install dependencies? [Yn] * running npm install && node node_modules/brunch/bin/brunch build * running mix deps.get We are all set! Run your Phoenix application: $ cd hello $ mix phoenix.server You can also run your app inside IEx (Interactive Elixir) as: $ iex -S mix phoenix.server

Slide 22

Slide 22 text

client server join "room:23" send "room:23", "Hello" send "room:23", "Hi" Socket

Slide 23

Slide 23 text

socket channel client channel PubSub

Slide 24

Slide 24 text

PubSub server 1 server 2 server 3

Slide 25

Slide 25 text

maturity CPU bound tasks learning curve

Slide 26

Slide 26 text

elixir-lang.org Getting started
 Mix & OTP www.phoenixframework.org

Slide 27

Slide 27 text

No content