Jboot 性能测试

测试方式

通过 apache benchmark 工具进行压力测试

测试环境

  • JDK信息:

    • java version “1.8.0_25”
    • Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
    • Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
  • 硬件信息

    • 处理器:2.3 GHz Intel Core i7
    • 内存:16 GB 1600 MHz DDR3
    • 系统:macOS 10.13.4 (17E202)
    • 硬件:MacBook Pro (Retina, 15-inch, Late 2013

测试代码

测试代码:

  1. @RequestMapping("/")
  2. public class HelloDemo extends JbootController {
  3. public static void main(String[] args) {
  4. Jboot.setBootArg("jboot.mode","product");
  5. Jboot.run(args);
  6. }
  7. public void index() {
  8. renderText("hello jboot ...");
  9. }
  10. }

代码含义:

  • 默认使用 undertow 服务器
  • 把配置设置为生产模式,生产模式不会打印调试日志

测试结果

模拟10个并发,10000次访问:

ab -c10 -n10000 http://localhost:8080/

  1. This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
  2. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  3. Licensed to The Apache Software Foundation, http://www.apache.org/
  4. Benchmarking localhost (be patient)
  5. Completed 1000 requests
  6. Completed 2000 requests
  7. Completed 3000 requests
  8. Completed 4000 requests
  9. Completed 5000 requests
  10. Completed 6000 requests
  11. Completed 7000 requests
  12. Completed 8000 requests
  13. Completed 9000 requests
  14. Completed 10000 requests
  15. Finished 10000 requests
  16. Server Software:
  17. Server Hostname: localhost
  18. Server Port: 8080
  19. Document Path: /
  20. Document Length: 15 bytes
  21. Concurrency Level: 10
  22. Time taken for tests: 0.716 seconds
  23. Complete requests: 10000
  24. Failed requests: 0
  25. Total transferred: 2330000 bytes
  26. HTML transferred: 150000 bytes
  27. Requests per second: 13970.07 [#/sec] (mean)
  28. Time per request: 0.716 [ms] (mean)
  29. Time per request: 0.072 [ms] (mean, across all concurrent requests)
  30. Transfer rate: 3178.74 [Kbytes/sec] received
  31. Connection Times (ms)
  32. min mean[+/-sd] median max
  33. Connect: 0 0 0.1 0 1
  34. Processing: 0 0 0.1 0 3
  35. Waiting: 0 0 0.1 0 3
  36. Total: 0 1 0.1 1 4
  37. Percentage of the requests served within a certain time (ms)
  38. 50% 1
  39. 66% 1
  40. 75% 1
  41. 80% 1
  42. 90% 1
  43. 95% 1
  44. 98% 1
  45. 99% 1
  46. 100% 4 (longest request)