Giter Site home page Giter Site logo

minipush's Introduction

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.

minipush's People

Contributors

mqy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.