PUSH Technologies - An Overview

From PiRho Knowledgebase
Jump to navigationJump to search

Template:ShortDescription Template:Infobox PublicTech

PUSH technologies allow servers to deliver updates to clients instantly when data changes, without requiring repeated polling. This article compares the major PUSH mechanisms—Server-Sent Events, WebSockets, MQTT, Long‑Polling, and Web Push—explaining how each works, where they fit, and how to choose between them. It also covers the universal PUSH lifecycle, architectural patterns, and practical considerations.

What “PUSH” Means

PUSH reverses the traditional HTTP request/response flow by enabling servers to send updates the moment something meaningful happens. This requires:

  • a persistent or semi‑persistent channel
  • a subscription mechanism
  • a delivery engine
  • event triggers

Summary Comparison Table

Technology Directionality Ideal Use Cases Complexity
SSE Server→Client Notifications, dashboards, workflow updates Low
WebSockets Full-duplex Chat, collaboration, presence Medium–High
MQTT Pub/Sub IoT, sensors, distributed systems Medium
Long-polling Simulated PUSH Legacy fallback Low
Web Push Server→Browser Notifications outside browser Medium

Major PUSH Technologies

Server-Sent Events (SSE)

Lightweight one-way PUSH over a long-lived HTTP connection.
Strengths: simple, efficient, REST-friendly.
Limitations: one-way only; PHP-FPM tuning required.

Deep Dive: Server‑Sent Events (SSE)

Server‑Sent Events (SSE) is a server → client streaming technology defined in the HTML Living Standard. Clients receive UTF‑8 encoded events over a long‑lived HTTP connection via the JavaScript `EventSource` interface. (Spec: WHATWG HTML — Server‑Sent Events)

How SSE Works

  • Client opens a long‑lived HTTP GET request.
  • Server replies with `Content-Type: text/event-stream` and streams events.
  • Events may include `data:`, optional `id:` (resume), and optional `event:` (named types).
  • Browsers auto‑reconnect and send `Last-Event-ID` when resuming. (Spec details)

Example Event

``` id: 583 event: order_update data: {"order":123,"status":"shipped"} ```

Strengths

  • Simple implementation; native `EventSource` API.
  • Automatic reconnection and event ID tracking.

Limitations

  • One‑way only (server → client); UTF‑8 text only.
  • Browser connection limits for HTTP/1 (commonly ~6 per domain).

WebSockets

Full-duplex real-time communication.
Strengths: low-latency, binary support.
Limitations: needs event-driven runtime.

Long-Polling

Held-open requests until change.
Strengths: universal fallback.
Limitations: inefficient at scale.

MQTT

Pub/sub protocol designed for IoT and telemetry.
Strengths: massive scalability, durable subscriptions.
Limitations: requires broker, not browser-native.

Web Push API

Notification delivery even when browser is closed.
Strengths: great for user-centric alerts.
Limitations: not for continuous streams.

Universal PUSH Lifecycle

1. Discovery/Intent
2. Channel Establishment
3. Subscription Registration
4. Delivery

When to Use What

  • Use SSE for simple one-way notifications.
  • Use WebSockets for collaborative apps.
  • Use MQTT for IoT/distributed messaging.
  • Use Long-polling for legacy compat.
  • Use Web Push for browser notifications.

References