SlideShare a Scribd company logo
Creating scalable game
servers
Who am i?
• Coded games for more than 8 years professionally
• Worked on networking middleware at MuchDifferent and wrote a
Unity emulator for servers there
• Worked on multiple multiplayer games for mobile, webGL and on a
kids MMO for south Korean market
• TakeCover www.gamajun-games.com
• Educational games for www.dimensionu.com as a sub-contractor at
MuchDifferent
• Small stuff here and there on different things, a bit of OSS included
Chicken and egg
• I want to describe the case for Orleans
• You should know the definitions before the case makes sense
• Definitions aren’t motivating without the case for some
• I have to start from one or the other
• I’ll go fast over the definitions
Concurrency vs parallelism
• concurrency is the decomposability property of a program, algorithm,
or problem into order-independent or partially-ordered components
or units (What!?)
• concurrency comes from the need to execute many pieces of code on
a small number of CPU cores
• Parallel computing is a type of computation in which many
calculations or the execution of processes are carried out
simultaneously
Distribution
• A distributed system is a model in which components located on
networked computers communicate and coordinate their actions by
passing messages
Why concurrent, parallel and distributed code
• It’s more than 10 years that CPU cores won’t get more powerful
• We have multiple cores instead
• One single machine have limited power
• Modern workloads
History
• We should know more about CS and SE history but we don’t
• All programs were sequential
• CPUs were getting more and more powerful and programs were
getting faster
• Some people used multiple processors but only on servers
• Today nobody has a one core processor and the free lunch stopped
• Academia worked on distributed stuff
Who needed it?
• Not many people
• Heavy graphics processing
• AI
• Simulations and military scale stuff
• Telephone switches
• Researchers interested I the field
Ok what those some people did
• How to communicate?
• Memory sharing vs message passing
• Transactional memory, locks and semaphores
• Memory sharing was the way
• Message passing and Erlang
• Stateless web
• Multi-threading, coroutines, the actor model and CSP
The usual way
• Thread
• Shared memory and locks
• Don’t do it unless you have to and quit as soon as you had to debug it

• Transactional memory to the rescue?
• Things changed in last 5-8 years
• Actor model rises again
Actor model
• Mathematical theory of computation
• Introduced in 1973 by Hewitt, Bishop, and Steiger
• A framework and basis for reasoning about concurrency
• Actors as primitives of concurrent computation
The Erlang way
• No shared memory
• Even no mutable state
• Message passing
• The actor model
• Why it is not popular?
• Elixir helps
Communicating sequential processes
• Each process runs sequentially
• Processes communicate over channels only
• Go has this
Scalability
• Horizontal scalability
• Vertical scalability
• Vertical scalability is limited
• Big machines are expensive
• Horizontal scalability requires distributed software
• HS can make your software more available and more fault tolerant
• VS is impossible for many tasks
stateless services for scaling
• stateless services are easy to develop
• They offload the problem to the storage system
• Caches
• Low latency , high throughput usually dictates stateful
Stateful services for scalability
• Much faster responses
• Harder to develop and maintain
• Doesn’t offload all problems to storage
• Doesn’t hit storage as much as stateless services
• Actor model is very good here for many cases
Actor model implementation issues
• Erlang is the first and most robust industrial implementation made in
Ericson
• Akka and Akka.net are similar to it conceptually
• You need to manage resources and do load balancing
• You need to handle many failure cases
• Erlang as the most robust one has a very special syntax, is dynamically
typed and its ecosystem is not as big as what you would expect
Scalable game-servers-tgc
Problem: concurrency is
hard*
Distribution, high
throughput and low-latency
make it even harder
Microsoft Orleans
• Distributed actor model runtime
• Virtual actor model
• Location transparency
• Based on .NET objects and interfaces
• Asynchronous using async await
• Error propagation
• Silo runtime execution container
• Implicit activation and life-cycle management
• Coordinated placement, multiplexed communication and failure recovery
What was it again
• Distributed C# with remote objects
• Magically managed by Orleans runtime
• Magic doesn’t mean hidden stuff
• You are in control if you need
• It looks like C# and it act like C#
• It scales
• It’s fault tolerant
• Guides you within the right path
Grains , virtual actor
1. Grain instances always exist, virtually
• Needn’t be created, looked up or deleted
• Code can always call methods the grain
• Grains never fail
2. Activations are created on-demand
• If there is no existing activation, a message sent to it triggers instantiation
• Lifecycle is managed by the runtime
• Transparent recovery from server failures
• Runtime can create multiple activations of stateless grains (for performance)
3. Location transparency
• Grains can pass references to one another around
• References can be persisted to cold-storage
Execution model
• Activations are single-threaded
• Optionally re-entrant
• Runtime schedules execution of methods
• Multiplexed across threads
• No shared state
• Avoid races
• No need for locks
• Cooperative multitasking
Developer experience
Grain interface
public interface IHello : IGrainWithGuidKey
{
Task<string> SayHello(string greeting);
}
Grain implementation
Public class HelloGrain : GrainBase, IHello
{
async Task<string> SayHello(string greeting)
{
var resp = "You said: '" + greeting + "', I
say: Hello!";
return resp;
}
}
Orleans is built for
• Large scale distributed real-time systems
• High throughput , low latency
• Large number of independent entities
• Stateful computing
• Not too much communication between many entities for computing
results
Apadana game backend case study
• A scalable distributed backend for games
• No physics and game world logic for now
• Players, authentication, cloud save
• Leaderboards
• Match making
• Realtime messaging in games
• Guilds and friend lists
Scalable game-servers-tgc
Architecture
• Many silos in the back
• Storage using ArangoDB and couchbase (customizable)
• Cloud ready
• Front-ends using WebAPI and websockets, custom UDP protocol soon
Inside silo
• Developer
• Game (Title) used as tenant
• Player
• RealtimeGame
• Leaderboard
• MatchMaker
Architecture
• Stateful grains
• Write to storage for fault tolerance
• Batch communications
• Distributed processing of user messages
• Index grains for managing resources
LeaderBoard
• Stateful grain per leaderboard
• Sorting data in memory
• Defined resource
• Very low latency and without much database hits
• Hot leaderboards in memory
MatchMaker
• One grain per MatchMaking game mode
• Clients send requests
• MM processes in a timer and sends responses
• Games are created here
Real-time game
• One grain per match
• References all players
• Relays messages between them
• Doesn’t care about message format unless your scripts want to
Scripting
• Uses C# and Roslyn
• Code analysis for security
• Times-out scripts which take a long time
• Scripts are asynchronous as well
• Compiled and executed locally on each machine
A note on Micro services
• Not the silver-bullet
• Each grain is a micro service
• Latency
• Do you really need multiple apps in multiple languages?
• Local per service storage
What about Node.js
• All cool kids are using it
• Single threaded
• No concurrency and distribution abstractions
• CSP and hard to reason about
• Not good for CPU bound and stateful stuff
• Horrible idea for real-time games
• Add web-hooks and you are doomed
• Brain melt-down coming soon
Advanced Orleans features
• Timers
• Reminders
• Streams
• Observers
• Placement strategy
• Versioning
• Transactions
• More MSR stuff always coming
What else
• Super awesome community
• More super awesome community
• Fascinating core team
• A great project lead
• Being used in MSN win10 apps , Skype, internal Azure services, Halo 4
and 5, age of empire castle siege and many other MS and community
projects
Acknowledgements
• Sergey Bykov
• Julian Dominguez
• Reuben Bond
• Gutemberg Ribeiro
• Other members of Orleans community
• Amir Reza Moghassemi (My fellow at Apadana)
age of empire castle siege
Resources
• http://github.com/dotnet/orleans
• http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
• https://www.microsoft.com/en-us/research/project/orleans-virtual-
actors/#
• https://channel9.msdn.com/Events/Build/2014/3-641
• https://channel9.msdn.com/Events/Build/2014/3-641
Thanks
Ashkan.Saeedi.1989@gmail.com
www.apadana-platform.ir (Persian)
Ad

More Related Content

What's hot (16)

Massively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project OrleansMassively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project Orleans
Newman Hunter
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft Orleans
Uri Goldstein
 
Staying friendly with the gc
Staying friendly with the gcStaying friendly with the gc
Staying friendly with the gc
Oren Eini
 
Akka Actors
Akka ActorsAkka Actors
Akka Actors
Dylan Forciea
 
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
Training on iOS app development - Samesh Swongamikha & Neetin SharmaTraining on iOS app development - Samesh Swongamikha & Neetin Sharma
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
MobileNepal
 
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National PoliceDevoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Bert Jan Schrijver
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better Concurrency
Dror Bereznitsky
 
Rebooting design in RavenDB
Rebooting design in RavenDBRebooting design in RavenDB
Rebooting design in RavenDB
Oren Eini
 
AtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
AtlasCamp 2014: Preparing Your Plugin for JIRA Data CenterAtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
AtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
Atlassian
 
Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)
GlobalLogic Ukraine
 
Scaling
ScalingScaling
Scaling
Òscar Vilaplana
 
Data consistency: Analyse, understand and decide
Data consistency: Analyse, understand and decideData consistency: Analyse, understand and decide
Data consistency: Analyse, understand and decide
Louis Jacomet
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
David Hoerster
 
Tiger oracle
Tiger oracleTiger oracle
Tiger oracle
d0nn9n
 
Hi
HiHi
Hi
marks2020
 
Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model framework
Neil Mackenzie
 
Massively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project OrleansMassively Scaleable .NET Web Services with Project Orleans
Massively Scaleable .NET Web Services with Project Orleans
Newman Hunter
 
A Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft OrleansA Brief Intro to Microsoft Orleans
A Brief Intro to Microsoft Orleans
Uri Goldstein
 
Staying friendly with the gc
Staying friendly with the gcStaying friendly with the gc
Staying friendly with the gc
Oren Eini
 
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
Training on iOS app development - Samesh Swongamikha & Neetin SharmaTraining on iOS app development - Samesh Swongamikha & Neetin Sharma
Training on iOS app development - Samesh Swongamikha & Neetin Sharma
MobileNepal
 
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National PoliceDevoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Bert Jan Schrijver
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better Concurrency
Dror Bereznitsky
 
Rebooting design in RavenDB
Rebooting design in RavenDBRebooting design in RavenDB
Rebooting design in RavenDB
Oren Eini
 
AtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
AtlasCamp 2014: Preparing Your Plugin for JIRA Data CenterAtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
AtlasCamp 2014: Preparing Your Plugin for JIRA Data Center
Atlassian
 
Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)Take a Look at Akka+Java (English version)
Take a Look at Akka+Java (English version)
GlobalLogic Ukraine
 
Data consistency: Analyse, understand and decide
Data consistency: Analyse, understand and decideData consistency: Analyse, understand and decide
Data consistency: Analyse, understand and decide
Louis Jacomet
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
David Hoerster
 
Tiger oracle
Tiger oracleTiger oracle
Tiger oracle
d0nn9n
 
Project Orleans - Actor Model framework
Project Orleans - Actor Model frameworkProject Orleans - Actor Model framework
Project Orleans - Actor Model framework
Neil Mackenzie
 

Similar to Scalable game-servers-tgc (20)

The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling Software
Abdelmonaim Remani
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remani
jaxconf
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
Jared Smith
 
Fi fo euc 2014
Fi fo euc 2014Fi fo euc 2014
Fi fo euc 2014
Licenser
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
Viktor Sovietov
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
mperham
 
What ya gonna do?
What ya gonna do?What ya gonna do?
What ya gonna do?
CQD
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Bob Pusateri
 
Writing Scalable Software in Java
Writing Scalable Software in JavaWriting Scalable Software in Java
Writing Scalable Software in Java
Ruben Badaró
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015
Ricard Clau
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
Elizabeth Smith
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
Jeremy Likness
 
Orleans gdc2019
Orleans gdc2019Orleans gdc2019
Orleans gdc2019
Crystin Cox
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
David Hoerster
 
The Economies of Scaling Software
The Economies of Scaling SoftwareThe Economies of Scaling Software
The Economies of Scaling Software
Abdelmonaim Remani
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Panagiotis Kanavos
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remani
jaxconf
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
Jared Smith
 
Fi fo euc 2014
Fi fo euc 2014Fi fo euc 2014
Fi fo euc 2014
Licenser
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
Viktor Sovietov
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
mperham
 
What ya gonna do?
What ya gonna do?What ya gonna do?
What ya gonna do?
CQD
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Bob Pusateri
 
Writing Scalable Software in Java
Writing Scalable Software in JavaWriting Scalable Software in Java
Writing Scalable Software in Java
Ruben Badaró
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015
Ricard Clau
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
Elizabeth Smith
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
Jeremy Likness
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
David Hoerster
 
Ad

Recently uploaded (20)

Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Ad

Scalable game-servers-tgc

  • 2. Who am i? • Coded games for more than 8 years professionally • Worked on networking middleware at MuchDifferent and wrote a Unity emulator for servers there • Worked on multiple multiplayer games for mobile, webGL and on a kids MMO for south Korean market • TakeCover www.gamajun-games.com • Educational games for www.dimensionu.com as a sub-contractor at MuchDifferent • Small stuff here and there on different things, a bit of OSS included
  • 3. Chicken and egg • I want to describe the case for Orleans • You should know the definitions before the case makes sense • Definitions aren’t motivating without the case for some • I have to start from one or the other • I’ll go fast over the definitions
  • 4. Concurrency vs parallelism • concurrency is the decomposability property of a program, algorithm, or problem into order-independent or partially-ordered components or units (What!?) • concurrency comes from the need to execute many pieces of code on a small number of CPU cores • Parallel computing is a type of computation in which many calculations or the execution of processes are carried out simultaneously
  • 5. Distribution • A distributed system is a model in which components located on networked computers communicate and coordinate their actions by passing messages
  • 6. Why concurrent, parallel and distributed code • It’s more than 10 years that CPU cores won’t get more powerful • We have multiple cores instead • One single machine have limited power • Modern workloads
  • 7. History • We should know more about CS and SE history but we don’t • All programs were sequential • CPUs were getting more and more powerful and programs were getting faster • Some people used multiple processors but only on servers • Today nobody has a one core processor and the free lunch stopped • Academia worked on distributed stuff
  • 8. Who needed it? • Not many people • Heavy graphics processing • AI • Simulations and military scale stuff • Telephone switches • Researchers interested I the field
  • 9. Ok what those some people did • How to communicate? • Memory sharing vs message passing • Transactional memory, locks and semaphores • Memory sharing was the way • Message passing and Erlang • Stateless web • Multi-threading, coroutines, the actor model and CSP
  • 10. The usual way • Thread • Shared memory and locks • Don’t do it unless you have to and quit as soon as you had to debug it  • Transactional memory to the rescue? • Things changed in last 5-8 years • Actor model rises again
  • 11. Actor model • Mathematical theory of computation • Introduced in 1973 by Hewitt, Bishop, and Steiger • A framework and basis for reasoning about concurrency • Actors as primitives of concurrent computation
  • 12. The Erlang way • No shared memory • Even no mutable state • Message passing • The actor model • Why it is not popular? • Elixir helps
  • 13. Communicating sequential processes • Each process runs sequentially • Processes communicate over channels only • Go has this
  • 14. Scalability • Horizontal scalability • Vertical scalability • Vertical scalability is limited • Big machines are expensive • Horizontal scalability requires distributed software • HS can make your software more available and more fault tolerant • VS is impossible for many tasks
  • 15. stateless services for scaling • stateless services are easy to develop • They offload the problem to the storage system • Caches • Low latency , high throughput usually dictates stateful
  • 16. Stateful services for scalability • Much faster responses • Harder to develop and maintain • Doesn’t offload all problems to storage • Doesn’t hit storage as much as stateless services • Actor model is very good here for many cases
  • 17. Actor model implementation issues • Erlang is the first and most robust industrial implementation made in Ericson • Akka and Akka.net are similar to it conceptually • You need to manage resources and do load balancing • You need to handle many failure cases • Erlang as the most robust one has a very special syntax, is dynamically typed and its ecosystem is not as big as what you would expect
  • 19. Problem: concurrency is hard* Distribution, high throughput and low-latency make it even harder
  • 20. Microsoft Orleans • Distributed actor model runtime • Virtual actor model • Location transparency • Based on .NET objects and interfaces • Asynchronous using async await • Error propagation • Silo runtime execution container • Implicit activation and life-cycle management • Coordinated placement, multiplexed communication and failure recovery
  • 21. What was it again • Distributed C# with remote objects • Magically managed by Orleans runtime • Magic doesn’t mean hidden stuff • You are in control if you need • It looks like C# and it act like C# • It scales • It’s fault tolerant • Guides you within the right path
  • 22. Grains , virtual actor 1. Grain instances always exist, virtually • Needn’t be created, looked up or deleted • Code can always call methods the grain • Grains never fail 2. Activations are created on-demand • If there is no existing activation, a message sent to it triggers instantiation • Lifecycle is managed by the runtime • Transparent recovery from server failures • Runtime can create multiple activations of stateless grains (for performance) 3. Location transparency • Grains can pass references to one another around • References can be persisted to cold-storage
  • 23. Execution model • Activations are single-threaded • Optionally re-entrant • Runtime schedules execution of methods • Multiplexed across threads • No shared state • Avoid races • No need for locks • Cooperative multitasking
  • 25. Grain interface public interface IHello : IGrainWithGuidKey { Task<string> SayHello(string greeting); }
  • 26. Grain implementation Public class HelloGrain : GrainBase, IHello { async Task<string> SayHello(string greeting) { var resp = "You said: '" + greeting + "', I say: Hello!"; return resp; } }
  • 27. Orleans is built for • Large scale distributed real-time systems • High throughput , low latency • Large number of independent entities • Stateful computing • Not too much communication between many entities for computing results
  • 28. Apadana game backend case study • A scalable distributed backend for games • No physics and game world logic for now • Players, authentication, cloud save • Leaderboards • Match making • Realtime messaging in games • Guilds and friend lists
  • 30. Architecture • Many silos in the back • Storage using ArangoDB and couchbase (customizable) • Cloud ready • Front-ends using WebAPI and websockets, custom UDP protocol soon
  • 31. Inside silo • Developer • Game (Title) used as tenant • Player • RealtimeGame • Leaderboard • MatchMaker
  • 32. Architecture • Stateful grains • Write to storage for fault tolerance • Batch communications • Distributed processing of user messages • Index grains for managing resources
  • 33. LeaderBoard • Stateful grain per leaderboard • Sorting data in memory • Defined resource • Very low latency and without much database hits • Hot leaderboards in memory
  • 34. MatchMaker • One grain per MatchMaking game mode • Clients send requests • MM processes in a timer and sends responses • Games are created here
  • 35. Real-time game • One grain per match • References all players • Relays messages between them • Doesn’t care about message format unless your scripts want to
  • 36. Scripting • Uses C# and Roslyn • Code analysis for security • Times-out scripts which take a long time • Scripts are asynchronous as well • Compiled and executed locally on each machine
  • 37. A note on Micro services • Not the silver-bullet • Each grain is a micro service • Latency • Do you really need multiple apps in multiple languages? • Local per service storage
  • 38. What about Node.js • All cool kids are using it • Single threaded • No concurrency and distribution abstractions • CSP and hard to reason about • Not good for CPU bound and stateful stuff • Horrible idea for real-time games • Add web-hooks and you are doomed • Brain melt-down coming soon
  • 39. Advanced Orleans features • Timers • Reminders • Streams • Observers • Placement strategy • Versioning • Transactions • More MSR stuff always coming
  • 40. What else • Super awesome community • More super awesome community • Fascinating core team • A great project lead • Being used in MSN win10 apps , Skype, internal Azure services, Halo 4 and 5, age of empire castle siege and many other MS and community projects
  • 41. Acknowledgements • Sergey Bykov • Julian Dominguez • Reuben Bond • Gutemberg Ribeiro • Other members of Orleans community • Amir Reza Moghassemi (My fellow at Apadana) age of empire castle siege
  • 42. Resources • http://github.com/dotnet/orleans • http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/ • https://www.microsoft.com/en-us/research/project/orleans-virtual- actors/# • https://channel9.msdn.com/Events/Build/2014/3-641 • https://channel9.msdn.com/Events/Build/2014/3-641