f# in social gaming by yan cui at codemotion dubai
TRANSCRIPT
![Page 1: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/1.jpg)
![Page 2: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/2.jpg)
Hi, my name is Yan Cui.
![Page 3: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/3.jpg)
Jan 2010
Nov 2015
Apr 2016
![Page 4: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/4.jpg)
F#in�theReal�World
![Page 5: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/5.jpg)
agenda
![Page 6: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/6.jpg)
Domain ModellingInfrastructureGame LogicAlgorithms
DSLs
![Page 7: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/7.jpg)
1MILLION USERS
ACTIVEDAILY
![Page 8: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/8.jpg)
250MILLION DAY
PERREQUEST
![Page 9: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/9.jpg)
2MONTH
TBP E R
secops25,000
![Page 10: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/10.jpg)
we are polyglot
C#
![Page 11: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/11.jpg)
why F#?
![Page 12: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/12.jpg)
time to market
![Page 13: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/13.jpg)
correctness
![Page 14: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/14.jpg)
efficient
![Page 15: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/15.jpg)
tame complexity
![Page 16: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/16.jpg)
![Page 17: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/17.jpg)
Collectables
Wager Size
Special SymbolAvg Wager Size
Web Server call
![Page 18: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/18.jpg)
• Line Win– X number of matching symbols on adjacent columns– Positions have to be a ‘line’– Wild symbols substitute for other symbols
• Scatter Win– X number of matching symbols anywhere– Triggers bonus game
![Page 19: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/19.jpg)
What symbols should land?Any special symbol wins?
Did the player win anything?
![Page 20: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/20.jpg)
What the player’s new average wager?
![Page 21: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/21.jpg)
Should the player receive collectables?
![Page 22: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/22.jpg)
type Symbol = Standard of string | Wild
![Page 23: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/23.jpg)
type Symbol = Standard of string | Wild
e.g. Standard “hat”Standard “shoe”Standard “bonus”…
![Page 24: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/24.jpg)
type Symbol = Standard of string | Wild
i.e. Wild
![Page 25: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/25.jpg)
type Win = LineWin of int * Symbol * int | ScatterWin of Symbol * int
![Page 26: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/26.jpg)
type Win = LineWin of int * Symbol * int | ScatterWin of Symbol * int
e.g. LineWin (5, Standard “shoe”, 4)
![Page 27: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/27.jpg)
type Win = LineWin of int * Symbol * int | ScatterWin of Symbol * int
e.g. ScatterWin (Standard “bonus”, 3)
![Page 28: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/28.jpg)
type LineNum = inttype Count = int
type Win = LineWin of LineNum * Symbol * Count | ScatterWin of Symbol * Count
![Page 29: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/29.jpg)
closed hierarchy
![Page 30: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/30.jpg)
no Nulls
![Page 31: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/31.jpg)
make invalid states unrepresentable
![Page 32: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/32.jpg)
[<Measure>]type Pence
e.g. 42<Pence>153<Pence>…
![Page 33: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/33.jpg)
10<Meter> / 2<Second> = 5<Meter/Second>10<Meter> * 2<Second> = 20<Meter Second> 10<Meter> + 10<Meter> = 20<Meter>10<Meter> * 10 = 100<Meter>10<Meter> * 10<Meter> = 100<Meter2>10<Meter> + 2<Second> // error10<Meter> + 2 // error
![Page 34: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/34.jpg)
10<Meter> / 2<Second> = 5<Meter/Second>10<Meter> * 2<Second> = 20<Meter Second> 10<Meter> + 10<Meter> = 20<Meter>10<Meter> * 10 = 100<Meter>10<Meter> * 10<Meter> = 100<Meter2>10<Meter> + 2<Second> // error10<Meter> + 2 // error
![Page 35: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/35.jpg)
type Wager = int64<Pence>type Multiplier = int
type Payout = Coins of Wager | MultipliedCoins of Multiplier * Wager | Multi of Payout list | BonusGame
![Page 36: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/36.jpg)
type Wager = int64<Pence>type Multiplier = int
type Payout = Coins of Wager | MultipliedCoins of Multiplier * Wager | Multi of Payout list | BonusGame
![Page 37: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/37.jpg)
type Wager = int64<Pence>type Multiplier = int
type Payout = Coins of Wager | MultipliedCoins of Multiplier * Wager | Multi of Payout list | BonusGame
![Page 38: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/38.jpg)
type State = {
AvgWager : WagerSpecialSymbol : SymbolCollectables : Map<Collectable, Count>
}
![Page 39: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/39.jpg)
immutable by default
![Page 40: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/40.jpg)
![Page 41: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/41.jpg)
Recap
![Page 42: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/42.jpg)
lightweight syntax for types & hierarchies
![Page 43: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/43.jpg)
great for domain modelling
![Page 44: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/44.jpg)
make invalid states unrepresentable
![Page 45: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/45.jpg)
better correctness
![Page 46: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/46.jpg)
order of magnitude increase in productivity
![Page 47: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/47.jpg)
![Page 48: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/48.jpg)
![Page 49: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/49.jpg)
player states are big
![Page 50: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/50.jpg)
Stateless Server DatabaseClient
![Page 51: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/51.jpg)
1:1 read-write ratio
![Page 52: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/52.jpg)
![Page 53: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/53.jpg)
ServerClient
Session 1
Session 2
![Page 54: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/54.jpg)
ServerClient Database
![Page 55: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/55.jpg)
Elastic Load Balancer
S3
Auto scaling Group
Server A Server B
...
EC2
CloudFront
Stateful Server
![Page 56: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/56.jpg)
Stateful Server
Game Logic
Stateless Middle-tier
Infrastructure
logging circuit breaker
perf tracking retry …
![Page 57: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/57.jpg)
Stateful Server
Game Logic
Stateless Middle-tier
Infrastructure
logging circuit breaker
perf tracking retry …
![Page 58: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/58.jpg)
Stateful Server
Game Logic
Stateful Middle-tier
Infrastructure
logging circuit breaker
perf tracking retry …
![Page 59: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/59.jpg)
The Actor Model
An actor is the fundamental unit of computation which embodies the 3 things
• Processing• Storage• Communication
that are essential to computation.
-Carl Hewitt** http://bit.ly/HoNHbG
![Page 60: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/60.jpg)
The Actor Model
• Everything is an actor• An actor has a mailbox• When an actor receives a message it can:– Create new actors– Send messages to actors– Designate how to handle the next message
![Page 61: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/61.jpg)
Stateful Server
• Gatekeeper– Manages the local list of active workers– Spawns new workers
• Worker– Manages the states for a player– Optimistic locking– Persist state after period of inactivity
![Page 62: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/62.jpg)
Stateful Server
Game Server
Player A
Player B
S3Worker C
Worker B
GatekeeperR
eque
st H
andl
ers
Asynchronous
![Page 63: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/63.jpg)
Stateful Server
Game Server
Worker C
Worker B
Gatekeeper
Worker Aok
Req
uest
Han
dler
sPlayer A
Player B
Asynchronous
S3
![Page 64: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/64.jpg)
Stateful Server
Game Server
S3Worker C
Worker B
Gatekeeper
Worker AR
eque
st H
andl
ers
Player A
Player B
Asynchronous
![Page 65: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/65.jpg)
Stateful Server
Game Server
S3Worker C
Gatekeeper
Worker AR
eque
st H
andl
ers
Player A
Player B
Asynchronous
![Page 66: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/66.jpg)
Stateful Server
Game Server
Worker C
Worker A
Gatekeeper
error
Req
uest
Han
dler
sPlayer A
Player B
S3
Asynchronous
![Page 67: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/67.jpg)
type Agent<‘T> = MailboxProcessor<‘T>
![Page 68: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/68.jpg)
type Agent<‘T> = MailboxProcessor<‘T>
type Message = | Get of AsyncReplyChannel<…> | Put of State * Version * AsyncReplyChannel<…>
![Page 69: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/69.jpg)
type Agent<‘T> = MailboxProcessor<‘T>
type Message = | Get of AsyncReplyChannel<…> | Put of State * Version * AsyncReplyChannel<…>
![Page 70: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/70.jpg)
type Result<‘T> = | Success of ’T | Failure of Exception
![Page 71: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/71.jpg)
type Result<‘T> = | Success of ’T | Failure of Exception
type GetResult = Result<State * Version>type PutResult = Result<unit>
![Page 72: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/72.jpg)
type Agent<‘T> = MailboxProcessor<‘T>
type Message = | Get of AsyncReplyChannel<GetResult> | Put of State * Version * AsyncReplyChannel<PutResult>
![Page 73: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/73.jpg)
type Agent<‘T> = MailboxProcessor<‘T>
type Message = | Get of AsyncReplyChannel<GetResult> | Put of State * Version * AsyncReplyChannel<PutResult>
![Page 74: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/74.jpg)
type Worker (playerId) = let agent = Agent<Message>.Start(fun inbox -> let state = getCurrentState playerId
let rec workingState (state, version) = async { … } and closedState () = async { … }
workingState (state, 1))
![Page 75: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/75.jpg)
type Worker (playerId) = let agent = Agent<Message>.Start(fun inbox -> let state = getCurrentState playerId
let rec workingState (state, version) = async { … } and closedState () = async { … }
workingState (state, 1))
![Page 76: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/76.jpg)
type Worker (playerId) = let agent = Agent<Message>.Start(fun inbox -> let state = getCurrentState playerId
let rec workingState (state, version) = async { … } and closedState () = async { … }
workingState (state, 1))
![Page 77: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/77.jpg)
type Worker (playerId) = let agent = Agent<Message>.Start(fun inbox -> let state = getCurrentState playerId
let rec workingState (state, version) = async { … } and closedState () = async { … }
workingState (state, 1))
![Page 78: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/78.jpg)
type Worker (playerId) = let agent = Agent<Message>.Start(fun inbox -> let state = getCurrentState playerId
let rec workingState (state, version) = async { … } and closedState () = async { … }
workingState (state, 1))
![Page 79: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/79.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> do! persist state return! closedState() … }
![Page 80: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/80.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> do! persist state return! closedState() … }
![Page 81: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/81.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> do! persist state return! closedState() … }
![Page 82: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/82.jpg)
non-blocking I/O
![Page 83: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/83.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> do! persist state return! closedState() … }
![Page 84: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/84.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> do! persist state return! closedState() … }
![Page 85: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/85.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Get(reply)) -> reply.Reply <| Success(state, version) return! workingState(state, version) … }
![Page 86: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/86.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Get(reply)) -> reply.Reply <| Success(state, version) return! workingState(state, version) … }
type Message =
| Get of AsyncReplyChannel<GetResult>
| Put of State * Version * AsyncReplyChannel<PutResult>
![Page 87: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/87.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Get(reply)) -> reply.Reply <| Success(state, version) return! workingState(state, version) … }
type GetResult = Result<State * Version>
type PutResult = Result<unit>
![Page 88: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/88.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Get(reply)) -> reply.Reply <| Success(state, version) return! workingState(state, version) … }
![Page 89: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/89.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(newState, v, reply)) when version = v -> reply.Reply <| Success() return! workingState(newState, version+1) … }
![Page 90: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/90.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(newState, v, reply)) when version = v -> reply.Reply <| Success() return! workingState(newState, version+1) … }
type Message =
| Get of AsyncReplyChannel<GetResult>
| Put of State * Version * AsyncReplyChannel<PutResult>
![Page 91: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/91.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(newState, v, reply)) when version = v -> reply.Reply <| Success() return! workingState(newState, version+1) … }
![Page 92: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/92.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(newState, v, reply)) when version = v -> reply.Reply <| Success() return! workingState(newState, version+1) … }
![Page 93: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/93.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(_, v, reply)) -> reply.Reply <| Failure(VersionMismatch(version, v)) return! workingState(state, version) }
![Page 94: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/94.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with … | Some(Put(_, v, reply)) -> reply.Reply <| Failure(VersionMismatch(version, v)) return! workingState(state, version) } type Result<‘T> =
| Success of ’T
| Failure of Exception
![Page 95: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/95.jpg)
let rec workingState (state, version) = async { let! msg = inbox.TryReceive(60000) match msg with | None -> … | Some(Get(reply)) -> … | Some(Put(newState, v, reply)) when version = v -> … | Some(Put(_, v, reply)) -> … }
![Page 96: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/96.jpg)
and closedState () = async { let! msg = inbox.Receive() match msg with | Get(reply) -> reply.Reply <| Failure(WorkerStopped) return! closedState() | Put(_, _, reply) -> reply.Reply <| Failure(WorkerStopped) return! closedState() }
![Page 97: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/97.jpg)
and closedState () = async { let! msg = inbox.Receive() match msg with | Get(reply) -> reply.Reply <| Failure(WorkerStopped) return! closedState() | Put(_, _, reply) -> reply.Reply <| Failure(WorkerStopped) return! closedState() }
![Page 98: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/98.jpg)
5x efficient improvement
![Page 99: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/99.jpg)
60% latency drop
![Page 100: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/100.jpg)
no databases
![Page 101: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/101.jpg)
90% cost saving
![Page 102: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/102.jpg)
Recap
![Page 103: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/103.jpg)
Agents• no locks• async message passing
![Page 104: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/104.jpg)
Agents• no locks• async message passing• self-contained• easy to reason with
![Page 105: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/105.jpg)
akka.Net
Orleans
![Page 106: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/106.jpg)
Pattern Matching• clear & concise
![Page 107: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/107.jpg)
Async Workflow• non-blocking I/O• no callbacks
![Page 108: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/108.jpg)
![Page 109: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/109.jpg)
![Page 110: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/110.jpg)
Caught a Gnome
![Page 111: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/111.jpg)
EXP Item Gold
Quest Progress
Caught a Gnome
![Page 112: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/112.jpg)
Level Up
Quest Progress
EXP Item Gold
Caught a Gnome
Quest Complete
![Page 113: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/113.jpg)
Level Up
Quest Progress
EXP Item Gold
Caught a Gnome
New Quest
Quest Complete
![Page 114: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/114.jpg)
Quest Progress
EXP Item Gold
Caught a Gnome
Quest Complete
New Quest
Level Up
![Page 115: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/115.jpg)
Quest Progress
New QuestAchievement
Progress
EXP Item Gold
Quest CompleteLevel Up
Caught a Gnome
![Page 116: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/116.jpg)
Level Up
Quest Progress
EXP Item Gold
Caught a Gnome
Quest Complete
New QuestAchievement
Progress
Achievement Complete
![Page 117: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/117.jpg)
Level Up
Quest Progress
EXP Item Gold
Caught a Gnome
Quest Complete
New QuestAchievement
Progress
Achievement Complete
![Page 118: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/118.jpg)
100+ actions
![Page 119: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/119.jpg)
![Page 120: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/120.jpg)
triggered by different abstraction layers
![Page 121: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/121.jpg)
non-functional requirements
![Page 122: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/122.jpg)
![Page 123: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/123.jpg)
message-broker pattern
![Page 124: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/124.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
![Page 125: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/125.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
Ignore
Process
Process
Process
Process
Ignore
![Page 126: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/126.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
EXPItemGold
![Page 127: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/127.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
EXPItemGold
![Page 128: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/128.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
EXPItemGold
Process
Ignore
Ignore
Ignore
Process
Ignore
![Page 129: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/129.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
EXPItemGold
Level Up
![Page 130: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/130.jpg)
Caught Gnome Trapping
Queue
Levelling
Quests
Achievements
Analytics
Partner Reporting
EXPItemGold
Level Up
![Page 131: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/131.jpg)
need lots of facts
![Page 132: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/132.jpg)
type Fact = | GotExp of Exp | GotGold of Gold | GotItem of Item * Count | CaughtMonster of Monster * Bait * Location | LevelUp of OldLevel * NewLevel …
![Page 133: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/133.jpg)
type Reward = | GotExp of Exp | GotGold of Gold | GotItem of Item * Count
type StateChange = | LevelUp of OldLevel * NewLevel …
![Page 134: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/134.jpg)
type Fact = | StateChange of StateChange | Reward of Reward | Trapping of Trapping | Fishing of Fishing …
![Page 135: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/135.jpg)
let process fact = match fact with | StateChange(stateChange) -> … | Reward(reward) -> … | Trapping(trapping) -> … …
![Page 136: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/136.jpg)
C# interop
![Page 137: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/137.jpg)
…var fact = Fact.NewStateChange(
StateChange.NewLevelUp(oldLvl, newLvl));…
![Page 138: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/138.jpg)
type IFact = interface end
type Reward = | GotExp of Exp | GotGold of Gold | GotItem of Item * Count interface IFact
![Page 139: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/139.jpg)
type IFact = interface end
type Reward = | GotExp of Exp | GotGold of Gold | GotItem of Item * Count interface IFact
![Page 140: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/140.jpg)
let process (fact : IFact) = match fact with | :? StateChange as stateChange -> … | :? Reward as reward -> … | :? Trapping as trapping -> … … | _ -> raise <| NotSupportedFact fact
![Page 141: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/141.jpg)
let process (fact : IFact) = match fact with | :? StateChange as stateChange -> … | :? Reward as reward -> … | :? Trapping as trapping -> … … | _ -> raise <| NotSupportedFact fact
![Page 142: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/142.jpg)
simple
![Page 143: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/143.jpg)
flexible
![Page 144: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/144.jpg)
saver
![Page 145: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/145.jpg)
![Page 146: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/146.jpg)
location baitattraction rate
catch rate
![Page 147: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/147.jpg)
auto-tuning trapping stats
![Page 148: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/148.jpg)
Monsterstrength speed
intelligence
Trapstrength speed
technology
![Page 149: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/149.jpg)
Monsterstrength speed
intelligence
Trapstrength speed
technology
Catch Rate %
![Page 150: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/150.jpg)
trial-and-error
![Page 151: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/151.jpg)
“if you require constant diligence you’re setting
everyone up for failure and hurt”
- Bryan Hunter
![Page 152: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/152.jpg)
genetic algorithms
![Page 153: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/153.jpg)
![Page 154: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/154.jpg)
![Page 155: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/155.jpg)
![Page 156: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/156.jpg)
![Page 157: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/157.jpg)
![Page 158: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/158.jpg)
![Page 159: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/159.jpg)
![Page 160: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/160.jpg)
![Page 161: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/161.jpg)
![Page 162: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/162.jpg)
![Page 163: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/163.jpg)
![Page 164: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/164.jpg)
F#-powered DSLs.Awesome!
![Page 165: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/165.jpg)
![Page 166: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/166.jpg)
![Page 167: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/167.jpg)
wanna find correlations?
![Page 168: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/168.jpg)
wanna find correlations?
you can DIY it!
;-)
![Page 169: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/169.jpg)
Amazon.CloudWatch.Selector
github.com/fsprojects/Amazon.CloudWatch.Selector
![Page 170: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/170.jpg)
Find metrics whose 5 min average exceeded
1 second during last 12 hours
![Page 171: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/171.jpg)
cloudWatch.Select( unitIs “milliseconds” + average (>) 1000.0 @ last 12 hours |> intervalOf 5 minutes)
![Page 172: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/172.jpg)
cloudWatch.Select(“ unitIs ‘milliseconds’ and average > 1000.0 duringLast 12 hours at intervalOf 5 minutes”)
![Page 173: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/173.jpg)
Did any cache nodes’ CPU spike yesterday?
![Page 174: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/174.jpg)
cloudWatch.Select( namespaceLike “elasticache” + nameLike “cpu” + max (>) 80.0 @ last 24 hours |> intervalOf 15 minutes)
![Page 175: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/175.jpg)
cloudWatch.Select( namespaceLike “elasticache” + nameLike “cpu” + max (>) 80.0 @ last 24 hours |> intervalOf 15 minutes)
regex support
![Page 176: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/176.jpg)
![Page 177: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/177.jpg)
![Page 178: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/178.jpg)
![Page 179: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/179.jpg)
Amazing
F# =
![Page 180: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/180.jpg)
![Page 181: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/181.jpg)
managedkey-value store
![Page 182: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/182.jpg)
redundancy9-9s guarantee
![Page 183: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/183.jpg)
great performance
![Page 184: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/184.jpg)
name your throughput
![Page 185: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/185.jpg)
![Page 186: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/186.jpg)
select GameTitle, UserId, TopScore from GameScores where GameTitle = “Starship X” and TopScore >= 1000 order desc limit 3 with (NoConsistentRead, Index(GameTitleIndex, true))
![Page 188: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/188.jpg)
GOAL
Disguise complexity
![Page 189: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/189.jpg)
GOAL
SELECT UserId, TopScore FROM GameScore WHERE GameTitle CONTAINS “Zelda” ORDER DESCLIMIT 3 WITH (NoConsistentRead)
![Page 190: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/190.jpg)
Query
AST
Execution
![Page 192: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/192.jpg)
![Page 193: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/193.jpg)
SELECT * FROM GameScore
Abstract Syntax Tree (AST)
FParsec
![Page 194: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/194.jpg)
![Page 195: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/195.jpg)
select GameTitle, UserId, TopScore from GameScores where GameTitle = “Starship X” and TopScore >= 1000 order desc limit 3 with (NoConsistentRead, Index(GameTitleIndex, true))
![Page 196: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/196.jpg)
![Page 197: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/197.jpg)
< 50 LOC
![Page 198: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/198.jpg)
S3 Provider
github.com/fsprojects/S3Provider
F# type provider for Amazon S3
![Page 199: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/199.jpg)
![Page 200: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/200.jpg)
![Page 201: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/201.jpg)
intellisense over S3
![Page 202: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/202.jpg)
compile time validation
![Page 203: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/203.jpg)
no code generation
![Page 204: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/204.jpg)
Domain ModellingInfrastructureGame LogicAlgorithms
DSLs
![Page 205: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/205.jpg)
why F#?
![Page 206: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/206.jpg)
time to market
![Page 207: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/207.jpg)
correctness
![Page 208: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/208.jpg)
efficient
![Page 209: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/209.jpg)
tame complexity
![Page 210: F# in social gaming by Yan Cui at Codemotion Dubai](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58ed04b21a28ab166c8b45ed/html5/thumbnails/210.jpg)
@theburningmonktheburningmonk.comgithub.com/theburningmonk