我已经下载了Kitura 0.20并为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()
与Zewo和Vapor相比,得分可能会低至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
答案 0 :(得分:3)
我怀疑你的用尽了短暂的端口。您的问题可能与此问题相同:'ab' program freezes after lots of requests, why?
Kitura目前不支持HTTP keepalive,因此每个请求都需要新的连接。这种情况的一个症状是,无论您尝试驱动负载多少秒,您都会看到相似数量的已完成请求(在您的示例中为16229)。
在OS X上,默认情况下有16,384个临时端口可供使用,除非您调整网络设置,否则这些端口将很快耗尽。
[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/
我的方法是减少Maximum Segment Lifetime可调参数(默认为15000或15秒)并在基准测试时临时增加可用端口的范围,例如:
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