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

Elixir cluster

Elixir cluster

Yutaka Nishimura

September 05, 2016
Tweet

More Decks by Yutaka Nishimura

Other Decks in Technology

Transcript

  1. &MJYJSͰ
    ΫϥελϦϯά
    ϑΝϯίϛϡχέʔγϣϯζ
    ٕज़։ൃ෦੢ଜ

    View full-size slide

  2. ࣗݾ঺հ
    w ג
    ϑΝϯίϛϡχέʔγϣϯζ
    w ٕज़։ൃ෦
    w αʔόαΠυɺΠϯϑϥ
    w +BWB4DBMB
    w 3FETIJGU 5SFBTVSF%BUB "VSPSB 4QBSL
    w ࠷ۙɺ&MJYJS৮͍ͬͯ·͢ɻ

    View full-size slide

  3. &MJYJSͷಛ௃
    w ϓϥοτϑΥʔϜ
    w 4DBMBCJMMJUZεέʔϧ͠΍͢͞
    w 'BVMUUPMFSBODFରো֐ੑ
    w ݴޠ
    w 'VODUJPOBMQSPHSBNNJOHؔ਺ܕϓϩάϥϛϯά
    w &YUFOTJCJMJUZBOE%4-T֦ு͠΍͢͞ͱ%4-
    w πʔϧʢΤίγεςϜͱର࿩؀ڥʣ

    View full-size slide

  4. εέʔϧ͠΍͢͞
    w ਨ௚εέʔϧʢ7.ͷॲཧೳྗʣ
    w ܰྔϓϩηε
    w ਫฏεέʔϧʢෳ਺7.ͷ࿈ܞʣ
    w ϊʔυؒϓϩηε௨৴

    View full-size slide

  5. ϕʔε͸ʮϊʔυʯ
    w ϊʔυ͸#&".7.
    w #&".7.͸ɺ&SMBOH&MJYJSͷ࣮ߦ؀ڥ
    w 04ͷ֤छػೳΛ଱ো֐ੑΛߴΊͯಠࣗʹ࠶࣮૷ͯ͠Δ7.
    w ΫϥελϦϯάػೳΛݴޠ7.ϨϕϧͰඪ४αϙʔτ
    w ઀ଓͰ͖Δϊʔυ
    w ϩʔΧϧ-"/Πϯλʔωοτ
    w ϊʔυؒͰͰ͖Δ͜ͱ
    w ϩʔΧϧϊʔυͰͰ͖Δ͜ͱʢϓϩηεىಈɺॲཧ࣮ߦͳͲʣ͸΄΅Ͱ͖Δɻ
    w 4FSWFS$MJFOUΑΓ΋ɺ1FFS1FFSʹ͍ۙ

    View full-size slide

  6. ಈ࡞Πϝʔδ
    $MVTUFS
    #&".
    /PEF!MPDBMIPTU
    #&".
    /PEF!MPDBMIPTU
    -"/
    #&".
    /PEF!IPTU@UXP
    )PTU
    #&".
    OPEF!YDPN
    8"/
    ϓϩηε"
    ϓϩηεىಈ
    ॲཧ࣮ߦ
    ࣮ߦ݁Ռฦૹ
    ̍
    ̎
    ̏
    ϓϩάϥϜ
    ϓϩηε#

    View full-size slide

  7. )FMMP8PSME
    w MPDBMIPTUͰىಈͨ͠ϊʔυؒͰ)FMMP8PSME
    % iex --sname one
    iex(one@huracan)1>
    % iex --sname two
    iex(two@huracan)1> Node.connect(:'one@huracan')
    true
    iex(two@huracan)2> Node.list
    [:one@huracan]
    iex(two@huracan)3> Node.spawn_link(Node.list |> hd,
    fn -> IO.puts ‘Hello World, in #{Node.self}' end)
    #PID<8477.68.0>
    Hello World, in one@huracan

    View full-size slide

  8. ϊʔυͰࢼ͢ʢ̍ʣ
    ϊʔυ઀ଓ͢Δ
    % iex --sname one --cookie cookie1
    iex(one@huracan)1>
    % iex --sname three --cookie cookie1
    iex(three@host_b)1> Node.connect(:'one@huracan')
    true
    iex(three@host_b)2> Node.connect(:'two@huracan')
    true
    iex(three@host_b)3> Node.list
    [:one@huracan, :two@huracan]
    % iex --sname two --cookie cookie1
    iex(two@huracan)1>

    View full-size slide

  9. ϊʔυͰࢼ͢ʢ̎ʣ
    ϓϩάϥϜΛఆٛ͢Δ
    % iex --sname one --cookie cookie1
    iex(one@huracan)1> defmodule Hello do
    ...(one@huracan)1> def hello(name) do
    ...(one@huracan)1> IO.puts 'Hello #{name}, in #{Node.self}.'
    ...(one@huracan)1> end
    ...(one@huracan)1> end
    iex(one@huracan)2> Hello.hello(‘foo’)
    Hello foo, in one@huracan.
    % iex --sname two --cookie cookie1
    iex(two@huracan)1> defmodule Hello do … লུ
    iex(two@huracan)1> Hello.hello(‘foo’)
    Hello foo, in two@huracan.
    % iex --sname three --cookie cookie1
    iex(three@host_b)1> Hello.hello(‘foo’)
    ** (UndefinedFunctionError) undefined function Hello.hello/1

    View full-size slide

  10. ϊʔυͰࢼ͢ʢ̏ʣ
    ผϊʔυͷϓϩάϥϜΛ࣮ߦ
    % iex --sname three --cookie cookie1
    iex(three@host_b)6> Hello.hello('bar')
    ** (UndefinedFunctionError) undefined function
    Hello.hello/1 (module Hello is not available)
    iex(three@host_b)3> Node.list
    [:one@huracan, :two@huracan]
    iex(three@host_b)4> Node.list |> Enum.map(fn(node) ->
    ...(three@host_b)4> Node.spawn_link(node, fn ->
    ...(three@host_b)4> Hello.hello('bar') end)
    ...(three@host_b)4> end)
    Hello bar, in one@huracan
    Hello bar, in two@huracan
    [#PID<8193.132.0>, #PID<9717.84.0>]

    View full-size slide

  11. &MJYJSͦΖͦΖͲ͏Ͱ͠ΐ͏ʁ
    w ଴๬ͷ&MJYJSຊ೔ຊޠ༁Ͱ·ͨ͠ʂ
    ϓϩάϥϛϯά&MJYJS

    %BWF5IPNBT ஶ

    ࡫ాߞҰ ຋༁

    ௗҪઇ ຋༁

    View full-size slide

  12. &MJYJSͦΖͦΖͲ͏Ͱ͠ΐ͏ʁ
    w ࣮͸ɺ$FOU04Ͱ΋ZVNͰࢼͤ·͢
    GFEPSBެࣜϦϙδτϦϗεςΟϯάɿDPQS
    $FOU04$FOU04
    &MJYJS
    &SMBOH
    w IUUQTDPQSGFEPSBJOGSBDMPVEPSHDPQSTZOJTIJFMJYJS

    View full-size slide