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
| Mode | Description | Use case |
|---|---|---|
| Active-active | Messages published in any region are replicated to all others | Global applications with local publish and subscribe |
| Active-passive | One region publishes, others receive replicas | Disaster 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
| Classification | Description | Replication rules |
|---|---|---|
| Standard | Non-sensitive business data | Replicates to any consented region |
| Sensitive | PII, financial data | Requires additional compliance checks |
| Restricted | Regulated data (GDPR, HIPAA) | Region-locked by default, requires explicit override |
Ordering guarantees
| Scope | Guarantee |
|---|---|
| Within a region | Strict publish order maintained |
| Across regions | Causal ordering preserved (messages from the same publisher arrive in order) |
| Global | No 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:
| Route | Typical 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 case | How cross-region messaging helps |
|---|---|
| Global applications | Users interact with local instances. Events replicate globally. |
| Compliance | Keep data in required jurisdictions with consent-based replication |
| Disaster recovery | Passive replicas in standby regions, ready for failover |
| Multi-region processing | Process events in the region closest to the compute |
| B2B integrations | Share 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?