Skip to content

Benchmarking

Csaba Tamas edited this page May 8, 2016 · 7 revisions

Table of contents

#Benchmark: Dispatcher Pattern

The scope of this test is to find out the efficiency of the two main Dispatcher Pattern strategies:

  • DispatcherPattern.BLOCKING_REQUEST - waits for the response of the first request before dispatching the second request;
  • DispatcherPattern.CORRELATED_ASYNC - dispatches all the requests and upon receiving a response matches the requests based on the Response's correlationId header value;

##Burst Test

During the test 1000 messages are dispatched. The Endpoint Proxy client code is not waiting for the response (not blocking), instead it collects all responses at the end of the test;

Pseudo Code

var dispatchedRequestList

for (1:100)
	responseFuture = dispatch(request)
	dispatchedRequestList.add(responseFuture)

block until dispatchedRequestList.size == 0
...
responseFuture.responseReceived(dispatchedRequestList.remove(this))

###BLOCKING_REQUEST BURST 1000 messages / log level: error

  • Average Time (6 consecutive executions): 5.4266s
  • Median Time (6 consecutive executions): 5.4885s
  • Final Memory: 10M/212M

###CORRELATED_ASYNC BURST 1000 messages / log level: error

  • Average Time (6 consecutive executions): 4.1361s
  • Median Time (6 consecutive executions): 4.1160s
  • Final Memory: 8M/150M

##Sequential test

During the test 10 messages are dispatched. However the client code will wait for the response of the request, before dispatching the second one.

Pseudo Code

for (1:100)
	responseFuture = dispatch(request)
	responseFuture.waitForResponse()

###BLOCKING_REQUEST SEQUENTIAL 100 messages / log level: error

  • Average Time (6 consecutive executions): 11.02s
  • Median Time (6 consecutive executions): 11.0025s
  • Final Memory: 10M/212M

###CORRELATED_ASYNC SEQUENTIAL 100 messages / log level: error

  • Average Time (6 consecutive executions): 14.9233s
  • Median Time (6 consecutive executions): 14.8595s
  • Final Memory: 10M/212M

##Conclusion It seems that the message correlation imposes an additional overhead and substantially slows down the message processing. Therefore in most cases the BLOCKING_REQUEST Dispatcher Pattern will fit the bill. Only when the client adopts consequently the non-blocking programming techniques will the CORRELATED_ASYNC Dispatcher Pattern bring benefits.

##Test Context

  • Test platform: CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  • executed on 1.0.0-snapshot at May 01 16:18:30 2016

Clone this wiki locally