2

I've download Kitura 0.20 and created a new project for a benchmark on a swift build -c release

import Kitura

let router = Router()

router.get("/") {
request, response, next in
    response.send("Hello, World!")
    next()
}

Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()

and the score appear to be low compare to Zewo and Vapor which could hit 400k+ request/s?

MacBook-Pro:hello2 yanli$ wrk -t1 -c100 -d30 --latency http://localhost:8090
Running 30s test @ http://localhost:8090
  1 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   415.36us  137.54us   3.09ms   91.11%
    Req/Sec     5.80k     2.47k    7.19k    85.71%
  Latency Distribution
     50%  391.00us
     75%  443.00us
     90%  513.00us
     99%    0.93ms
  16229 requests in 30.01s, 1.67MB read
  Socket errors: connect 0, read 342, write 55, timeout 0
Requests/sec:    540.84
Transfer/sec:     57.04KB
James Lei
  • 41
  • 5

1 Answers1

3

I suspect you are running out of ephemeral ports. Your issue is probably the same as this one: 'ab' program freezes after lots of requests, why?

Kitura currently does not support HTTP keepalive, and so every request requires a new connection. One symptom of this is that regardless of how many seconds you attempt to drive load, you'll see a similar number of completed requests (16229 in your example).

On OS X, there are 16,384 ephemeral ports available by default, and these will be rapidly exhausted unless you tune the network settings.

[1] http://danielmendel.github.io/blog/2013/04/07/benchmarkers-beware-the-ephemeral-port-limit/ [2] https://rolande.wordpress.com/2010/12/30/performance-tuning-the-network-stack-on-mac-osx-10-6/

My approach has been to reduce the Maximum Segment Lifetime tunable (which defaults to 15000, or 15 seconds) and increase the range of available ports temporarily while benchmarking, for example:

sudo sysctl -w net.inet.tcp.msl=1000
sudo sysctl -w net.inet.ip.portrange.first=32768
<run benchmark>
sudo sysctl -w net.inet.tcp.msl=15000
sudo sysctl -w net.inet.ip.portrange.first=49152
Community
  • 1
  • 1
David Jones
  • 131
  • 5
  • Interesting, and Kitura build is failed at the moment until other fix is done. Testing on Perfect and Vapor with the new sysctl you've provided, they are still getting the same score, I guess they are not impact by MSL. Have provide some info to the contributors and let see what is their finding. – James Lei Jul 17 '16 at 14:16
  • For reference, Kitura 1.0 now supports keepalive. The `wrk` driver will try to use keepalive by default, but take care if using `ab` as your driver, as you need to pass the `-k` flag to enable keepalive on the client side. – David Jones Nov 23 '16 at 09:40
  • Thanks for the update here, I followed your Github issue progress and I think I replied in that issue. – James Lei Nov 23 '16 at 15:40