Erlang:
Bring cloud to your application


                      Ngoc Dao
Normally, you bring
your application → cloud

Erlang lets you bring

cloud → your application
Normally,
cloud is at OS level


Erlang lets you create and control
cloud at application level,
your application
It’s because Erlang feels like an OS

You can control the OS in your application
ps → pman:start().
top → etop:start().
applications → applications
      appmon:start().
      webtool:start().
      observer:start().
“We are dropping appmon, and replacing it with observer instead.”
observer:start().
webtool alternative: BigWig
debugger:start().
Let’s create a cloud
Guest                                       Guest
machine                                     machine
            mynode1          mynode2

          Erlang process   Erlang process
          Erlang process   Erlang process
          Erlang process   Erlang process
                …                …




                                              Host
                                             machine
Create 2 nodes


$ erl -sname mynode1 -setcookie mypassword1 -detached

$ erl -sname mynode2 -setcookie mypassword2 -detached
Check if the nodes are on

$ ps aux
                          Host
                         machine
                                                                Guest
[output]                                                       machine
epmd -daemon
beam.smp ... -sname mynode1 -setcookie mypassword1 -noshell -noinput
beam.smp ... -sname mynode2 -setcookie mypassword2 -noshell -noinput


                                                      Guest
                                                     machine
Guest                                              Guest
machine                                            machine
            mynode1                 mynode2

          Erlang process          Erlang process
          Erlang process          Erlang process
          Erlang process          Erlang process
                …                       …




                           epmd                      Host
                                                    machine
Login to mynode1


$ erl -sname mynode3 -setcookie mypassword1 -remsh mynode1@ngoc



From here, to stop mynode1:
init:stop(). or q().

To quit without stoping mynode1:
Ctrl+C
More topics
• Deploy code to nodes
• Connect nodes together
• Hot code swap

Cloud Erlang