21
#CDays14 – Milano 25, 26 e 27 Febbraio 2014 WEB06 WEB IN REAL TIME CON ASP.NET SIGNALR

Real time web with SignalR

Embed Size (px)

DESCRIPTION

How to use SignalR in an event-driven architecture to close the write/read cycle.

Citation preview

Page 1: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

WEB06 WEB IN REAL TIME CON ASP.NET SIGNALR

Page 3: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

Agenda• What / Why / When

• Event-driven architecture and SignlaR

• Scale-out SignalR

• Performance tips

Page 4: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

About meAlessandro MelchioriSoftware architect @ codiceplastico

@amelchiori

http://melkio.blog.codiceplastico.com

Page 5: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

demoSignalR.Intro

Page 6: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

Pres

enta

tion

Laye

r

Serv

ice

Laye

r

Dom

ain

Mod

el

Storage

Da qui…

Page 7: Real time web with SignalR

#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

Page 8: Real time web with SignalR

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)

Page 9: Real time web with SignalR

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

Page 10: Real time web with SignalR

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

Page 11: Real time web with SignalR

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

Page 12: Real time web with SignalR

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

Page 13: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

demoEvent-driven architecture & SignalR

Page 14: Real time web with 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

Page 15: Real time web with SignalR

Scale-out issues: message delivery

?How do messages from one server get

to the other servers in my web farm?

Page 16: Real time web with SignalR

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?

Page 17: Real time web with SignalR

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?

Page 18: Real time web with SignalR

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

Page 19: Real time web with SignalR

Scale-out provider architecture

web nodes

clients

backplaneMessages sharded

over multiple backplane streams

Page 20: Real time web with SignalR

#CDays14 – Milano 25, 26 e 27 Febbraio 2014

demoScale-out SignalR

Page 21: Real time web with 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