Skip to content
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

Change proxy_request to stream reponse instead of accumulating it #29

Open
rtobar opened this issue Sep 18, 2020 · 0 comments
Open

Change proxy_request to stream reponse instead of accumulating it #29

rtobar opened this issue Sep 18, 2020 · 0 comments

Comments

@rtobar
Copy link
Contributor

rtobar commented Sep 18, 2020

During the discussions of #28, @smclay pointed out that the implementation of the proxy_request method in the ngamsServer reads all the incoming response data before sending it back to the original client. This is fine for small amounts of data, but adds latency to the response, and more importantly has the potential of crashing NGAS if the memory limits of the machine are reached.

This issue is to re-implement proxy_request so it streams the incoming data instead of accumulating it in memory. Once this is implemented we could take care of merging the functionality currently being discussed in #28 to avoid some potential code duplication.

rtobar added a commit that referenced this issue Sep 21, 2020
As pointed out in #29, the previous implementation of proxy_request
accumulated the proxy's response before it was sent back to the original
client. This didn't only add latency to the system, but also the
potential of making the process crash because too much memory could end
up being used the NGAS, triggering the OOM killer to kill our process.

In the case of POST requests this streaming functionality was not
included because the underlying functions in the ngamsHttpUtils module
didn't support this. In the case of a GET request this behavior wasn't
implemented only to avoid writing some code and share it with the POST
branch of the code.

This commit finally changes the behavior of proxy_request to stream the
response back to the original client rather than accumulating it in
memory. Now that the missing functionality has been included into
ngamsHttpUtils both GET and POST requests can be streamed, while their
code is mostly shared.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
rtobar added a commit that referenced this issue Sep 22, 2020
As pointed out in #29, the previous implementation of proxy_request
accumulated the proxy's response before it was sent back to the original
client. This didn't only add latency to the system, but also the
potential of making the process crash because too much memory could end
up being used the NGAS, triggering the OOM killer to kill our process.

In the case of POST requests this streaming functionality was not
included because the underlying functions in the ngamsHttpUtils module
didn't support this. In the case of a GET request this behavior wasn't
implemented only to avoid writing some code and share it with the POST
branch of the code.

This commit finally changes the behavior of proxy_request to stream the
response back to the original client rather than accumulating it in
memory. Now that the missing functionality has been included into
ngamsHttpUtils both GET and POST requests can be streamed, while their
code is mostly shared.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant