-
Notifications
You must be signed in to change notification settings - Fork 140
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
Feat: Multi-tiered cache for aws #699
Conversation
🦋 Changeset detectedLatest commit: 2f06186 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts
Outdated
Show resolved
Hide resolved
packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts
Outdated
Show resolved
Hide resolved
packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts
Outdated
Show resolved
Hide resolved
packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts
Outdated
Show resolved
Hide resolved
packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts
Outdated
Show resolved
Hide resolved
}, | ||
async set(key, value, isFetch) { | ||
const revalidatedAt = Date.now(); | ||
await S3Cache.set(key, value, isFetch); |
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.
use Promise.allSetlled()
to parallelize?
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.
This is on purpose actually, given how it works we have 3 choice for handling write error failure:
- We could do as it is here, set on S3, then set on DDB, which means that if it fails in DDB, instance that don't have local cache will work as expected. ( But those with local cache will still serve outdated data )
- We could first write in DDB and then S3, which means that in case S3 fail, new instance will fetch outdated data, and existing instance will fetch outdated data.
- Or we could use
allSettled
but then the behavior will be unpredictable in case one of the 2 fails
I should have added a comment explaining this. One other thing we could do is to let the user chose the behavior they'd want.
I'll update and merge the PR tomorrow in case we should chose another option
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.
Oh you're right 👍
Thanks for explaining very clearly
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.
LGTM, a few nits
Co-authored-by: Victor Berchet <[email protected]>
As discussed in #621.
The new incremental cache work this way :
It requires both an S3 Bucket and a DynamoDb table
It uses the same env variable as both the default S3 and Tag cache as well as 2 new optional env
OPEN_NEXT_LOCAL_CACHE_TTL
(default is 0) andOPEN_NEXT_LOCAL_CACHE_SIZE
(default is 1000, in nbr of entries)Warning
This implementation is NOT strongly consistent
If some error happens while writing to DDB, some instance may use outdated local data