SimpleNS LogoDocs

Multi-Provider Channel Routing

Configure multiple plugins per channel and multiple credential-isolated provider instances per plugin with cascading error and rate-limit fallbacks.


Overview

One of SimpleNS's core strengths is separating Channels, Plugins, and Provider Instances:

  • Channel (e.g., email, sms, whatsapp): What kind of notification you are sending.
  • Plugin (e.g., @simplens/resend, @simplens/nodemailer-gmail): An npm package that knows how to talk to a specific service.
  • Provider Instance (e.g., gmail-1, gmail-2, gmail-3): A configured instance of a plugin with its own encrypted credentials, priority, and rate limits.

Because each provider instance has its own credentials and token-bucket rate limit, you can attach multiple accounts of the same plugin (like two Resend API keys or multiple Gmail accounts) and multiple different plugins to the same channel, then wire them together with Channel Routing.


Real-World Use Case: Multiple Accounts as Fallbacks

Suppose your free/tier Gamil account (gmail-1) has a daily rate limit of 500 emails per day, or occasionally returns an error. With SimpleNS, you can:

Install Plugins Once In Dashboard → Plugins (/plugins), install @simplens/nodemailer-gmail.

Create Multiple Provider Instances

  • Create gmail-1, gmail-2 and gmail-3 from @simplens/nodemailer-gmail plugin and configure 3 different SMTP credentials.

Configure Channel Routing In Channel Routing for email:

  • Default Provider: gmail-1
  • Fallback Chain (fallback_provider_ids): gmail-2 → gmail-3
  • Kafka Partitions: 6 (default)

Your application keeps sending the exact same POST /api/notification request with "channel": ["email"]—SimpleNS handles failover automatically with zero code changes.


How Cascading Failover Works

SimpleNS protects delivery across three failure modes:

ScenarioWhat SimpleNS Does
Provider hits rate limitBefore dispatch, SimpleNS checks token buckets across [default_provider_id, ...fallback_provider_ids] in order. If gmail-1 is rate-limited, SimpleNS immediately fails over to gmail-2 (or gmail-3) and delivers without waiting. It only delays the notification if all providers in the cascade are rate-limited.
Non-retryable error (e.g., invalid key / 4xx rejection)SimpleNS immediately cascades through the remaining fallback_provider_ids in order (checking rate limits and schema compatibility) until one succeeds.
Retryable error (e.g., 5xx / network timeout)SimpleNS retries the current provider with exponential backoff. Once retry_count + 1 > MAX_RETRY_COUNT, it hands off asynchronously to the next provider in fallback_provider_ids with a fresh retry budget (retry_count = 0).

Explicit provider Override Rules

When sending a notification, you can optionally pass provider: ["<provider-id>"] in the request body:

  • Only providers configured in that channel's routing (default_provider_id or fallback_provider_ids) are eligible.
  • If you pass a provider ID that is not in that channel's routing (even if the provider is enabled and active), SimpleNS does not use it and routes to default_provider_id instead.
  • If the explicit provider is in fallback_provider_ids, SimpleNS starts there and cascades only to providers after it in the chain.

Zero-Restart Sync

Every provider instance and channel routing update is saved in MongoDB (with encrypted credentials) and hot-reloaded across all API, worker, and processor containers via Redis Pub/Sub.

On this page