简体   繁体   English

Spring Boot Keep-Alive Apache 基准测试

[英]Spring boot Keep-Alive apache benchmark

I am trying to use Keep-Alive with Spring Boot, using configuration from: https://stackoverflow.com/a/31461882/5585182我正在尝试将Keep-Alive与 Spring Boot 一起使用,使用以下配置: https : //stackoverflow.com/a/31461882/5585182

# application.properties
server.connection-timeout=60000

When I want to verify with Apache Benchmark connections are not kept alive.当我想使用 Apache Benchmark 进行验证时,连接没有保持活动状态。

ab -v 2 -k -c 1 -n 10 http://localhost:8080/api/test

I get the following output:我得到以下输出:

---
GET /api/test HTTP/1.0
Connection: Keep-Alive
Host: localhost:8080
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Date: Wed, 27 Dec 2017 15:17:54 GMT
Connection: close

As you can see it responded with Connection: close anyone got a clue why this is not working?正如你所看到的,它用Connection: close回应Connection: close有没有人知道为什么这不起作用?

ab is using HTTP/1.0 instead of HTTP/1.1. ab 使用 HTTP/1.0 而不是 HTTP/1.1。 It sends a keep-alive header, so it should still work, as Tomcat is supporting keep-alive with HTTP/1.0:它发送一个 keep-alive 标头,所以它应该仍然有效,因为 Tomcat 支持使用 HTTP/1.0 保持活动:

https://tomcat.apache.org/tomcat-9.0-doc/config/http.html#HTTP/1.1_and_HTTP/1.0_Support https://tomcat.apache.org/tomcat-9.0-doc/config/http.html#HTTP/1.1_and_HTTP/1.0_Support

But I tested it here too.但我也在这里测试过。 No keep-alive with ab but when tested with telnet, it works with SpringBoot/tomcat:不能与 ab 保持连接,但是当使用 telnet 测试时,它可以与 SpringBoot/tomcat 一起使用:

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1
Escape character is '^]'.
GET / HTTP/1.1
Host: www.myhost.de

HTTP/1.1 200 
Cache-Control: no
...
Connection still open

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM