Skip to content

Conversation

@luminitavoicu
Copy link
Contributor

@luminitavoicu luminitavoicu commented Nov 24, 2020

Signed-off-by: Luminita Voicu lumivo@amazon.com

Reason for This PR

The micro-http server holds a HashMap of all opened connections and has a limit for the number of active connections at the same time. The requests_unixsocket python package, used by the testing framework for issuing API requests, opens a new connection for every API call and keeps it alive even after receiving the response from the server. These sockets are kept inside the connections HashMap and might very easily end up in exceeding the micro-http's limit, triggering a 503 response from the server.

Description of Changes

To prevent this from happening, the pool_connections argument was set to 10, consistent with the maximum number of open connections allowed: MAX_CONNECTIONS. Attempts to issue a new API request, after this limit has been reached, implies closing and removing the least recently used open fd and then adding a newly opened connection to the pool.

  • This functionality can be added in rust-vmm.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any newly added unsafe code is properly documented.
  • Any API changes are reflected in firecracker/swagger.yaml.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

@acatangiu
Copy link
Contributor

Good catch!

Can you please add detail to the commit msg and the PR description around what the newly added behavior is? Without diving deep into the code, I for one can't tell how the changes in this PR should affect behavior.

serban300
serban300 previously approved these changes Nov 25, 2020
The micro-http server holds a HashMap of all open connections and
has a limit for the number of active connections at the same time.
The `requests_unixsocket` python package, used by the testing
framework for issuing API requests, opens a new connection for every
API call and keeps it alive even after receiving the response from
the server. These sockets are kept inside the connections HashMap
and might very easily end up in exceeding the micro-http's limit,
triggering a '503' response from the server.
To prevent this from happening, the `pool_connections` argument was
set to 10, consistent with the maximum number of open connections
allowed. Attempts to issue a new API request, after this limit has
been reached, implies closing and removing the least recently used
open fd and then adding a newly opened connection to the pool.

Signed-off-by: Luminita Voicu <lumivo@amazon.com>
@luminitavoicu luminitavoicu merged commit f85188f into firecracker-microvm:master Nov 25, 2020
@luminitavoicu luminitavoicu deleted the connections_no branch November 25, 2020 15:08
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.

4 participants