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

read (& send) JSONs as streams where possible #825

Merged
merged 1 commit into from
Nov 25, 2019
Merged

Conversation

jameshadfield
Copy link
Member

Background: The auspice server (and the nextstrain.org server, but that's not part of this PR) read JSON data into memory during getDataset request handling and then send the data as a response to the client. For all non-v1 JSONs these data are passed through unmodified by the server.

This PR shifts to reading in data as a stream and piping this data to the response (which is also a stream). This results in some nice memory savings (green vs orange lines):

image

_H3N2 datasets, all v2 JSONs, no tip-frequencies_

v2 JSONs are designed so that no modifications
need to be made by the server. This allows us to
read as a stream and stream the response, saving
memory on the server.
@trvrb
Copy link
Member

trvrb commented Nov 25, 2019

Awesome!

Copy link
Contributor

@huddlej huddlej left a comment

Choose a reason for hiding this comment

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

This makes sense and seems like a great performance improvement.

@jameshadfield jameshadfield merged commit cc8820b into master Nov 25, 2019
@jameshadfield jameshadfield deleted the streams branch November 25, 2019 19:53
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