Scaling with Asynchronous Messaging

Preview:

Citation preview

Elton Stoneman

Microsoft MVP & Pluralsight Author

http://particular.net

Scaling with

Asynchronous Messaging

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

The VETRO pattern

Single host architectures

Message queue architecture

Outline

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Integration pattern – receive

input; process; send output.

Discrete components.

Well suited to distributed

processing.

How parallel can you go?

The VETRO Pattern

Validate

Enrich

Transform

Route

Operate

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Synchronous, sequential processing

Single host process

Demo – App V1.0

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

1K messages: <1 min

10K messages: 4.5 min

App V1.0

0

50

100

150

200

250

300

1K msg 10K msg

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

1K messages: <1 min

10K messages: 4.5 min

1M messages: 7-8 hours

App V1.0

0

5000

10000

15000

20000

25000

30000

1K msg 10K msg 1M

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Asynchronous, parallel processing

Using Tasks and DataFlow

Single host process

Demo – App V1.1 & 1.2

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V1.2

1K messages: <0.5 min

10K messages: 3.5 min

0

50

100

150

200

250

1K msg 10K msg

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V1.2

1K messages: <0.5 min

10K messages: 3.5 min

1M messages: 5.5 hours

0

2000

4000

6000

8000

10000

12000

14000

16000

18000

20000

1K msg 10K msg 1M

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V1.2: In the Real World

1K messages: 1 min

10K messages: 10 min

1M messages: 17.5 hours

0

10000

20000

30000

40000

50000

60000

70000

1K msg 10K msg 1M

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Single host receives input &

runs processing.

v1.2 runs at 16msg/sec =

17.5 hours for 1M messages.

Cannot run extra hosts without

contention over input.

Needs rewrite to scale.

Scaling Limitations

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Single host receives input &

sends 'do processing'

messages to queues.

Hosts can read from queues

without contention.

Allows multiple hosts to run

processing concurrently.

More scale – add hosts.

Message Queue Architecture

Asynchronous message sending

Single producer process

Multiple consumer processes

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Demo: App V2

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V2

1K messages: <1 min

10K messages: 10 min

0

100

200

300

400

500

600

700

1K msg 10K msg

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V2

1K messages: <1 min

10K messages: 10 min

1M messages: 16.5 hours

0

10000

20000

30000

40000

50000

60000

70000

1K msg 10K msg 1M

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Remote DB & API

1x VM @ 1x host reading input & producing messages

3x VMs, each @ 9x hosts consuming messages

Demo – App V2 on Multiple VMs

0

50

100

150

200

250

300

350

400

450

500

1K msg 10K msg

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V2 on Multiple VMs

1K messages: <1 min

10K messages: 8 min

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

App V2 on Multiple VMs

1K messages: <1 min

10K messages: 8 min

1M messages: 13.5 hours

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

50000

1K msg 10K msg 1M

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Scaling with App V2

1M messages

3 VMs: 13.5 hours

6 VMs: 6.5 hours

10 VMs: 1.5 hours0

2

4

6

8

10

12

14

3 6 10

Du

rati

on

/ h

ou

rs

Consumer VMs

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

• Single processor always limited

• Split work and distribute

• Bottlenecks – dependencies not app logic

• Downside – more moving parts

• More upsides

Summary

Thank you

github.com/sixeyed/going-async

Recommended