-
Notifications
You must be signed in to change notification settings - Fork 71
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
[card-cache-service] optimize caching #417
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
valayDave
force-pushed
the
oss/card-optimization
branch
from
February 28, 2024 18:33
61fdee2
to
2a47ee4
Compare
# Core Changes: - created a background service that will poll all the cards/dataupdate for individual tasks - The background service will run one process per taskspec for a small amount of time specified via the ENV vars - This service will be launched when cards are requested. - The reading of cards will be happenning directly from cache and the reads will be "best-effort" - API routes to get a card / list cards will have async-waits until the cache is updated. - The new optimization will require the MF GUI to also be up-to-date with the new server. - Uses a new optimized mf client. - Metaflow UI which keeps best effor polling new cards every 0.5 seconds can work best with new server. - async routines that will clean up the cache and remove completed async-processes - removed dead code which will no longer be used. # Why not use the existing cache client: - The way the existing cache client works, it loads the entire `Task` / `Card` object in memory and then returns the html/data from it. - This is inefficient because load the `Card` object does datastore list calls which are time expensive. - Once the path to the cards/data-updates has been found, getting the actual object is very fast. - For example, listing cards, takes ~ 1-2 seconds, but getting the actual card once the path is resolved takes ~ 10 milliseconds. - The current cache actions are "stateless" meaning, that once the action is done, the previous state is lost when a new action is called. - This stateless nature is not good for cards, where the data may change a lot more frequently but paths won't change. - The new cache service retrives the object paths once and then keeps updating them until the background-process finishes execution. - This approach improves latency drastically # Configuration Options: - `CARD_CACHE_PROCESS_NO_CARD_WAIT_TIME` : How long should the process wait for a card to be available before it exits - `CARD_CACHE_PROCESS_MAX_UPTIME` : The max duration the process should run - `CARD_CACHE_CARD_LIST_POLLING_FREQUENCY` : How frequently should the process poll for listing new cards - `CARD_CACHE_CARD_UPDATE_POLLING_FREQUENCY` : How frequently should the process poll for the card html content - `CARD_CACHE_DATA_UPDATE_POLLING_FREQUENCY` : How frequently should the process poll for the data updates - `CARD_CACHE_DISK_CLEANUP_INTERVAL`: The interval at which the cached cards are stored should be cleaned up - `CARD_API_HTML_WAIT_TIME`: the timeperiod the card HTML retrieval API will max busy wait for the card to be ready before timing out and resulting in null response.
valayDave
force-pushed
the
oss/card-optimization
branch
from
February 28, 2024 18:38
2a47ee4
to
3e7d0e0
Compare
saikonen
reviewed
Mar 4, 2024
|
||
async def _get_latest_return_code(process: Process): | ||
with contextlib.suppress(asyncio.TimeoutError): | ||
await asyncio.wait_for(process.wait(), 1e-6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some notes for clarity.. so the combination of wait_for
and async process.wait()
with a minimal timeout in effect acts in a similar way as process.poll()
from the synchronous implementation?
saikonen
approved these changes
Mar 11, 2024
valayDave
added a commit
to Netflix/metaflow-ui
that referenced
this pull request
Mar 14, 2024
- make refresh interval default smaller - remove timeout code block in card load - leveraging the `created_on` timestamps in dataupdates to discard stale data - handle case of idle refresh - comments on whats changed. - compatible with new changes introduced in Netflix/metaflow-service#417
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Core Changes:
Why not use the existing cache client:
Task
/Card
object in memory and then returns the html/data from it.Card
object does datastore list calls (which are time expensive).Configuration Options:
CARD_CACHE_PROCESS_NO_CARD_WAIT_TIME
: How long should the process wait for a card to be available before it exitsCARD_CACHE_PROCESS_MAX_UPTIME
: The max duration the process should runCARD_CACHE_CARD_LIST_POLLING_FREQUENCY
: How frequently should the process poll for listing new cardsCARD_CACHE_CARD_UPDATE_POLLING_FREQUENCY
: How frequently should the process poll for the card html contentCARD_CACHE_DATA_UPDATE_POLLING_FREQUENCY
: How frequently should the process poll for the data updatesCARD_CACHE_DISK_CLEANUP_INTERVAL
: The interval at which the cached cards are stored should be cleaned upCARD_API_HTML_WAIT_TIME
: the time period the card HTML retrieval API will max busy wait for the card to be ready before timing out and resulting in null response.TODOs