Social Notification Delivery Architecture: Events, Inboxes, and Push

Updated on
9 min read

Likes, comments, follows, and mentions look like small features, but each can trigger several independent actions: persist an in-app notification, update unread counts, send a push alert, and feed an activity or analytics view. A notification system built around asynchronous events can separate those tasks from the user action without treating a broker or push provider as a guarantee that a person saw the alert.

This guide focuses on notification delivery architecture: where events come from, how recipients and preferences are applied, how to make processing safe to retry, and when to choose push, pull, or both.

What Is Social Notification Delivery Architecture?

It is the set of services and data flows that turn a confirmed product action into a notification that can be read in an inbox or delivered over a channel such as mobile push, email, or an in-app connection.

The originating event describes a fact, such as CommentCreated. A notification consumer interprets that fact for recipients, applies product rules and preferences, and creates one or more delivery records. The event is not itself a notification: the same event can be irrelevant to one recipient, suppressed for another, and rendered differently across channels.

The Problem: Separate Product Work from Delivery

Sending notifications inline with a like or comment request couples the user-facing action to every downstream dependency. A slow push gateway can increase request latency; a gateway outage can fail an otherwise successful comment; and one synchronous call per recipient can make a popular post expensive to process.

Moving delivery to a queue removes that synchronous dependency, but introduces failure boundaries of its own. A service can commit a comment and crash before publishing its event. A broker can redeliver an event after a consumer has already written an inbox item. A push provider can accept a request while the device is offline, and a response from the provider does not mean the user opened the notification.

The design therefore needs two distinct outcomes:

  • Durable product state: a notification record that the recipient can retrieve later.
  • Best-effort delivery: attempts to draw attention to that record through push, email, or another channel.

How It Works: Architecture and Event Flow

A robust flow separates the business transaction, notification creation, and channel delivery:

Client action
  -> application service: commit business change + outbox event
  -> outbox relay
  -> broker or durable queue
  -> notification consumer: resolve recipients and preferences
  -> inbox database + channel delivery jobs
  -> push/email workers -> FCM, APNs, or another provider
  -> client fetches the durable inbox

The business service writes its data change and an outbox row in the same local database transaction. A relay later publishes that row. This avoids the dual-write gap where a database commit succeeds but a separate broker publish is lost. The transactional outbox pattern explains why the relay can still publish more than once, which is why consumers need deduplication.

The notification consumer validates the event contract, resolves recipients from current relationship data, checks mute, block, and channel preferences, and writes inbox records. It can enqueue channel-specific jobs after durable inbox creation. A worker sends a minimal push payload, while the client fetches full details from the authenticated inbox API. For iOS, Apple’s remote notification server guide describes the provider-server-to-APNs-to-device path. Firebase’s FCM server sending guide documents sending through the Firebase Admin SDK.

Keep transport adapters separate from notification policy and domain rules. A ports-and-adapters architecture helps keep broker and provider clients replaceable without spreading their APIs through product logic.

Components and Delivery Patterns

Pattern How it works Best fit Main trade-off
Synchronous delivery The request handler calls channel providers directly A small prototype with low fan-out and noncritical alerts Couples request latency and availability to providers
Broker with channel queues Events are consumed asynchronously and jobs are routed to independent workers Separate scaling and retry policies for push, email, and other channels Requires broker operations, deduplication, and lag monitoring
Durable inbox with pull The app stores notification records; clients fetch them when opened History, unread state, and users who are offline Does not by itself alert an inactive user
Hybrid inbox and push hint The inbox is durable; push carries a pointer or small preview Most social products that need both history and timely alerts Provider acceptance is not proof of device display or user attention
Fan-out on read Store an activity once and assemble recipient views at query time Very large audiences where per-recipient writes are costly Reads and ranking become more complex and can be less predictable

These approaches can be combined. A common starting point is a durable inbox plus asynchronous push jobs, with fan-out-on-read reserved for unusually large audiences. A broker such as Kafka, RabbitMQ, or a managed service such as Amazon SNS is a transport choice, not a substitute for the inbox or the delivery policy.

Real-World Use Cases

  • Direct interactions: A comment or mention can create a durable inbox item and a push job for the recipient, subject to mute and privacy settings.
  • High-volume activity: Likes on a popular post can be coalesced into a summary such as “Several people liked your post” rather than producing one push per action.
  • Followed creators or groups: Resolve recipients from subscriptions and apply per-user frequency limits; for a very large audience, consider computing recipient feeds at read time.
  • Unread reminders and digests: Scheduled workers can summarize eligible inbox items without changing the source events or duplicating the underlying records.
  • Cross-channel delivery: Email and push can have separate consent, retry, and suppression rules while referencing the same notification identity.

Practical Considerations

Define a Small, Stable Event Contract

Events should describe what happened and include enough identifiers for consumers to resolve context. Avoid copying full user profiles or private message bodies into a broker topic when an ID and an authorized lookup will do.

{
  "id": "evt_01JEXAMPLE",
  "type": "CommentCreated",
  "occurred_at": "<ISO-8601 UTC timestamp>",
  "actor_id": "user_123",
  "object": {
    "type": "post",
    "id": "post_456"
  },
  "schema_version": 1
}

Do not assume the event should contain a fixed list of recipients: follower relationships, blocks, and notification settings can change. Resolve or validate recipients in the notification service, and define whether the product uses event-time or processing-time preferences.

Make Inbox Writes Idempotent

Give each logical notification a stable key and enforce it in durable storage. For example, a PostgreSQL inbox table can reject a repeated write for the same recipient and notification key:

CREATE TABLE notification_inbox (
    recipient_id UUID NOT NULL,
    notification_key TEXT NOT NULL,
    source_event_id TEXT NOT NULL,
    notification_type TEXT NOT NULL,
    payload JSONB NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    read_at TIMESTAMPTZ,
    PRIMARY KEY (recipient_id, notification_key)
);

INSERT INTO notification_inbox (
    recipient_id, notification_key, source_event_id,
    notification_type, payload
)
VALUES (
    '00000000-0000-0000-0000-000000000001',
    'comment:evt_01JEXAMPLE',
    'evt_01JEXAMPLE',
    'comment',
    '{"post_id":"post_456"}'
)
ON CONFLICT (recipient_id, notification_key) DO NOTHING;

Choose the key to represent the product’s deduplication rule. If a single source event can produce multiple inbox items for one user, include the notification type or another stable output identifier. Commit the inbox write and the consumer’s deduplication state together when they share a database; acknowledge the broker message only after that transaction succeeds.

Bound Retries and Control Fan-Out

Retry transient network failures, throttling, and temporary provider errors with a limit, exponential backoff, and jitter. Do not retry invalid tokens or malformed payloads forever. Respect provider retry guidance such as Retry-After where applicable; the AWS retry-with-backoff guidance explains why retries need idempotent operations and limits.

Send a stable notification or delivery ID where the provider supports it, but do not assume that an external push side effect can be made exactly once by your database transaction. Keep a delivery-attempt record, classify failures, route exhausted jobs to a dead-letter queue, and provide an audited replay path. For large fan-out, partition jobs by recipient or another stable key, cap per-user delivery rates, and aggregate noisy events.

Monitor time from source event to inbox creation, inbox-to-provider attempt, provider response classes, consumer lag, retry age, dead-letter count, and per-channel opt-out rates. Track delivery states precisely: queued, attempted, accepted by provider, failed, or opened when the client reports it. Do not label a provider-accepted message as read or delivered to a human. On Windows-hosted workers, Windows Event Log analysis and monitoring can complement application-level metrics and structured logs.

Common Misconceptions

“Exactly-once broker delivery prevents duplicate notifications.”

Broker and client guarantees apply only within defined boundaries. A relay may republish after a crash, and a consumer may finish a database write before its acknowledgement is recorded. Make inbox creation idempotent. An external push provider and your database do not share one transaction, so an ambiguous timeout can still require a retry that may duplicate a push.

“A successful push API response means the user saw the alert.”

A provider response generally indicates that the provider accepted or rejected a request. Device connectivity, operating-system policy, notification permissions, and user behavior determine what happens afterward. The durable inbox remains the source of truth; push is a hint to revisit it.

“Every event should become an immediate notification.”

Events are facts for interested consumers, not a mandate to interrupt users. Preferences, quiet hours, privacy rules, aggregation, and rate limits should determine whether and how an event becomes a notification.

“More fan-out is always better.”

Writing one row and sending one push per recipient can create a large burst for popular content. Measure the delivery delay and storage cost, then choose direct fan-out, batching, aggregation, or read-time fan-out according to audience size and product needs.

TBO Editorial

About the Author

TBO Editorial writes about the latest updates about products and services related to Technology, Business, Finance & Lifestyle. Do get in touch if you want to share any useful article with our community.