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

Lambda response error with large requests #35

Closed
zacdezgeo opened this issue Aug 28, 2024 · 3 comments
Closed

Lambda response error with large requests #35

zacdezgeo opened this issue Aug 28, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@zacdezgeo
Copy link
Collaborator

Describe the bug

When making a request to the summary endpoint with 8 fields or more, the API returns an internal server error.

To Reproduce

num_fields = 8
fields_to_test = available_fields[:num_fields]

try:
    benchmark(fields_to_test, delay_before_request=0)  # Warm start
except Exception as e:
    print(f"Error with {num_fields} fields: {fields_to_test}")
    print(f"Error message: {str(e)}")

Returns:

Error with 8 fields: ['sum_pop_2020', 'ogc_fid', 'sum_pop_f_0_2020', 'sum_pop_f_10_2020', 'sum_pop_f_15_2020', 'sum_pop_f_1_2020', 'sum_pop_f_20_2020', 'sum_pop_f_25_2020']
Error message: Failed to get summary: {"message":"Internal Server Error"}

After digging into the Lambda logs, we are hitting hard Lambda limits around the response size of 6 MB.

Expected behavior

I'm unsure how often actual users will requests more than 8 fields. That being said, we should have a clear path to support these use cases either by communicating these limits when they occur and proposing an alternative approach, or we adapt something in the API to return the expected response directly.

@zacdezgeo zacdezgeo added the bug Something isn't working label Aug 28, 2024
@zacdezgeo zacdezgeo self-assigned this Aug 28, 2024
@zacdezgeo zacdezgeo changed the title Lambda response too large with 8 or more fields Lambda response error with large requests Aug 28, 2024
@zacdezgeo
Copy link
Collaborator Author

@bpstewar @andresfchamorro; opened a lot of related issues here, but here's a summary of the solution I am proposing:

We could also dig into some other options afterward such as:

  • pagination of the response: might not be feasible given a user will likely want the entire data requested
  • aggregating data to lower resolution hexagon levels

@zacdezgeo
Copy link
Collaborator Author

In #32, @vincentsarago added compression, and the difference is notable. We deployed a new API version, using the Kenya AOI, and requesting a point geometry, a user can retrieve 28 fields before hitting the size limitation. Without the point geometry, a user can retrieve up to 32 fields.

The same considerations above still apply, but we might already be within the acceptable constraints for user requests. cc: @andresfchamorro @bpstewar

@alukach
Copy link
Collaborator

alukach commented Sep 5, 2024

Closed by #45

@alukach alukach closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants