Repository navigation
add Compojure with htp-kit and dbcp.clj - #22
Conversation
|
👍 |
|
Thanks for the contribution @shenfeng |
|
Hi, thanks. I am more than happy to answer any question about http-kit. http-kit is written in JAVA, I guess it should have better performance than Netty or servlet [1], and a nice Clojure API is exported, so, we can have much better API than Netty or servlet can offer. The combined result is interesting: we have runtime performance and developer performance at the same time. |
|
Hi, Shen. Thanks again for this test for http-kit. We included http-kit in the runs that we kicked off this Tuesday using @wg's Wrk in lieu of WeigHTTP. We switched to Wrk in order to get latency data but a side-effect is that Wrk is able to squeeze a bit more performance out of the frameworks, so many results have gone up slightly versus our first round of tests. On our i7 hardware, the results for http-kit are respectable: approximately 68K rps for the JSON serialization test, but that does not rival Netty or Servlets. This has me curious about two things:
As with every test, we want to be sure that we're not crippling http-kit by way of some silly configuration oversight. |
http-kit has little to configure. #setup.py
command = "lein run -- --db-host " + args.database_host + " --worker=${CPU_CORES}"
# should have better raw performanceServlet can do 213,322 and netty 203,970? while http-kit's can only do 68k. That's faster than I think. I can understand netty and servlet faster than http-kit. I've read the netty one's code, it's pretty low level. And I can not beat Java with Clojure: Clojure is write on top of Java :) I run wrk on the netty and http-kit on a Macbook Air with 1.7 GHZ cpu: # netty
./wrk -t3 -c400 -r100k http://localhost:8080/
Making 100000 requests to http://localhost:8080/
3 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.06ms 9.30ms 69.33ms 82.43%
Req/Sec 7.84k 0.95k 9.00k 74.32%
100096 requests in 3.69s, 17.18MB read
Socket errors: connect 0, read 266, write 0, timeout 0
Requests/sec: 27151.18
Transfer/sec: 4.66MB#http-kit
./wrk -t3 -c400 -r100k http://localhost:8080/http-kit/json
Making 100000 requests to http://localhost:8080/http-kit/json
3 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 16.00ms 12.53ms 63.93ms 63.48%
Req/Sec 5.14k 793.47 7.00k 51.30%
100017 requests in 5.80s, 16.02MB read
Socket errors: connect 0, read 808, write 0, timeout 7
Requests/sec: 17240.70
Transfer/sec: 2.76MBI am curious about the database access performance ranking. I expect it to be slower than netty or servlet. |
|
Hi, I just sent another pull request #103, hopefully, will make http-kit run faster. |
|
Excellent. We'll get that applied soon! |
|
Hi, I just sent another pull request #147. |
Here's an example of the error output from before this change: Unhandled exception: Bad state: Stream was already listened to #0 _RawServerSocket.listen (dart:io-patch/socket_patch.dart:1106) TechEmpower#1 new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:123) TechEmpower#2 _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:91) TechEmpower#3 _ForwardingStream.listen (dart:async/stream_pipe.dart:86) TechEmpower#4 _ServerSocket.listen (dart:io-patch/socket_patch.dart:1351) TechEmpower#5 _HttpServer.listen (dart:io/http_impl.dart:2278) TechEmpower#6 _startServer.<anonymous closure> (file:///server.dart:88:12) TechEmpower#7 _RootZone.runUnary (dart:async/zone.dart:1371) TechEmpower#8 _FutureListener.handleValue (dart:async/future_impl.dart:129) TechEmpower#9 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) TechEmpower#10 _Future._propagateToListeners (dart:async/future_impl.dart:665) TechEmpower#11 _Future._completeWithValue (dart:async/future_impl.dart:478) TechEmpower#12 Future.wait.<anonymous closure> (dart:async/future.dart:362) TechEmpower#13 _RootZone.runUnary (dart:async/zone.dart:1371) TechEmpower#14 _FutureListener.handleValue (dart:async/future_impl.dart:129) TechEmpower#15 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) TechEmpower#16 _Future._propagateToListeners (dart:async/future_impl.dart:665) TechEmpower#17 _Future._completeWithValue (dart:async/future_impl.dart:478) TechEmpower#18 Future.wait.<anonymous closure> (dart:async/future.dart:362) TechEmpower#19 _RootZone.runUnary (dart:async/zone.dart:1371) TechEmpower#20 _FutureListener.handleValue (dart:async/future_impl.dart:129) TechEmpower#21 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) TechEmpower#22 _Future._propagateToListeners (dart:async/future_impl.dart:665) TechEmpower#23 _Future._completeWithValue (dart:async/future_impl.dart:478) TechEmpower#24 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:510) TechEmpower#25 _microtaskLoop (dart:async/schedule_microtask.dart:41) TechEmpower#26 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50) TechEmpower#27 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99) TechEmpower#28 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)
Here's an example of the error output from before this change: Unhandled exception: Bad state: Stream was already listened to #0 _RawServerSocket.listen (dart:io-patch/socket_patch.dart:1106) #1 new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:123) #2 _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:91) #3 _ForwardingStream.listen (dart:async/stream_pipe.dart:86) #4 _ServerSocket.listen (dart:io-patch/socket_patch.dart:1351) #5 _HttpServer.listen (dart:io/http_impl.dart:2278) #6 _startServer.<anonymous closure> (file:///server.dart:88:12) #7 _RootZone.runUnary (dart:async/zone.dart:1371) #8 _FutureListener.handleValue (dart:async/future_impl.dart:129) #9 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) #10 _Future._propagateToListeners (dart:async/future_impl.dart:665) #11 _Future._completeWithValue (dart:async/future_impl.dart:478) #12 Future.wait.<anonymous closure> (dart:async/future.dart:362) #13 _RootZone.runUnary (dart:async/zone.dart:1371) #14 _FutureListener.handleValue (dart:async/future_impl.dart:129) #15 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) #16 _Future._propagateToListeners (dart:async/future_impl.dart:665) #17 _Future._completeWithValue (dart:async/future_impl.dart:478) #18 Future.wait.<anonymous closure> (dart:async/future.dart:362) #19 _RootZone.runUnary (dart:async/zone.dart:1371) #20 _FutureListener.handleValue (dart:async/future_impl.dart:129) #21 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636) #22 _Future._propagateToListeners (dart:async/future_impl.dart:665) #23 _Future._completeWithValue (dart:async/future_impl.dart:478) #24 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:510) #25 _microtaskLoop (dart:async/schedule_microtask.dart:41) #26 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50) #27 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99) #28 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)
Another test added to the suite using Compojure, but using http-kit[1] as the server and dbcp.clj[2] to talk to database
It should run quite fast and make it quite an interesting option.