Skip to content

Conversation

conico974
Copy link
Collaborator

This PR adds yet another layer of replication for the sharded tag cache, this time aiming at reducing the latency worldwide by replicating the data tag in multiple regions

Copy link

changeset-bot bot commented Mar 25, 2025

🦋 Changeset detected

Latest commit: 0320485

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Minor

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

Copy link

pkg-pr-new bot commented Mar 25, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@500

commit: 0320485

return regionalReplicasInAllRegions;
}

getClosestRegion() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get better accuracy on this one by using country or colo if needed

@conico974 conico974 force-pushed the feat/regional-replication branch from 5c14d74 to 02b441f Compare March 28, 2025 17:22
* Default region to use for the regional replication when the region cannot be determined
* @default "enam"
*/
defaultRegion?: AllowedDurableObjectRegion;
Copy link
Contributor

@vicb vicb May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be used when enableRegionalReplication is false?

At least it would be nice to clarify the comment on when exactly this is used.

If we decide to use it only when enableRegionalReplication is true then we can use

regionalReplicationOptions?: {
  defaultRegion: AllowedDurableObjectRegion
}

to be consistent with shardReplicationOptions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to go with the regionalReplicationOptions params to keep it consistent

@conico974 conico974 force-pushed the feat/regional-replication branch from 02b441f to ad3e971 Compare May 25, 2025 13:21
@vicb
Copy link
Contributor

vicb commented May 26, 2025

Doc PR: opennextjs/docs#155

@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@opennextjs/cloudflare": patch
"@opennextjs/cloudflare": minor

*
* This will increase the number of durable objects created, as each shard will be replicated in all regions.
*/
regionalReplicationOptions?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we do not really need "Options"?

Suggested change
regionalReplicationOptions?: {
regionalReplication?: {

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

A couple minor comments

@conico974 conico974 merged commit 5142788 into opennextjs:main May 26, 2025
7 checks passed
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.

2 participants