The document describes a new layered architecture for a social and casual gaming platform. The key points are:
1) The previous architecture had inconsistent designs, unclear responsibilities, technical debt, and scaling issues with 7 layers of caching.
2) The new architecture aims to be flexible, predictable, scalable, simple with clean separation and no horizontal dependencies.
3) It has four main layers - client, interface, service, and storage - each with clear responsibilities around integration, authorization, composition, and persistence. Building blocks are small, simple applications and a platform to abstract complexity.
7. XML Json
Interfacing Interfacing +
plain GET Intefacing Intefacing
Caching SQL Business Caching
Authorization + Authentication
Business Caching
Caching logic logic
Authorization
Business SQL
Business Business
logic Caching Caching logic
logic
Business
SQL
logic
Caching SQL
SQL Business
SQL logic
Swift SQLSchema
API
Schema Schema
Schema
Mysql
Write DB Mysql DB Mysql DB Mysql DB
Mysql
Reader
Memcache
Mysql Mysql DB Cluster
Readers
7
8. Problems
Inconsistent
design
&
interfaces
Unclear
responsibili4es
Technical
debt
Independent
teams
developing
the
same
features.
7
layers
of
caching
hell
Scaling
9. Problems
Inconsistent
design
&
interfaces
Unclear
responsibili4es
Technical
debt
Independent
teams
developing
the
same
features.
7
layers
of
caching
hell
Scaling
not a
problem
:)
18. Interfaces
https post
/user/get/
3rd Party {auth:
{token: UwAA_AWeff...} Highscore
Backend } Service
list
1
get([friends]) Application
User
2 User 2 Interface
Interface
Service
list
get(me)
1
count /application/highscores/
1
Friends
Service
1
User
Service Awards
Service
16
21. definition
User
profile logic Service
template
+ Award
html,
Service
[properties]
18
22. header
definition
User
logo profile Service
logic
template
navigation search + Award
html,
Service
[properties]
18
23. ame.com /
htt p://www.ag
preprocess
...
widget platform
footer ...
home_page
new games
header body
...
definition
User
logo profile Service
logic
template
navigation search + Award
html,
Service
[properties]
18
24. Services
user
{context:{ get interface
guid: 62623423,
siteid : 88,
locale : en_US
},guid: 324112535}
{
gid: 324112535,
user service username : -fooba-,
avatarId :
http://agame.com/avatars/99142.png
}
check fetch 鍖lter modify
{
gid: 324112535,
username : -fooba-,
profile firstName : john
storage avatarId : 99142
}
25. Storage platform
API
instead
of
SQL
Buckets
of
data
=
Key-足Value
with
Schema
Abstracts
storage
Bucket Bucket Bucket Bucket Bucket Bucket
Storage Node 1 Storage Node 2
Cache Cache
Shard 1 Shard 2 Shard ..
20
28. interface JSON Load
balancer
Auth User Award Pro鍖le Game
in@erface interface interface widget widget
Protobuf Widget
PlaGorm
service
User User Game Award Award
service service service service service
Protobuf
storage
User Game
Pro鍖les Pro鍖les Games
Award Award
bucket bucket bucket
bucket bucket
Storage
PlaGorm
23
29. How we do it
Strictly
de鍖ne
EVERYTHING
input/output
format,
urls,
rpc
func4ons,
types,
valida4on
Strict
rules
on
changes
Everything
op4onal
Unless
youre
really,
really
sure
(and
have
proof!)
Generate
code
and
documenta4on
Interface
derived
from
speci鍖ca4on
Documenta4on
derived
from
speci鍖ca4on
24
31. What we ended up with
Small
applica4ons
running
on
their
own
nodes
Scale
up
where
necessary
Many
of
them
on
the
same
machine
Small
cluster
already
contains
hundreds
of
nodes
26
32. Keeping it connected
Connec4ng
all
nodes
is
a
bad
idea:
Not
needed
Number
of
open
connec4ons
Solu4on:
use
hidden
nodes
Each
node
speci鍖es
the
nodes
it
needs.
How
does
it
scale?
27
34. Router
Each
applica4on
has
its
own
router
Scans
&
Monitors
Balances
requests
across
nodes
Parallelizes
requests
as
much
as
possible
Applica4on
can
only
talk
to
what
it
has
de鍖ned
29
35. But what about response times?
Use
proper
transports
(Erlang
RPC
vs.
HTTP)
Yes
there
is
some
transport
overhead
Typically
<
1ms
per
layer
(+network
latency)
But
each
layer
has
predictable
response
4mes
As
long
as
enough
downward
resources
are
available
30
39. Where are we now..
Interface
layer
has
been
de鍖ned
and
largely
implemented
ImplemenMng
the
service
&
storage
layer
step
by
step
Meanwhile
we
have
adapters
in
place
Several
of
the
new
APIs
are
in
use
in
producMon
First
portals
on
the
new
widget
plaGorm
will
be
deployed
in
the
coming
months
34
40. ... And where were going
Deploying
to
mul4ple
datacenters
this
year
Bring
elas4city
to
our
deployments
Decommission
our
old
architecture
Erlang
game
plahorm
35
41. Lessons Learned
An
architectural
vision
is
crucial
Integra4ng
into
a
mess
is
a
mess
Layers
with
clear
responsibili4es
Strict
communica4on
Package
small
Change
is
the
only
constant
Op4mize
for
predictability
鍖rst
36