SlideShare una empresa de Scribd logo
1 de 102
Descargar para leer sin conexión
Akka for real-time Multiplayer
mobile games
Yan Cui
http://theburningmonk.com
@theburningmonk
Principal Engineer @
Real-Time games in Top 100 Grossing (2017)
2014
2015
2016
2017
(3)
(6)
(8)
(13)
2018 ???
Enabling Factors
Source: PC Mag
Enabling Factors
Source: OpenSignal
Enabling Factors
> $400M Monthly Revenue

Source: Bloomberg
> 80M DAU

Source: Tencent
10-20 inputs/s, sensitive to lags (> 300ms)
unpredictable network, limited bandwidth
Decisions, decisions...
Build vs Buy?
Global deployment vs Centralized?
TCP vs UDP?
Server Authoritative vs Lock-Step?
Constraints/Trade-offs
Latency (RTT)
Cost
Complexity
Scalability
Operational overhead
Global Deployment
vs
Centralised
10-20 inputs/s, sensitive to lags (> 300ms)
optimize for this
Global Deployment
! Players are geo-routed to closest multiplayer server.
! Matched with other players in the same geo-region for best UX.
! No need for players to “choose server”, it should just work.
Global Deployment
! Should leaderboards be global or regional?
! Should guilds/alliances be global or regional?
! Should chatrooms be global or regional?
! Should liveops events be global or regional?
! Should players be allowed to play with others in another region? ie.
play with distant relatives/friends.
! Should players be allowed to switch default region?
eg. moved to Europe after Brexit
Server Authoritative
vs
Lock-Step
Server Authoritative
! Server decides game logic.
! Client sends all inputs to server.
! Client receives game state (either full, or delta) from server.
Server Authoritative
! Server decides game logic.
! Client sends all inputs to server.
! Client receives game state (either full, or delta) from server.
! Client keeps internal state for game world, which mirrors server state.
! Client doesn’t modify world state directly, only display with some prediction to
mask network latency.
Client 1 Client 2Server
C1 control 1 C2 control 1
game state 1
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
game state 1
game state 2
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
game state 1
game state 2
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
game state 1
game state 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 3
C1 control 1
C2 control 1
C2 control 2
C2 control 3
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
game state 1
game state 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 4
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
game state 1
game state 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 4
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
game state 1
game state 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 5
C2 control 3
game state 4
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
game state 1
game state 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 3
C1 control 1
C2 control 1
C2 control 2
game state 5
C2 control 3
game state 4
Pros
! Always in-sync.
! Hard to cheat - no memory hacks, etc.
! Easy (and quick) to join mid-match.
! Server can detect lagged/DC’d client and take over with AI.
Cons
! High server load.
! High bandwidth usage.
! Synchronization on the client is complicated.
! Little experience in the company with server-side .Net stack.
(bus factor of 1)
! .NetCore was/is still a moving target.
high server load and
bandwidth needs
client has to receive
more data
Lock-Step*
! Client sends all inputs to server.
! Server collects all inputs, and buffers them.
! Server sends all buffered inputs to all clients X times a second.
* traditional RTS games tend to use peer-to-peer model
Lock-Step*
! Client sends all inputs to server.
! Server collects all inputs, and buffers them.
! Server sends all buffered inputs to all clients X times a second.
! Client executes all inputs in the same order.
! Because everyone is 'guaranteed' to have executed the same input at the
same frame in the same order, we get synchronicity.
! Use prediction to mask network latency.
* traditional RTS games tend to use peer-to-peer model
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
C1 control 1
C2 control 1
C2 control 2
C1 control 1
C2 control 1
C2 control 2
C2 control 3
inputs, instead
of game state
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
C1 control 1
C2 control 1
C2 control 2
C1 control 1
C2 control 1
C2 control 2
C2 control 3
RTT: time between sending an input to
receiving it back from server
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
C1 control 1
C2 control 1
C2 control 2
C1 control 1
C2 control 1
C2 control 2
C2 control 3
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
C1 control 1
C2 control 1
C2 control 2
C1 control 1
C2 control 1
C2 control 2
C2 control 3
RTT
frame time
latency
Client 1 Client 2Server
C1 control 1 C2 control 1
C2 control 2
C2 control 3
C1 control 1
C2 control 1
C2 control 2
C1 control 1
C2 control 1
C2 control 2
C2 control 3
RTT
frame time
RTT = latency x 2 + X
Xmin = 0, Xmax = frame time
latency
Pros
! Light server load.
! Lower bandwidth usage.
! Simpler server implementation.
Cons
! Needs deterministic game engine.
! Unity has long-standing determinism problem with floating point.
! Hackable, requires some form of server-side validation.
! All clients must take over lagged/DC’d client with AI.
! Slower to join mid-match, need to process all inputs.
! Need to ensure all clients in a match are compatible.
fix-point math, server
validation, ...
bandwidth
Build vs Buy
ApeSync
+
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3
buffering
connection open
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3
buffering
connection open
authenticate
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
buffering
connection open
authenticate
send/receive
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
buffering
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
C3 input
connection open
authenticate
send/receive
buffering
MATCH 1
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
C3 input
connection open
authenticate
send/receive
buffering
broadcast!
MATCH 1
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
C3 input
connection open
authenticate
send/receive
buffering
broadcast!
MATCH 1
current frame history
frame 1
frame 2
frame 3
frame 4
connection open
authenticate
send/receive
buffering
broadcast!
MATCH 1
current frame history
frame 1
frame 2
frame 3
frame 4
connection open
authenticate
send/receive
buffering
broadcast!
C3 input
concurrency
MATCH 1
current frame history
frame 1
frame 2
frame 3
...
C1 input
C2 input
C3 joined
C3 input
connection open
authenticate
send/receive
C1 input
buffering
broadcast!
MATCH 1
current frame history
frame 1
frame 2
frame 3
...
C1 input
C2 input
C3 joined
C3 input
C1 input
C2 input
buffering
broadcast!
MATCH MATCH MATCH MATCH MATCH
MATCH MATCH MATCH MATCH MATCH
MATCH MATCH MATCH MATCH MATCH
MATCH MATCH MATCH MATCH MATCH
MATCH MATCH MATCH MATCH MATCH
MATCH MATCH MATCH MATCH MATCH
MATCH
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
connection open
authenticate
send/receive
MATCH
C1 input
C2 input
current frame history
frame 1
frame 2
frame 3C3 joined
connection open
authenticate
send/receive
MATCH
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
Socket
actor
Match
actor
MATCH
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
Root Aggregate
Socket
actor
Match
actor
MATCH
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
Root Aggregate
Socket
actor
Match
actor
MATCH
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
MATCH
current frame history
frame 1
frame 2
frame 3
C1 input
C2 input
C3 joined
C3 joined
act locally
think globally
how actors interact with each other
aka, the “protocol”
the secret to building high
performance systems is simplicity
complexity kills performance
Higher CCU per server
Fewer servers
Lower cost
Less operational overhead
Performance Matters
We should forget about small
efficiencies, say about 97% of the
time: premature optimization is the
root of all evil. Yet we should not
pass up our opportunities in that
critical 3%.
Performance Matters
We should forget about small
efficiencies, say about 97% of the
time: premature optimization is the
root of all evil. Yet we should not
pass up our opportunities in that
critical 3%.
Performance Matters
Threads are heavy OS constructs.
Each thread is allocated 1MB stack space by default.
Context Switching is expensive at scale.
Actors are cheap.
Actor system can optimise use of threads to minimise context switching.
Actor Model
>
Non-blocking I/O framework for JVM.
Very performant.
Simplifies implementation of socket servers (TCP/ UDP).
UDP support is “meh”...
Netty
Custom network protocol (bandwidth).
Minimise Netty object creations (GC pressure).
Minimise the no. of message hops inside Akka (latency).
Performance Tuning
Buffer pooling (GC pressure).
Using direct buffers (GC pressure).
Performance Tuning
Disable Nagle's algorithm (latency).
TCP tuning (including BBR, etc. with differing results).
Epoll.
ENA-enabled EC2 instances.
Performance Tuning
Custom Reliable UDP protocol, optimized for countries with poor networking
conditions.
Performance Tuning
AWS Lambda functions to run bot clients (written with Akka):
! Cheaper
! Faster to boot up
! Easy to update
Each Lambda invocation could simulate up to 100 bots.
Automated Load Testing
http://bit.ly/2xgGHXZ
from US-EAST (Lambda)
to EU-WEST (game server)
optimize for tail latencies
from US-EAST (Lambda)
to EU-WEST (game server)
Monitoring
Monitoring
Performance in the Wild(in poor networking condition)
95 percentile
max playable RTT
outperforms Photon
on performance
Performance in the Wild(in poor networking condition)
fewer disconnects
Performance in the Wild
! Improved KPIs - D1 retention, session time, etc.
! 14% cheaper vs. Photon, based on current cost projection
Akka for realtime multiplayer mobile games

Más contenido relacionado

La actualidad más candente

Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Lucas Jellema
 

La actualidad más candente (20)

Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
Squirreling Away $640 Billion: How Stripe Leverages Flink for Change Data Cap...
 
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
From Message to Cluster: A Realworld Introduction to Kafka Capacity Planning
From Message to Cluster: A Realworld Introduction to Kafka Capacity PlanningFrom Message to Cluster: A Realworld Introduction to Kafka Capacity Planning
From Message to Cluster: A Realworld Introduction to Kafka Capacity Planning
 
Handle Large Messages In Apache Kafka
Handle Large Messages In Apache KafkaHandle Large Messages In Apache Kafka
Handle Large Messages In Apache Kafka
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Dual write strategies for microservices
Dual write strategies for microservicesDual write strategies for microservices
Dual write strategies for microservices
 
Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRS
 
Apache Helix presentation at SOCC 2012
Apache Helix presentation at SOCC 2012Apache Helix presentation at SOCC 2012
Apache Helix presentation at SOCC 2012
 
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
Getting up to speed with MirrorMaker 2 | Mickael Maison, IBM and Ryanne Dolan...
 
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
Enabling product personalisation using Apache Kafka, Apache Pinot and Trino w...
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Kafka High Availability in multi data center setup with floating Observers wi...
Kafka High Availability in multi data center setup with floating Observers wi...Kafka High Availability in multi data center setup with floating Observers wi...
Kafka High Availability in multi data center setup with floating Observers wi...
 
Under the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database ArchitectureUnder the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database Architecture
 
Rainbird: Realtime Analytics at Twitter (Strata 2011)
Rainbird: Realtime Analytics at Twitter (Strata 2011)Rainbird: Realtime Analytics at Twitter (Strata 2011)
Rainbird: Realtime Analytics at Twitter (Strata 2011)
 
Microservices with Kafka Ecosystem
Microservices with Kafka EcosystemMicroservices with Kafka Ecosystem
Microservices with Kafka Ecosystem
 
Performance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State StoresPerformance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State Stores
 
Kafka error handling patterns and best practices | Hemant Desale and Aruna Ka...
Kafka error handling patterns and best practices | Hemant Desale and Aruna Ka...Kafka error handling patterns and best practices | Hemant Desale and Aruna Ka...
Kafka error handling patterns and best practices | Hemant Desale and Aruna Ka...
 
A Kafka-based platform to process medical prescriptions of Germany’s health i...
A Kafka-based platform to process medical prescriptions of Germany’s health i...A Kafka-based platform to process medical prescriptions of Germany’s health i...
A Kafka-based platform to process medical prescriptions of Germany’s health i...
 
Knative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVMKnative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVM
 

Similar a Akka for realtime multiplayer mobile games

GamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemGamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming System
Academia Sinica
 
Ccna cheat sheet
Ccna cheat sheetCcna cheat sheet
Ccna cheat sheet
aromal4frnz
 
Smart Water Metering By Electronet Equipments Pvt Ltd
Smart Water Metering By Electronet Equipments Pvt LtdSmart Water Metering By Electronet Equipments Pvt Ltd
Smart Water Metering By Electronet Equipments Pvt Ltd
Rajendra Nagaonkar
 

Similar a Akka for realtime multiplayer mobile games (20)

Akka for realtime multiplayer mobile games
Akka for realtime multiplayer mobile gamesAkka for realtime multiplayer mobile games
Akka for realtime multiplayer mobile games
 
Scalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer gamesScalability & Big Data challenges in real time multiplayer games
Scalability & Big Data challenges in real time multiplayer games
 
Game Networking for Online games
Game Networking for Online gamesGame Networking for Online games
Game Networking for Online games
 
Reconsider TCPdump for Modern Troubleshooting
Reconsider TCPdump for Modern TroubleshootingReconsider TCPdump for Modern Troubleshooting
Reconsider TCPdump for Modern Troubleshooting
 
Reliving the history of multiplayer games
Reliving the history of multiplayer gamesReliving the history of multiplayer games
Reliving the history of multiplayer games
 
BRKRST-3068 Troubleshooting Catalyst 2K and 3K.pdf
BRKRST-3068  Troubleshooting Catalyst 2K and 3K.pdfBRKRST-3068  Troubleshooting Catalyst 2K and 3K.pdf
BRKRST-3068 Troubleshooting Catalyst 2K and 3K.pdf
 
Tech solutions and tricks in real time mobile multiplayer
Tech solutions and tricks in real time mobile multiplayerTech solutions and tricks in real time mobile multiplayer
Tech solutions and tricks in real time mobile multiplayer
 
A 5 security x line platform
A 5 security x line platformA 5 security x line platform
A 5 security x line platform
 
Cisco CCENT Cram Notes
Cisco CCENT Cram NotesCisco CCENT Cram Notes
Cisco CCENT Cram Notes
 
managing your network environment
managing your network environmentmanaging your network environment
managing your network environment
 
GamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming SystemGamingAnywhere: An Open Cloud Gaming System
GamingAnywhere: An Open Cloud Gaming System
 
Ccna cheat sheet
Ccna cheat sheetCcna cheat sheet
Ccna cheat sheet
 
NetRacer for the Commodore 64
NetRacer for the Commodore 64NetRacer for the Commodore 64
NetRacer for the Commodore 64
 
Eliminating SAN Congestion Just Got Much Easier- webinar - Nov 2015
Eliminating SAN Congestion Just Got Much Easier-  webinar - Nov 2015 Eliminating SAN Congestion Just Got Much Easier-  webinar - Nov 2015
Eliminating SAN Congestion Just Got Much Easier- webinar - Nov 2015
 
Configure Cisco Routers for Syslog, NTP, and SSH Operations
Configure Cisco Routers for Syslog, NTP, and SSH Operations Configure Cisco Routers for Syslog, NTP, and SSH Operations
Configure Cisco Routers for Syslog, NTP, and SSH Operations
 
Smart Water Metering By Electronet Equipments Pvt Ltd
Smart Water Metering By Electronet Equipments Pvt LtdSmart Water Metering By Electronet Equipments Pvt Ltd
Smart Water Metering By Electronet Equipments Pvt Ltd
 
Multicast tutorial v3
Multicast tutorial v3Multicast tutorial v3
Multicast tutorial v3
 
Building fast,scalable game server in node.js
Building fast,scalable game server in node.jsBuilding fast,scalable game server in node.js
Building fast,scalable game server in node.js
 
Sync2IP 2 Port and 4 Port Sync to LAN Adapter
Sync2IP 2 Port and 4 Port Sync to LAN AdapterSync2IP 2 Port and 4 Port Sync to LAN Adapter
Sync2IP 2 Port and 4 Port Sync to LAN Adapter
 
Lets Play Together
Lets Play TogetherLets Play Together
Lets Play Together
 

Más de Yan Cui

How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
Yan Cui
 

Más de Yan Cui (20)

How to win the game of trade-offs
How to win the game of trade-offsHow to win the game of trade-offs
How to win the game of trade-offs
 
How to choose the right messaging service
How to choose the right messaging serviceHow to choose the right messaging service
How to choose the right messaging service
 
How to choose the right messaging service for your workload
How to choose the right messaging service for your workloadHow to choose the right messaging service for your workload
How to choose the right messaging service for your workload
 
Patterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfPatterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdf
 
Lambda and DynamoDB best practices
Lambda and DynamoDB best practicesLambda and DynamoDB best practices
Lambda and DynamoDB best practices
 
Lessons from running AppSync in prod
Lessons from running AppSync in prodLessons from running AppSync in prod
Lessons from running AppSync in prod
 
Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functions
 
How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
 
Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSync
 
Build social network in 4 weeks
Build social network in 4 weeksBuild social network in 4 weeks
Build social network in 4 weeks
 
Patterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsPatterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applications
 
How to bring chaos engineering to serverless
How to bring chaos engineering to serverlessHow to bring chaos engineering to serverless
How to bring chaos engineering to serverless
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Building a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLBuilding a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQL
 
FinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyFinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economy
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold starts
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020
 
A chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayA chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage away
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response times
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Akka for realtime multiplayer mobile games

  • 1. Akka for real-time Multiplayer mobile games
  • 3.
  • 4.
  • 5. Real-Time games in Top 100 Grossing (2017) 2014 2015 2016 2017 (3) (6) (8) (13) 2018 ???
  • 9. > $400M Monthly Revenue
 Source: Bloomberg > 80M DAU
 Source: Tencent
  • 10.
  • 11. 10-20 inputs/s, sensitive to lags (> 300ms)
  • 13.
  • 14. Decisions, decisions... Build vs Buy? Global deployment vs Centralized? TCP vs UDP? Server Authoritative vs Lock-Step?
  • 17.
  • 18.
  • 19. 10-20 inputs/s, sensitive to lags (> 300ms)
  • 20.
  • 21.
  • 23. Global Deployment ! Players are geo-routed to closest multiplayer server. ! Matched with other players in the same geo-region for best UX. ! No need for players to “choose server”, it should just work.
  • 24. Global Deployment ! Should leaderboards be global or regional? ! Should guilds/alliances be global or regional? ! Should chatrooms be global or regional? ! Should liveops events be global or regional? ! Should players be allowed to play with others in another region? ie. play with distant relatives/friends. ! Should players be allowed to switch default region? eg. moved to Europe after Brexit
  • 26. Server Authoritative ! Server decides game logic. ! Client sends all inputs to server. ! Client receives game state (either full, or delta) from server.
  • 27. Server Authoritative ! Server decides game logic. ! Client sends all inputs to server. ! Client receives game state (either full, or delta) from server. ! Client keeps internal state for game world, which mirrors server state. ! Client doesn’t modify world state directly, only display with some prediction to mask network latency.
  • 28. Client 1 Client 2Server C1 control 1 C2 control 1 game state 1
  • 29. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 game state 1 game state 2
  • 30. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 game state 1 game state 2
  • 31. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 game state 1 game state 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 3 C1 control 1 C2 control 1 C2 control 2 C2 control 3
  • 32. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 game state 1 game state 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 4
  • 33. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 game state 1 game state 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 4
  • 34. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 game state 1 game state 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 5 C2 control 3 game state 4
  • 35. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 game state 1 game state 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 3 C1 control 1 C2 control 1 C2 control 2 game state 5 C2 control 3 game state 4
  • 36.
  • 37. Pros ! Always in-sync. ! Hard to cheat - no memory hacks, etc. ! Easy (and quick) to join mid-match. ! Server can detect lagged/DC’d client and take over with AI.
  • 38. Cons ! High server load. ! High bandwidth usage. ! Synchronization on the client is complicated. ! Little experience in the company with server-side .Net stack. (bus factor of 1) ! .NetCore was/is still a moving target.
  • 39. high server load and bandwidth needs client has to receive more data
  • 40. Lock-Step* ! Client sends all inputs to server. ! Server collects all inputs, and buffers them. ! Server sends all buffered inputs to all clients X times a second. * traditional RTS games tend to use peer-to-peer model
  • 41. Lock-Step* ! Client sends all inputs to server. ! Server collects all inputs, and buffers them. ! Server sends all buffered inputs to all clients X times a second. ! Client executes all inputs in the same order. ! Because everyone is 'guaranteed' to have executed the same input at the same frame in the same order, we get synchronicity. ! Use prediction to mask network latency. * traditional RTS games tend to use peer-to-peer model
  • 42. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 C1 control 1 C2 control 1 C2 control 2 C1 control 1 C2 control 1 C2 control 2 C2 control 3 inputs, instead of game state
  • 43. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 C1 control 1 C2 control 1 C2 control 2 C1 control 1 C2 control 1 C2 control 2 C2 control 3 RTT: time between sending an input to receiving it back from server
  • 44. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 C1 control 1 C2 control 1 C2 control 2 C1 control 1 C2 control 1 C2 control 2 C2 control 3
  • 45. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 C1 control 1 C2 control 1 C2 control 2 C1 control 1 C2 control 1 C2 control 2 C2 control 3 RTT frame time latency
  • 46. Client 1 Client 2Server C1 control 1 C2 control 1 C2 control 2 C2 control 3 C1 control 1 C2 control 1 C2 control 2 C1 control 1 C2 control 1 C2 control 2 C2 control 3 RTT frame time RTT = latency x 2 + X Xmin = 0, Xmax = frame time latency
  • 47.
  • 48. Pros ! Light server load. ! Lower bandwidth usage. ! Simpler server implementation.
  • 49. Cons ! Needs deterministic game engine. ! Unity has long-standing determinism problem with floating point. ! Hackable, requires some form of server-side validation. ! All clients must take over lagged/DC’d client with AI. ! Slower to join mid-match, need to process all inputs. ! Need to ensure all clients in a match are compatible.
  • 51.
  • 52.
  • 55.
  • 57. +
  • 58. MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3 buffering
  • 59. connection open MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3 buffering
  • 60. connection open authenticate MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined buffering
  • 61. connection open authenticate send/receive MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined buffering
  • 62. MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined C3 input connection open authenticate send/receive buffering
  • 63. MATCH 1 C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined C3 input connection open authenticate send/receive buffering broadcast!
  • 64. MATCH 1 current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined C3 input connection open authenticate send/receive buffering broadcast!
  • 65. MATCH 1 current frame history frame 1 frame 2 frame 3 frame 4 connection open authenticate send/receive buffering broadcast!
  • 66. MATCH 1 current frame history frame 1 frame 2 frame 3 frame 4 connection open authenticate send/receive buffering broadcast! C3 input
  • 67.
  • 69. MATCH 1 current frame history frame 1 frame 2 frame 3 ... C1 input C2 input C3 joined C3 input connection open authenticate send/receive C1 input buffering broadcast!
  • 70. MATCH 1 current frame history frame 1 frame 2 frame 3 ... C1 input C2 input C3 joined C3 input C1 input C2 input buffering broadcast!
  • 71. MATCH MATCH MATCH MATCH MATCH
  • 72. MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH
  • 73. MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH
  • 74. MATCH C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined connection open authenticate send/receive
  • 75. MATCH C1 input C2 input current frame history frame 1 frame 2 frame 3C3 joined connection open authenticate send/receive
  • 76. MATCH current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined Socket actor Match actor
  • 77. MATCH current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined Root Aggregate Socket actor Match actor
  • 78. MATCH current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined Root Aggregate Socket actor Match actor
  • 79. MATCH current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined
  • 80. MATCH current frame history frame 1 frame 2 frame 3 C1 input C2 input C3 joined C3 joined act locally think globally how actors interact with each other aka, the “protocol”
  • 81.
  • 82. the secret to building high performance systems is simplicity complexity kills performance
  • 83. Higher CCU per server Fewer servers Lower cost Less operational overhead Performance Matters
  • 84. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. Performance Matters
  • 85. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. Performance Matters
  • 86. Threads are heavy OS constructs. Each thread is allocated 1MB stack space by default. Context Switching is expensive at scale. Actors are cheap. Actor system can optimise use of threads to minimise context switching. Actor Model >
  • 87. Non-blocking I/O framework for JVM. Very performant. Simplifies implementation of socket servers (TCP/ UDP). UDP support is “meh”... Netty
  • 88. Custom network protocol (bandwidth). Minimise Netty object creations (GC pressure). Minimise the no. of message hops inside Akka (latency). Performance Tuning
  • 89. Buffer pooling (GC pressure). Using direct buffers (GC pressure). Performance Tuning
  • 90. Disable Nagle's algorithm (latency). TCP tuning (including BBR, etc. with differing results). Epoll. ENA-enabled EC2 instances. Performance Tuning
  • 91. Custom Reliable UDP protocol, optimized for countries with poor networking conditions. Performance Tuning
  • 92. AWS Lambda functions to run bot clients (written with Akka): ! Cheaper ! Faster to boot up ! Easy to update Each Lambda invocation could simulate up to 100 bots. Automated Load Testing
  • 94.
  • 95. from US-EAST (Lambda) to EU-WEST (game server)
  • 96. optimize for tail latencies from US-EAST (Lambda) to EU-WEST (game server)
  • 99. Performance in the Wild(in poor networking condition) 95 percentile max playable RTT outperforms Photon on performance
  • 100. Performance in the Wild(in poor networking condition) fewer disconnects
  • 101. Performance in the Wild ! Improved KPIs - D1 retention, session time, etc. ! 14% cheaper vs. Photon, based on current cost projection