Open weierophinney opened 4 years ago
I can confirm the slow speed for the php:apache container. Using the php internal server or a nginx container I didn't encounter this issue. Also forcing a http 1.0 return does fix the slow apache bench speed.
curl request is HTTP/1.0, but zend-expressive has HTTP/1.1 response.
This is interesting though. I didn't know this and searched for it.
RFC 2616: Applications that are at least conditionally compliant with this specification SHOULD use an HTTP-Version of "HTTP/1.1" in their messages, and MUST do so for any message that is not compatible with HTTP/1.0. For more details on when to send specific HTTP-Version values, see RFC 2145.
RFC 2145 An HTTP server SHOULD send a response version equal to the highest version for which the server is at least conditionally compliant, and whose major version is less than or equal to the one received in the request. An HTTP server MUST NOT send a version for which it is not at least conditionally compliant. A server MAY send a 505 (HTTP Version Not Supported) response if cannot send a response using the major version used in the client's request.
An HTTP server MAY send a lower response version, if it is known or suspected that the client incorrectly implements the HTTP specification, but this should not be the default, and this SHOULD NOT be done if the request version is HTTP/1.1 or greater.
So, if the client sends an HTTP/1.0 request, either an HTTP/1.0 response or HTTP/1.1 is acceptable, but HTTP/1.1 is preferred.
Enabling the HTTP KeepAlive feature for apache bench gave me fast results as with the internal php server and nginx:
ab -k -c 1 -n 1 http://localhost:8080/
Originally posted by @geerteltink at https://github.com/zendframework/zend-expressive/issues/502#issuecomment-318885485
curl request is HTTP/1.0, but zend-expressive has HTTP/1.1 response.
Next, I tried ApacheBench.
Very very slow.
ApacheBench expect active close of server, but server does not close until KeepAliveTimeout seconds.
This problem can solved by fix response protocol version based on request protocol version.
Originally posted by @ngyuki at https://github.com/zendframework/zend-expressive/issues/502