Skip to content

Send “Connection” headers only when keepAlive == false #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2020

Conversation

fabianfett
Copy link
Member

Motivation

  • after some investigation I discovered that the lambda control plane, does not expect a request header "Connection" = "keep-alive" and does not send a response header "Connection" = "keep-alive"
  • http/1.1 specifies in RFC 2616, Section 8.1.2:

[...] unless otherwise indicated, the client SHOULD assume that the server will maintain a persistent connection, even after error responses from the server.

Further, for the response it defines:

An HTTP/1.1 client MAY expect a connection to remain open, but would decide to keep it open based on whether the response from a server contains a Connection header with the connection-token close. In case the client does not want to maintain a connection for more than that request, it SHOULD send a Connection header including the connection-token close.

  • since we have been expecting "Connection" = "keep-alive" in the response until now, we where tearing down our connection after every request

Changes

  • We only send the "Connection" = "close" header if we don't want to keep the connection alive.
  • The MockServer does send the "Connection" = "close" header only if it want's to close the connection
  • We check if the response is HTTP/1.1 to close the connection otherwise.

@fabianfett fabianfett changed the title Removed “Connection” headers Send “Connection” headers only when keepAlive == false Mar 9, 2020
@fabianfett
Copy link
Member Author

This fixes: #25.

@fabianfett
Copy link
Member Author

fabianfett commented Mar 9, 2020

Performance

It looks like we are saving an average of 50ms with this improvement.

master:
Screenshot 2020-03-09 at 14 02 25

connection-pooling:
Screenshot 2020-03-09 at 14 21 23

Taking this into account we're currently only outperformed by Go and C#.

@fabianfett fabianfett requested a review from tomerd March 9, 2020 13:29
Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wonderful great catch

@tomerd tomerd merged commit df4e247 into master Mar 9, 2020
@tomerd tomerd deleted the connection-pooling branch March 10, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants