SlideShare a Scribd company logo
Going Multi-Node
Eric Oestrich
SmartLogic
Eric Oestrich
SmartLogic - smartlogic.io
GitHub: oestrich
Twitter: ericoestrich
Going Multi-Node
● What is a MUD?
● Clustering
● Leader Selection
● Spanning the Cluster
● Problems Encountered
ExVenture
exventure.org
Gossip
gossip.haus
midmud.com
MidMUD
What is a M.U.D.?
What is a MUD?
● Multi-User Dungeon
● Text based multiplayer game
● Started in the late 70s
● World of Warcraft or EverQuest, but with no graphics
What is a MUD?
What is a MUD?
Supervision Tree
● ExVenture
○ Cluster.Supervisor
○ Raft
○ Data.Repo
○ Web.Supervisor
○ Game.Supervisor
○ :ranch
Supervision Tree
● Game.Supervisor
○ Game.Session.Registry
○ Game.Config
○ Game.Caches
■ Game.Items
■ …
○ Game.Session.Supervisor
○ Game.World
Supervision Tree
● Game.World
○ Game.World.Master
○ Game.World.ZoneController
○ Game.ZoneSupervisor
○ Game.ZoneSupervisor
○ ...
Supervision Tree
● Game.ZoneSupervisor
○ Game.Zone
○ Game.Room.Supervisor
■ Game.Room
■ ...
○ Game.NPC.Supervisor
■ Game.NPC
■ ….
Starting Point
Everything Assumed One Node
● Heavy geared for a single node
● Most processes were local Registry
● Data stored in local ETS tables
● Lots of in process state (a virtual world)
Paths Forward
● Umbrella App
● Single Application
Single Application that is Cluster Aware
Clustering
libcluster
bitwalker/libcluster
libcluster
config :libcluster,
topologies: [
local: [
strategy: Cluster.Strategy.Epmd,
config: [
hosts: [:"world1@host", :"world2@host"]
]
]
]
Start the nodes
iex --sname world1 -S mix
iex --sname world2 -S mix
Start the nodes
Picking a leader
Raft Protocol
raft.github.io
Raft Basics
Raft Basics
Raft Basics
Raft Basics
Raft Basics
Picking a Leader
● Each node waits a random amount of time and picks itself
as leader
● Each other node votes for the first node it sees ask
● Once a majority is chosen the leader is picked and starts
the world
What the leader does
● Pushes zones out across the cluster
● When a node dies
○ Looks at zones that should be online
○ Spins them up across the cluster
Squabble
● ExVenture’s leader election has been pulled out
● GitHub: oestrich/squabble
Squabble Callbacks
defmodule MyApp.Leader do
@behaviour Squabble.Leader
@impl true
def leader_selected(term) do
end
@impl true
def node_down() do
end
end
Why a majority of the cluster?
Removing local Registry
Switch to :global registry
Spanning the Cluster
● Cache updates need to be updated on each node
● Process groups to handle this
● Might be a nicer way to handle these
Join the pg2 group on cache start
defmodule Game.Items do
@ets_key :items
def init(_) do
:ok = :pg2.create(@ets_key)
:ok = :pg2.join(@ets_key, self())
#...
end
Client API
def insert(item) do
members = :pg2.get_members(@ets_key)
Enum.map(members, fn member ->
GenServer.call(member, {:insert, item})
end)
end
Problems Encountered
Calls timing out
● Might be a network blip and a previously stable call is no
longer stable
Circuit Breakers
Circuit Breakers
Circuit Breakers
Things that should happen at most once
● Attached to Gossip, a chat service
● Each node connects as a websocket to Gossip
● New messages posted at most once to the local channel
● Only the leader node should handle these actions
Performance Tweaks
The journey from 230 to 3500
Single process being overloaded by messages
● Room processes became a bottleneck
● Create a side process that handles notifications
● PR #72
● ~230 -> ~600
Single process being overloaded by data size
● Session registry was overloaded with size of user data
● Pushing a large preloaded Ecto struct around
● Massively simplify what is stored
● PR #73
● ~600 -> ~1200
Too large messages
● The data being passed around was too large
● Same huge User structs
● Ran out of ram at 50GB
● Use same simplification in messages
● PR #74
● ~1200 -> ~3500
Going Multi-Node
Specs
- Intel Core i7-6700K
- Quad Core, with Hyperthreading
- 64GB of RAM
Demo
ExVenture Discord
https://discord.gg/GPEa6dB
Image Credits
http://discworld.starturtle.net/lpc/
http://www.majormud.com/
Thanks!
● GitHub: oestrich/ex_venture
● Documentation: exventure.org

More Related Content

PPT
Network
PPTX
Spesifikasi server
PDF
Presupuesto julio terminado convertido
PDF
The Ring programming language version 1.10 book - Part 8 of 212
PDF
MongoDB Drivers And High Availability: Deep Dive
PDF
Stripe CTF3 wrap-up
PDF
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
PDF
Killer Bugs From Outer Space
Network
Spesifikasi server
Presupuesto julio terminado convertido
The Ring programming language version 1.10 book - Part 8 of 212
MongoDB Drivers And High Availability: Deep Dive
Stripe CTF3 wrap-up
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
Killer Bugs From Outer Space

Similar to Going Multi-Node (20)

PDF
Optimizing Parallel Reduction in CUDA : NOTES
PDF
Beat Your Mom At Solitaire—Reverse Engineering of Computer Games
PDF
Transitioning to Native
PPTX
Troubleshooting MySQL from a MySQL Developer Perspective
PPTX
Lrz kurs: big data analysis
PDF
Defcon CTF quals
ODP
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
PPT
Computer Games Inner Workings - I. Loukeris AIT
PDF
Don't Give Credit: Hacking Arcade Machines
PDF
Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12
PDF
How to build a gaming computer
PPTX
Porting games from ps3 or web to shield and ouya [final]
PDF
Fast dynamic analysis, Kostya Serebryany
PDF
Константин Серебряный "Быстрый динамичекский анализ программ на примере поиск...
PDF
44 con slides
PDF
44 con slides (1)
PPTX
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
PDF
Programar para GPUs
PDF
Tomáš Čorej: Configuration management & CFEngine3
PDF
Why use JavaScript in Hardware? GoTo Conf - Berlin
Optimizing Parallel Reduction in CUDA : NOTES
Beat Your Mom At Solitaire—Reverse Engineering of Computer Games
Transitioning to Native
Troubleshooting MySQL from a MySQL Developer Perspective
Lrz kurs: big data analysis
Defcon CTF quals
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
Computer Games Inner Workings - I. Loukeris AIT
Don't Give Credit: Hacking Arcade Machines
Puppet@Citygrid - Julien Rottenberg - PuppetCamp LA '12
How to build a gaming computer
Porting games from ps3 or web to shield and ouya [final]
Fast dynamic analysis, Kostya Serebryany
Константин Серебряный "Быстрый динамичекский анализ программ на примере поиск...
44 con slides
44 con slides (1)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Programar para GPUs
Tomáš Čorej: Configuration management & CFEngine3
Why use JavaScript in Hardware? GoTo Conf - Berlin
Ad

More from SmartLogic (20)

PDF
Writing Game Servers with Elixir
PDF
All Aboard The Stateful Train
PDF
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
PDF
Monitoring Your Elixir Application with Prometheus
PPTX
Kubernetes and docker
PDF
Serializing Value Objects-Ara Hacopian
PDF
Guide to food foraging by SmartLogic's Kei Ellerbrock
PDF
Introduction to Type Script by Sam Goldman, SmartLogic
PDF
How SmartLogic Uses Chef-Dan Ivovich
PPTX
A Few Interesting Things in Apple's Swift Programming Language
PDF
Effective ActiveRecord
PDF
An Introduction to Reactive Cocoa
PDF
iOS Development Methodology
PPT
CSS Preprocessors to the Rescue!
PDF
Deploying Rails Apps with Chef and Capistrano
PDF
From Slacker to Hacker, Practical Tips for Learning to Code
PDF
The Language of Abstraction in Software Development
PDF
Android Testing: An Overview
PPTX
Intro to DTCoreText: Moving Past UIWebView | iOS Development
PDF
Logstash: Get to know your logs
Writing Game Servers with Elixir
All Aboard The Stateful Train
DC |> Elixir Meetup - Going off the Rails into Elixir - Dan Ivovich
Monitoring Your Elixir Application with Prometheus
Kubernetes and docker
Serializing Value Objects-Ara Hacopian
Guide to food foraging by SmartLogic's Kei Ellerbrock
Introduction to Type Script by Sam Goldman, SmartLogic
How SmartLogic Uses Chef-Dan Ivovich
A Few Interesting Things in Apple's Swift Programming Language
Effective ActiveRecord
An Introduction to Reactive Cocoa
iOS Development Methodology
CSS Preprocessors to the Rescue!
Deploying Rails Apps with Chef and Capistrano
From Slacker to Hacker, Practical Tips for Learning to Code
The Language of Abstraction in Software Development
Android Testing: An Overview
Intro to DTCoreText: Moving Past UIWebView | iOS Development
Logstash: Get to know your logs
Ad

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administraation Chapter 3
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Essential Infomation Tech presentation.pptx
PDF
System and Network Administration Chapter 2
PDF
AI in Product Development-omnex systems
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
history of c programming in notes for students .pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Nekopoi APK 2025 free lastest update
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administraation Chapter 3
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Essential Infomation Tech presentation.pptx
System and Network Administration Chapter 2
AI in Product Development-omnex systems
Softaken Excel to vCard Converter Software.pdf
CHAPTER 2 - PM Management and IT Context
history of c programming in notes for students .pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Upgrade and Innovation Strategies for SAP ERP Customers
How Creative Agencies Leverage Project Management Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Reimagine Home Health with the Power of Agentic AI​
Understanding Forklifts - TECH EHS Solution
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Nekopoi APK 2025 free lastest update
How to Choose the Right IT Partner for Your Business in Malaysia

Going Multi-Node