#CDays14 – Milano 25, 26 e 27 Febbraio 2014
WEB06 WEB IN REAL TIME CON ASP.NET SIGNALR
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Grazie a
Sponsor
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Agenda• What / Why / When
• Event-driven architecture and SignlaR
• Scale-out SignalR
• Performance tips
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
About meAlessandro MelchioriSoftware architect @ codiceplastico
@amelchiori
http://melkio.blog.codiceplastico.com
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
demoSignalR.Intro
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Pres
enta
tion
Laye
r
Serv
ice
Laye
r
Dom
ain
Mod
el
Storage
Da qui…
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Pres
enta
tion
Laye
r
Serv
ice
Laye
r
Dom
ain
Mod
el
Write storage
Read storage
…a qui
message bus
SignalR core architecture: pub/sub
message cache
publisher
client client client client
- serializzazione- salvataggio in cache- “deliverable”
client
worker worker worker
- selezione worker- recupero messaggio
notifica al client (over specific transport)
Pattern 1. Server broadcast
• Low rate broadcast of the same payload to all clients
• One message bus send maps to many users (fan out)
• More clients don’t increase message bus traffic
Pattern 2. Server push
• Low rate broadcast of the unique payload to each client
• One message bus send maps to one user (no fan out)
• More clients means more message bus traffic
Pattern 3. User event driven
• Broadcast on client actions
• One message bus send maps to many users (fan out)
• More clients means more message bus traffic
Pattern 4. High frequency real-time
• Fixed high rate broadcast from servers and clients
• One message bus send maps to one user (no fan out)
• More clients means more message bus traffic
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
demoEvent-driven architecture & SignalR
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Remember…
Have your app do as little as possible. If you do nothing, you can scale infinitely.
Scott Hanselman
Scale-out issues: message delivery
?How do messages from one server get
to the other servers in my web farm?
Scale-out issues: client transience
server 1
client
server 2
When is a client disconnected from
my app?
How do I avoid duplicate & missed
messages as I move from server to
server?
Scale-out issues: client distribution
server 1 server 2
client “foo”
client “foo”
client “foo,bar”
client “foo”
client “bar”
client “bar”
client “foo”
client “foo”
What happens if “foo” clients get many
more messages than others?
Scale-out SignalR
• SQL Server, Redis & Windows Azure Service Bus
• Great for the server broadcast load pattern
• Limited for other scenarios Every message goes to every server, so as traffic increases you’re
limited by how fast any one web server can pull messages off of the backplane
Backplanes are *much* slower than single-server performance
Scale-out provider architecture
web nodes
clients
backplaneMessages sharded
over multiple backplane streams
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
demoScale-out SignalR
#CDays14 – Milano 25, 26 e 27 Febbraio 2014
Q&ATutto il materiale di questa sessione su
http://www.communitydays.it/
Lascia il feedback su questa sessione,
potrai essere estratto per i nostri premi!
Seguici su
Twitter @CommunityDaysIT
Facebook http://facebook.com/cdaysit
#CDays14