16
The Disruptor High Performance Inter-Thread Messaging Michael Barker @mikeb2701 Lead Developer LMAX Thursday, 17 November 11

Disruptor tools in action

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Disruptor   tools in action

The DisruptorHigh Performance Inter-Thread MessagingMichael Barker @mikeb2701Lead DeveloperLMAX

Thursday, 17 November 11

Page 2: Disruptor   tools in action

Mo’vember• Apologies for the silly facial hair• Raising money for men’s health• Donate!!!

2

http://mobro.co/mikeb2701

Thursday, 17 November 11

Page 3: Disruptor   tools in action

What is the Disruptor?

http://code.google.com/p/disruptor

Thursday, 17 November 11

Page 4: Disruptor   tools in action

static long foo = 0;

private static void increment() { for (long l = 0; l < 500000000L; l++) { foo++;

}

}

Thursday, 17 November 11

Page 5: Disruptor   tools in action

public static long foo = 0;public static Lock lock = new Lock();

private static void increment() { int iterations = 500000000L / THREADS; for (long l = 0; l < iterations; l++){ lock.lock(); try { foo++; } finally { lock.unlock(); } }}

Thursday, 17 November 11

Page 6: Disruptor   tools in action

static AtomicLong foo = new AtomicLong(0);

private static void increment() { int iterations = 500000000L / THREADS; for (long l = 0; l < iterations; l++) { foo.getAndIncrement(); }}

Thursday, 17 November 11

Page 7: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms

Thursday, 17 November 11

Page 8: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms• One Thread (volatile): 4 700 ms (15x)

Thursday, 17 November 11

Page 9: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms• One Thread (volatile): 4 700 ms (15x)• One Thread (Atomic) : 5 700 ms (19x)

Thursday, 17 November 11

Page 10: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms• One Thread (volatile): 4 700 ms (15x)• One Thread (Atomic) : 5 700 ms (19x)• One Thread (Lock) : 10 000 ms (33x)

Thursday, 17 November 11

Page 11: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms• One Thread (volatile): 4 700 ms (15x)• One Thread (Atomic) : 5 700 ms (19x)• One Thread (Lock) : 10 000 ms (33x)• Two Threads (Atomic) : 17 000 ms (58x)

Thursday, 17 November 11

Page 12: Disruptor   tools in action

Increment a counter 500 000 000 times.

• One Thread : 300 ms• One Thread (volatile): 4 700 ms (15x)• One Thread (Atomic) : 5 700 ms (19x)• One Thread (Lock) : 10 000 ms (33x)• Two Threads (Atomic) : 17 000 ms (58x)• Two Threads (Lock) : 104 000 ms (345x) ^^^^^^^^ > 1.5 minutes!!!

Thursday, 17 November 11

Page 13: Disruptor   tools in action

Thursday, 17 November 11

Page 14: Disruptor   tools in action

Test Queue Disruptor Factor

OnePublisherToOneProcessorUniCastThroughputTest 2,366,171 72,087,993 30.5

OnePublisherToThreeProcessorDiamondThroughputTest 1,590,126 63,358,798 39.8

OnePublisherToThreeProcessorMultiCastThroughputTest 191,661 54,165,692 282.6

OnePublisherToThreeProcessorPipelineThroughputTest 1,289,199 71,562,125 55.5

OnePublisherToThreeWorkerPoolThroughputTest 2,175,593 10,412,567 4.8

Thursday, 17 November 11

Page 15: Disruptor   tools in action

Demo: Concert Tickets...

15

Concert Service

Concert Repository

<entity>Concert

<entity>Section

<event>Concert Created

<event>Allocation Rejected

<event>Allocation Approved

<event>Section Updated

<event>Concert Created

<event>Ticket

Purchase

Thursday, 17 November 11

Page 16: Disruptor   tools in action

Demo: Concert Tickets...

16

Request Servlet

Response Servlet

Concert Service

UDP UDP

HTTP Client

Long PollHTTP

Thursday, 17 November 11