项目作者: lamatola-os

项目描述 :
netty
高级语言: Java
项目地址: git://github.com/lamatola-os/netty-microservice.git
创建时间: 2018-04-07T10:29:08Z
项目社区:https://github.com/lamatola-os/netty-microservice

开源协议:

下载


netty microservice

  • uses netty 4.1
  • https://livebook.manning.com/book/netty-in-action/chapter-1/57
  • Non-blocking network calls free us from having to “wait for the completion” of an operation.
    Fully async I/O builds on this feature and carries it a step further: an async method returns immediately and
    notifies the user when it is complete, directly or at a later time.
  • Selectors allow us to monitor many connections for events with many fewer threads.
  1. cd server
  2. gradle run

architecture

  1. NettyMicroServer#run ------> HttpServerChannel#initChannel ---> HeartbeatServerHandler#channelRead0
  1. $ curl -v localhost:9090
  2. * Trying ::1...
  3. * TCP_NODELAY set
  4. * Connected to localhost (::1) port 9090 (#0)
  5. > GET / HTTP/1.1
  6. > Host: localhost:9090
  7. > User-Agent: curl/7.64.1
  8. > Accept: */*
  9. >
  10. < HTTP/1.1 200 OK
  11. < content-type: application/json
  12. < content-length: 67
  13. <
  14. * Connection #0 to host localhost left intact
  15. {"applicationName":"netty-netty-netty-netty-netty-netty-netty","applicationVersion":"1.0"}
  16. * Closing connection 0

perf

  1. ## lower concurrent requests results higher throughput
  2. ## with 100 concurrent requests
  3. ab -n 25000 -c 100 -k http://localhost:9090/
  4. This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
  5. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  6. Licensed to The Apache Software Foundation, http://www.apache.org/
  7. Benchmarking localhost (be patient)
  8. Completed 2500 requests
  9. Completed 5000 requests
  10. Completed 7500 requests
  11. Completed 10000 requests
  12. Completed 12500 requests
  13. Completed 15000 requests
  14. Completed 17500 requests
  15. Completed 20000 requests
  16. Completed 22500 requests
  17. Completed 25000 requests
  18. Finished 25000 requests
  19. Server Software:
  20. Server Hostname: localhost
  21. Server Port: 9090
  22. Document Path: /
  23. Document Length: 67 bytes
  24. Concurrency Level: 100
  25. Time taken for tests: 0.320 seconds
  26. Complete requests: 25000
  27. Failed requests: 0
  28. Keep-Alive requests: 25000
  29. Total transferred: 4050000 bytes
  30. HTML transferred: 1675000 bytes
  31. Requests per second: 78120.36 [#/sec] (mean)
  32. Time per request: 1.280 [ms] (mean)
  33. Time per request: 0.013 [ms] (mean, across all concurrent requests)
  34. Transfer rate: 12358.89 [Kbytes/sec] received
  35. Connection Times (ms)
  36. min mean[+/-sd] median max
  37. Connect: 0 0 0.2 0 4
  38. Processing: 0 1 0.5 1 9
  39. Waiting: 0 1 0.5 1 9
  40. Total: 0 1 0.6 1 9
  41. Percentage of the requests served within a certain time (ms)
  42. 50% 1
  43. 66% 1
  44. 75% 1
  45. 80% 1
  46. 90% 2
  47. 95% 2
  48. 98% 2
  49. 99% 3
  50. 100% 9 (longest request)

Also see