21
Elton Stoneman Microsoft MVP & Pluralsight Author http://particular.net Scaling with Asynchronous Messaging

Scaling with Asynchronous Messaging

  • Upload
    sixeyed

  • View
    166

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Scaling with Asynchronous Messaging

Elton Stoneman

Microsoft MVP & Pluralsight Author

http://particular.net

Scaling with

Asynchronous Messaging

Page 2: Scaling with Asynchronous Messaging

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

The VETRO pattern

Single host architectures

Message queue architecture

Outline

Page 3: Scaling with Asynchronous Messaging

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

Page 4: Scaling with Asynchronous Messaging

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Synchronous, sequential processing

Single host process

Demo – App V1.0

Page 5: Scaling with Asynchronous Messaging

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

Page 6: Scaling with Asynchronous Messaging

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

Page 7: Scaling with Asynchronous Messaging

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Asynchronous, parallel processing

Using Tasks and DataFlow

Single host process

Demo – App V1.1 & 1.2

Page 8: Scaling with Asynchronous Messaging

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

Page 9: Scaling with Asynchronous Messaging

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

Page 10: Scaling with Asynchronous Messaging

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

Page 11: Scaling with Asynchronous Messaging

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

Page 12: Scaling with Asynchronous Messaging

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

Page 13: Scaling with Asynchronous Messaging

Asynchronous message sending

Single producer process

Multiple consumer processes

Introduction to ServiceInsight for NServiceBusScaling with Asynchronous Messaging

Demo: App V2

Page 14: Scaling with Asynchronous Messaging

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

Page 15: Scaling with Asynchronous Messaging

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

Page 16: Scaling with Asynchronous Messaging

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

Page 17: Scaling with Asynchronous Messaging

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

Page 18: Scaling with Asynchronous Messaging

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

Page 19: Scaling with Asynchronous Messaging

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

Page 20: Scaling with Asynchronous Messaging

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

Page 21: Scaling with Asynchronous Messaging

Thank you

github.com/sixeyed/going-async