Weibo Docs

Core Concepts

The vocabulary used across Weibo, in one page.

Source[Kafka] → Map → Filter → KeyBy → Window(5m) → Reduce → Sink[Postgres]

Stream

An unbounded, ordered sequence of records. Created from a source, flows through operators, ends in a sink.

Record

FieldTypePurpose
Key[]bytePartition key for keyed state and shuffling
Value[]bytePayload
Timestamptime.TimeEvent time for windows
Offsetint64Source position for replay
PartitionintSource partition for barrier-aligned offsets
SourcestringStable source identity (Kafka topic)
Headersmap[string][]byteOptional metadata

Source and sink

  • Sources: Kafka, generator, slice, file
  • Sinks: Kafka, transactional Kafka, Postgres, HTTP, S3, file, stdout, blackhole

Details: Sources, Sinks.

Operator

OperatorShapeUse
Map1 → 1Transform
FlatMap1 → nSplit / explode
Filter1 → 0/1Drop records
KeyBypartitionEnable keyed state + parallelism
Reducefold per keyRunning aggregates
Window / WindowReducegroup by timeBounded aggregates
Process1 → 1, error-awareFailure policy: drop, DLQ, fail

Keyed stream

After KeyBy, every key has its own isolated state. WithPartitions(n) runs n workers, each owning a slice of the key space.

stream.KeyBy(byCustomer).WithPartitions(8).Reduce(sumAmount)

Window and watermark

  • Tumbling: fixed, non-overlapping
  • Sliding: fixed, overlapping
  • Session: closes after an inactivity gap

A watermark says "no record older than T will arrive". Windows fire when the watermark passes their end. Records behind the watermark (minus allowed lateness) are late and dropped or side-output.

Prefer WindowReduce for one result per (key, window).

State

BackendStorageBest for
state.InMemory()RAMUnder ~100k keys, lowest latency
state.Pebble(dir)Disk (LSM)Large state, fast native checkpoints

At 5M keys Pebble uses ~0.7 MB heap vs 579 MB, and checkpoints in ~75 ms vs ~3.3 s.

Checkpoint

A consistent snapshot of source offsets plus all operator state, taken with barriers that flow in-band through the graph (Chandy-Lamport). On crash, Weibo restores the last completed checkpoint and replays from the saved offsets.

Savepoint

A named, manually triggered checkpoint used for upgrades and migrations. See Savepoints and Upgrades.

Job

A complete pipeline (source → operators → sink) run by the process that embeds it, or as a container managed by the control plane.

On this page