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
Asynchronously stream requests to upstream when possible [feature] #251
Conversation
stream_request_body(client_ref, upstream_request, conn) | ||
|
||
{:error, reason} -> | ||
{:error, reason} # TODO: return 502 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO found
def dispatch(%UpstreamRequest{} = upstream_request, %Conn{method: method} = conn) do | ||
upstream_url = UpstreamRequest.to_upstream_url!(upstream_request) | ||
|
||
# TODO: find better solution that dropping this for broken HTTPBin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO found
stream_request_body(client_ref, upstream_request, conn) | ||
|
||
{:error, reason} -> | ||
{:error, reason} # TODO: return 502 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a TODO tag in a comment: # TODO: return 502
def dispatch(%UpstreamRequest{} = upstream_request, %Conn{method: method} = conn) do | ||
upstream_url = UpstreamRequest.to_upstream_url!(upstream_request) | ||
|
||
# TODO: find better solution that dropping this for broken HTTPBin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a TODO tag in a comment: # TODO: find better solution that dropping this for broken HTTPBin
|
||
defp put_response_headers(conn, headers) do | ||
headers | ||
|> Enum.reduce(conn, fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a function call when a pipeline is only one function long
Ebert has finished reviewing this Pull Request and has found:
But beware that this branch is 4 commits behind the You can see more details about this review at https://ebertapp.io/github/Nebo15/annon.api/pulls/251. |
Old implementation did buffering for any data that comes in and out of the gateway, which produce several drawbacks: 1. Memory usage was high 2. Network I/O had many peaks (read full body and then send it to upstream) 3. Higher latency (now upstream accepts connection almost instantly) 4. It was impossible to send large files, because they consumed lots of memory on gateway side. Current implementation will buffer only requests with application/json content-type, allowing Logger to save them. Future plans: - Find smarter way to log requests (by dropping secure data). - Use feature flags to async proxying JSON data.
22e699b
to
b279358
Compare
Old implementation did buffering for any data that comes in and out of
the gateway, which produce several drawbacks:
upstream)
memory on gateway side.
Current implementation will buffer only requests with application/json
content-type, allowing Logger to save them.
Future plans: