minipush

command module
v0.0.0-...-b47d8ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 28 Imported by: 0

README

MiniPush

MiniPush is a tiny and simple online push service, as a study project. Current status: in progress.

For offline push, please refer to:

Overview

Scope:

  • features: push from server; optional route bidirectional e2e messages.
  • small or medium dataset (at most millions per month).
  • low concurrency.

Key decisions:

  • event TTL (default: 30 days), outdated events are cleaned by a background task.
  • push less, fetch/query more -- events are fetched by clients, server does not push event.
  • head sequence as pointer, great for diff.
  • compressed read state bitmap.

Architecture

Components:

  • hub: websocket manager.
  • gRPC server:
    • route messages: bidirectional stream between clients(hubs) and server.
    • manage cluster sessions.
  • store(mysql): events.
  • event store manager: consume kafka, clean events.

Data storage:

  • mysql (events)
  • kafka (incoming events from business servers, optional e2e messages)

Other:

  • incoming event (format, size limit)
  • create(staging) time
  • scalability
  • server config

Event Model And APIs

Every event has the following attributes:

  • uid (immutable)
  • seq (immutable, sortable)
  • body (immutable)
  • create_time (immutable, set by callers on event creation)
  • read_state (mutable, true/false)

sequence

TODO

event TTL and clean

TODO

APIs

see proto

Session Management

Limit Max Live (online) Sessions

Rationale:

  • avoid flooding by malformed client program, or intentionally abuse by user.
  • try avoid interaction with user.

Solution:

  • configure max per user session limit (quota): 5?
  • kickoff old sessions that beyond the quota.
  • delete sessions that was kickoff for a while but hub did not issue delete request.
  • delete sessions that no live hub id, caused by follower stop.
  • on connect from follower to leader, follower syncs local sessions to leader.

Keep alive:

  • websocket Ping/Pong
  • Nginx keepalive_timeout

Data Storage

Because the data model is quite simple, we can choose almost any data store. For small dataset (say millions), mysql is enough. For huge dataset (say billions), perhaps we'd migrate to tidb (with sharding).

WebSocket

Web socket is mature, but was fully supported since IE 10 @ win 10.

Ref: Scaling to a Millions WebSocket concurrent connections

  • upgrade
  • cors
  • nginx
  • no load balancing
  • no max connection limit on each hub.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
dev
demo command
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL