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

Hopefully preventing server crashes from running out of memory #3276

Merged
merged 3 commits into from
Jun 23, 2023

Conversation

misaugstad
Copy link
Member

(hopefully) fixes #3224

This PR improves the performance of two of our biggest API calls: /adminapi/labels/cvMetadata and /attributesWithLabels. Instead of trying to convert all of the labels to JSON in one go like we had before, which forces us to load everything into memory, we are now writing 10k labels at a time to JSON files. We can then transfer the JSON files with much less memory.

I tested this out on my dev environment by artificially lowering the amount of memory available to Java so that I could test with smaller datasets. This seems to be solving the issue. Will only know for sure once it is on production.

Additionally, I only did this with two API endpoints to start. If we determine that the method is working, it's pretty easy to add that workflow to other endpoints!

In the saved file we include the timestamp for when it was created, which will allow us to serve multiple concurrent API requests for the same API.

Things to check before submitting the PR
  • I've written a descriptive PR title.
  • I've added/updated comments for large or confusing blocks of code.

@misaugstad misaugstad self-assigned this Jun 23, 2023
@misaugstad
Copy link
Member Author

Slight correction: I did this for a third API endpoint too, the /attributes API!

@misaugstad misaugstad merged commit 02892fc into develop Jun 23, 2023
@misaugstad misaugstad deleted the 3224-api-large-requests-hogging-memory branch June 23, 2023 18:29
@misaugstad misaugstad mentioned this pull request Jul 6, 2023
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.

Large API requests causing Seattle server to go down
1 participant