Skip to content

Instantly share code, notes, and snippets.

@richdougherty
Created April 1, 2014 05:15
Show Gist options
  • Select an option

  • Save richdougherty/9908113 to your computer and use it in GitHub Desktop.

Select an option

Save richdougherty/9908113 to your computer and use it in GitHub Desktop.

Test results

Non-blocking - 38 req/s

  def nonBlocking(delay: Long) = Action.async {
    val result = Promise[SimpleResult]
    Akka.system.scheduler.scheduleOnce(delay.millis) {
      result.success(Ok)
    }
    result.future
  }
$ wrk http://localhost:9000/debug/nonBlocking/500 --connections 20 --timeout 1s
Running 10s test @ http://localhost:9000/debug/nonBlocking/500
  2 threads and 20 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   519.91ms    1.15ms 523.41ms   75.00%
    Req/Sec    19.00      1.83    23.00     75.00%
  380 requests in 10.00s, 14.10KB read
Requests/sec:     37.98
Transfer/sec:      1.41KB

Blocking - 8 req/s

  def blocking(delay: Long) = Action {
    Thread.sleep(delay)
    Ok
  }
$ wrk http://localhost:9000/debug/blocking/500 --connections 20 --timeout 1s
Running 10s test @ http://localhost:9000/debug/blocking/500
  2 threads and 20 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.20s   813.91ms   4.02s    56.25%
    Req/Sec     3.25      1.65     6.00     62.50%
  76 requests in 10.01s, 2.82KB read
  Socket errors: connect 0, read 0, write 0, timeout 60
Requests/sec:      7.60
Transfer/sec:     288.64B

Non-blocking + Await.result - 38 req/s

  def semiBlocking(delay: Long) = Action {
    val result = Promise[SimpleResult]
    Akka.system.scheduler.scheduleOnce(delay.millis) {
      result.success(Ok)
    }
    Await.result(result.future, (delay + 1000).millis)
  }
$ wrk http://localhost:9000/debug/semiBlocking/500 --connections 20 --timeout 1s
Running 10s test @ http://localhost:9000/debug/semiBlocking/500
  2 threads and 20 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   519.86ms    1.15ms 522.33ms   78.12%
    Req/Sec    20.06      2.91    28.00     87.50%
  380 requests in 10.01s, 14.10KB read
Requests/sec:     37.98
Transfer/sec:      1.41KB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment