PostHog's architecture

Last updated:

|Edit this page

This section covers PostHog's data model, ingestion pipeline, ClickHouse setup and data querying. This page provides an overview of how PostHog is structured.

Broad overview

There are only a few systems to consider.

  • A website and API for users
  • An API for client apps
  • A plugin service for processing events on ingestion
  • A worker service for processing events in response to triggers
User
Client Apps/SDKs
Export Sink
Web/API
plugin/worker service
Celery
Data stores

Zooming closer

Adding detail reveals the flow between parts of the system.

plugin/worker service
Web/API
views insights and more
send events
read
write events
onEvent
save events
onTimer
export events
e.g. read flags
read events
start task
on schedule
Ingestion
Async
timer
Web
Capture API
Decide API
cron
Celery
User
Client Apps/SDKs
Export Sink
Data stores

Zoomed right in

K8s PostHog namespace
K8s Services
K8s Services
Other traffic
Events endpoint
Write path
Read path
Optional Utilization telemetry
Ingress
Postgres Stateful service
Kafka Stateful Service
Kafka Stateful Service
Redis SS
Service Load Balancer
Service Load Balancer
K8s Services
PGBouncer
ClickHouse Cluster (Operator Managed)
Replica 1 Shard 1
Replica 1 Shard 2
Replica 2 Shard 1
Replica 2 Shard 2
K8s ZooKeeper cluster
ZK1
ZK2
ZK3
Plugin Service
Worker Service
Events Service
Web Service
Client Apps
Posthog License Telemetry service

No communication is needed into or out of this namespace other than the ingress controller for the app and collecting data.

Questions?

  • Ahmed
    3 months ago

    Can you update this article.

    I think this is an old article. can we get it updated?

  • Puneet
    2 years ago

    How to get events to kafka topic

    As i saw there is no plugin is there, nor native method is available to push the events to Kafka But in the architecture i saw Posthog using Kafka internally Can i use this Kafka topic ? If i used this internal Kafka, Do I get the wrong Analytics of events ? or Before pushing it to Kafka does the posthog perform Analytics and add it into the event Payload like SessionId, Visitor Id etc.

    • Stefan
      a year ago

      did you try configuring the your own broker? what was your experience if you already tried?

Was this page useful?

Next article

Data model

This provides a high-level overview of the various objects and primitives that make up the PostHog data model. The two most basic entities in PostHog are the event and person objects. They represent the core of our analytics functionalities. Further reading: How data is stored in ClickHouse Event An event is the most important object in PostHog. It represents a single action that a user performed at a specific point in time. These events are sent either from one of our SDKs or…

Read next article