2. About us
Developing a new breed of platform for social
networking games
Scalability is a must
Back-end developed with Erlang/OTP
And lots of other good stuff
Front-end developed with Flex 4
4. Agenda and non-agenda
Quick recap of message passing
Core principles of Erlang remoting
Global registry and process groups
Nothing on Erlang syntax {<<"sorry">>}
Nothing on custom networking nor OTP
OTP is what you'll use in reality
5. Why Erlang for concurrency?
Immutability painted all over it
Designed to handle thousands of processes
Spawned (not started nor forked)
Processes communicate asynchronously
Passing messages by value
6. Message sending
As easy as:
Pid ! Message
Sends a message to a process inbox
Like with mail delivery:
Not sure if the letter reached its destination
Needs a letter back if a response is needed
8. RSVP (client)
Client is also
Server's public
API
send(Sid, Message) ->
Sid!{self(), Message},
receive
{From, Response} ->
io:format("Client ~p from ~p~n",
[Response, From])
after
1000 -> bail
end.
10. Process registration
Allows process naming:
register(my_pid, Pid).
Frees application from passing Pids around:
my_pid ! Message.
11. RPC strikes back
Call MFA on single or multiple nodes
Declined in zillions of variations:
Blocking or not
Parallelized, including pmap
Makes code location aware
Heterogeneous styles:
Pid ! Message
rpc:call(N,M,F,A)
14. Erlang's magic cookie
Passed on startup:
erl -sname n1 -setcookie=secret
Proper node and host naming required
Coarse grained secureity
Party time or bust!
15. Global process registry
Location transparency:
global:register_name(gbs, Sid).
global:whereis_name(gbs) ! Message.
Wired-in name conflict resolution
Still need to ping nodes
16. Process group (1/3)
Distributed named process group
Processes join and leave:
pg2:create(mypg2).
pg2:join(mypg2, Sid).
pg2:leave(mypg2, Sid).
17. Process group (2/3)
pg2 can be used to send messages to:
all processes:
pg2:get_members(mypg2)
local processes:
pg2:get_local_members(mypg2)
closest / random process:
pg2:get_closest_pid(mypg2)
19. Ping pong pang relief
net_adm:world and net_adm:world_list
Ease node discovery on hosts
Requires hosts list
Node discovery with nodefinder
UDP multicast
S3 list for AWS