5. Do the DuoDisco!
● Mark Meeuwenoord, Klasien van de Zandschulp,
James Bryan Graves
● It’s fun. Profit comes later
1. Download app
2. Join disco
3. Dance
4. Find partner → score!
5. goto 3
6. DuoDisco Architecture
● Table: player
○ id
○ name
○ status (“waiting”, “playing”, “loading”, etc)
○ connected (true / false)
○ connected_to (player id FK)
○ current_song_id
7.
8. Disco architecture issues
● Race Condition Paradise
○ Connection drops
○ Connection latency
○ Subtle client differences
● These bugs never happen while you’re
developing
● Player A → Player B, Player B → Player C
○ Debugging nightmare..
9.
10. So what about that Erlang thing?
● A language, VM and runtime system
● Fault tolerant
● Concurrent
● Functional
● In use by major players
11. Erlang: Fault Tolerance
● Systems will error
● “Let it crash”
○ Only program the happy path
● You will be restarted
○ by your supervisor
○ with a clean slate
12. Erlang: Concurrence
● Processes (“Actors”) are cheap
● Processes communicate
● Processes contain state
13. Erlang: It’s Functional
● Assign-once
● Pattern matching
● No loops
○ use (tail)recursion
○ list comprehensions, map/reduce
● It has a WEIRD SYNTAX? ?F()(*$#)(*#
○ I had to say it somewhere
○ Look at Elixir, it rocks. http://elixir-lang.org/
14. Erlang + Web = Zotonic
● “The Django of Erlang”
● Web development framework
○ Built-in web server; CMS
○ Opinionated & extensible
● Great performance out-of-the-box
● Easy to use data model
○ Semantic web “everything is a thing”
15. Back in the Disco…
● 3 clients, iOS, Android & HTML
● Backend: Erlang + Zotonic (obviously...)
● JSON over WebSockets
● REST for login / discovery
● Zotonic manages data model
○ (media files, multiple disco’s)
16. DuoDisco refactoring
● Model it the Erlang way
● Every player is a process
● “Room” processes for connected players
● One match-making process
○ Uses process registry for querying processes
17.
18.
19. DuoDisco findings
● First try-out at Extrapool Festival 2 wks ago
● No more weird bugs!
● Lessons learned
○ Think (a bit) before you code
○ Use the right tool for the job
○ Dare to iterate and start over
20. Links
http://erlang.org/ - the Erlang language
http://zotonic.com/ - The web framework
http://duodisco.nl/ - Duo Disco app info
http://elixir-lang.org/ - Erlang with different syntax
21. Thanks! Questions?
Contact:
● http://twitter.com/acscherp
● http://miraclethings.nl/
● http://github.com/arjan
● buy me a beer :p