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

[majora] Stream large API responses to clients #34

Closed
SamStudio8 opened this issue Mar 15, 2021 · 3 comments
Closed

[majora] Stream large API responses to clients #34

SamStudio8 opened this issue Mar 15, 2021 · 3 comments

Comments

@SamStudio8
Copy link
Member

Several of the full data set serialisations are growing at an alarming rate and we'll likely soon hit the limit of what we can safely send through to clients. These interfaces are currently only used by myself for inbound and outbound pipelines (notably the largest serialisations are for generating the Asklepian dataset). These endpoints should stream their reply to clients with StreamingHttpResponse.

@SamStudio8
Copy link
Member Author

SamStudio8 commented Mar 23, 2021

I've implemented a draft StreamingHttpResponse for get_task in Ocarina and Majora and the performance is absolute garbage. I've been waiting over an hour to stream the Asklepian payload. I'll try the FileResponse tomorrow.

@SamStudio8
Copy link
Member Author

I've skipped bothering with FileResponse as it's unlikely to be suited for our needs. Instead, I've read up about our options specifically with the S3 backend, it turns out we can use the S3 API to generate very short lived temporary access URLs for resources in our Celery result bucket. SamStudio8/majora2@8d504b9 takes advantage of this, generating an URL for a valid result, opening it in situ with requests with stream=True and then emitting the response.raw through to StreamingHttpResponse. It's several orders of magnitude quicker and doesn't require heavy memory usage on Majora, seems like a neat solution. Will play more with it later this week.

@SamStudio8
Copy link
Member Author

Bumping to backlog #62 as nothing seems to have exploded yet

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