Skip to main content
npayload is launching soon.
npayloadDocs
Concepts

Cross-region messaging

Multi-instance channels with geo-replication and data residency controls

Cross-region messaging lets channels span multiple npayload instances. Messages published in one region are automatically replicated to other regions with guaranteed delivery, enabling global applications while respecting data residency requirements.

How it works

When a channel is configured for cross-region messaging, npayload maintains a transmission queue between instances. Messages are published locally, queued for transmission, and delivered to remote instances with exactly-once guarantees.

Instance US-East                    Instance EU-West
┌──────────────────┐                ┌──────────────────┐
│  Channel: events │                │  Channel: events │
│                  │   Transmission │                  │
│  Publish here    │───────────────>│  Delivered here  │
│                  │   Queue        │                  │
│  Subscribe here  │<───────────────│  Publish here    │
└──────────────────┘                └──────────────────┘

Subscribers in each region receive messages from both local and remote publishers without any code changes.

Replication modes

ModeDescriptionUse case
Active-activeMessages published in any region are replicated to all othersGlobal applications with local publish and subscribe
Active-passiveOne region publishes, others receive replicasDisaster recovery, read replicas

Active-active

All instances both publish and receive messages. Subscribers in every region see the full stream.

const channel = await npayload.channels.create({
  name: 'global-events',
  replication: {
    mode: 'active-active',
    regions: ['us-east', 'eu-west', 'ap-south'],
  },
});

Active-passive

One region is the source. Other regions receive replicated messages but do not publish back.

const channel = await npayload.channels.create({
  name: 'config-updates',
  replication: {
    mode: 'active-passive',
    sourceRegion: 'us-east',
    replicaRegions: ['eu-west', 'ap-south'],
  },
});

Data residency

Cross-region messaging includes built-in data residency controls. Data does not flow to a region unless both the source and destination organisations have given explicit consent.

// Grant consent for data to flow to EU
await npayload.federation.grantConsent({
  channel: 'events',
  targetRegion: 'eu-west',
  dataClassification: 'standard', // or 'sensitive', 'restricted'
});

Cross-region replication requires explicit data residency consent from both the source and destination organisations. Messages are not transmitted until consent is confirmed at both ends.

Data classification

ClassificationDescriptionReplication rules
StandardNon-sensitive business dataReplicates to any consented region
SensitivePII, financial dataRequires additional compliance checks
RestrictedRegulated data (GDPR, HIPAA)Region-locked by default, requires explicit override

Ordering guarantees

ScopeGuarantee
Within a regionStrict publish order maintained
Across regionsCausal ordering preserved (messages from the same publisher arrive in order)
GlobalNo global total order. Use message groups with groupKey for strict ordering across regions.

For use cases that require strict global ordering, use message groups with a groupKey. Messages with the same group key are delivered in publish order regardless of which region they originate from.

Latency considerations

Cross-region delivery adds network latency between instances. Plan for:

RouteTypical added latency
Same continent (e.g., US-East to US-West)30 to 80ms
Cross-continent (e.g., US-East to EU-West)80 to 150ms
Long-haul (e.g., US-East to AP-South)150 to 300ms

Local subscribers always receive messages at local speed. The added latency only applies to cross-region delivery.

Instance discovery

npayload instances automatically discover each other. When a new instance is provisioned, it registers with the network and becomes available for cross-region channels without manual configuration.

// List available instances and regions
const instances = await npayload.federation.listInstances();

instances.forEach(instance => {
  console.log(`${instance.region}: ${instance.status}`);
});

Use cases

Use caseHow cross-region messaging helps
Global applicationsUsers interact with local instances. Events replicate globally.
ComplianceKeep data in required jurisdictions with consent-based replication
Disaster recoveryPassive replicas in standby regions, ready for failover
Multi-region processingProcess events in the region closest to the compute
B2B integrationsShare channels between organisations in different regions

Next steps

  • Channels to understand channel types and cross-instance channels
  • Marketplace to discover and share channels across organisations
  • Architecture for an overview of the global network

Was this page helpful?

On this page