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

Improve map performance over long date ranges (month+) #1301

Closed
1 of 4 tasks
nichhk opened this issue Jul 28, 2022 · 7 comments
Closed
1 of 4 tasks

Improve map performance over long date ranges (month+) #1301

nichhk opened this issue Jul 28, 2022 · 7 comments
Assignees
Labels
P-feature: Map Role: Backend Related to API or other server-side work Role: Frontend React front end work Size: 8pt Can be done in 31-48 hours Tech Stack: Old

Comments

@nichhk
Copy link
Member

nichhk commented Jul 28, 2022

Overview

Currently, the frontend will get up to 10k 311 requests/day for each day in the selected date range. If we select the past month, our server does not even work reliably--our frontend makes ~30 requests in parallel, one for each day, and 5-6 requests fail on the server side.

This is to say nothing of a browser's ability to render 100k+ requests in the first place. We'll need to measure that once we get the map to work reliably over a month's worth of request data.

Action Items

  • We are not caching the results for these API calls. We can try to implement caching by adding a cached decorator on get_filtered_requests
  • We can try limiting the max number of requests that we pull for each day; currently, we limit it to 10k, but there are around 4k requests per day, on average. We could try to set the limit to something like 1k.
  • We could throw more resources at the server--more threads, or other things
  • Look into server code to see if anything is particularly slow there

Resources

@nichhk nichhk added Role: Frontend React front end work Role: Backend Related to API or other server-side work Size: 8pt Can be done in 31-48 hours P-feature: Map labels Jul 28, 2022
@nichhk nichhk added this to the v2.1 Launch milestone Jul 28, 2022
@nichhk nichhk self-assigned this Jul 28, 2022
@nichhk
Copy link
Member Author

nichhk commented Aug 1, 2022

@EchoProject what do you think about the first checkbox in the comment above? How important is it to render all the requests for a particular date range in the map?

@nichhk
Copy link
Member Author

nichhk commented Aug 4, 2022

Another idea is to retrieve a limited number of requests on a city-level, but get all NC-level requests when a user selects an NC.

@edwinjue
Copy link
Member

Here's some reading material as promised from today's meeting.

To improve map performance, in theory, we could combine webworkers with mapbox's real-time data-join capability. We could try some branches in dev, collaborate and see if it is a solution that ultimately suits our needs. It's pretty neat to learn about nonetheless

@nichhk
Copy link
Member Author

nichhk commented Oct 21, 2022

@hqasmei, I'd encourage you to read Edwin's post above and see if any of those ideas seem useful in improving the map's load time. But for now, this is a good way to improve the user experience: #1408. Let me know if you have any questions!

@EchoProject EchoProject removed this from the v2.1 Launch milestone Dec 8, 2022
@mc759
Copy link
Member

mc759 commented Dec 13, 2022

Hey @edwinjue and @hqasmei Do you have an update for us on this issue?

Please update:

  • Progress:
  • Blockers:
  • Availability:
  • ETA:

Thanks!

@hqasmei
Copy link
Contributor

hqasmei commented Dec 13, 2022

Edwin correct me if I'm wrong

Progress: Hasn't been worked on yet, because first wanted to fix the #1408 issue first. Personally my option the code should be refactored to composition rather than inheritance to be able to handle this easier. Not sure where this stands in priority, but probably would take longer than #1408 issue

Blockers: Availability, not knowing the priority on this, and discussions on frontend infrastructure change for the Map.jsx and any other file to handle the requests.

Availability: a couple hours a week (~6 hours), evenings and weekends

ETA: Not sure

@hqasmei
Copy link
Contributor

hqasmei commented Jan 2, 2023

Had a meeting with Eric on 12/30/2022. Here are some of my notes:

Problem

  • The way the code is architected, has to wait until it completes getting the data before displaying the data

Potential Solution One (quickest):

  • Have the initial loading screen only display one days worth of data
  • Fast and needs less time
    - Issues: Still will take a while to load if you change the data range to a longer range

Potential Solution Two (longer):

  • Rearchitect the current structure to handle load as response as they come in rather than waiting to all the responses to complete

Updates

  • I emailed Mapbox to see if they have any examples with handling large data loading
  • Copied the section that needs refactoring and renamed it
  • Started refactoring the class component (legacy) into functional component

Questions:

  • What is the expectation?
  • Do you want one weeks of data to load as the data comes in?
  • Do you want to limit the range that can be selected by the user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-feature: Map Role: Backend Related to API or other server-side work Role: Frontend React front end work Size: 8pt Can be done in 31-48 hours Tech Stack: Old
Projects
Status: Done (without merge)
Development

No branches or pull requests

6 participants