docs/sources/reference-pyroscope-v2-architecture/components/segment-writer.md
The segment-writer is a stateless component that accumulates incoming profiles in memory and periodically writes them to object storage as segments. This is a new component in v2 that replaces the ingester's role in the write path.
Each segment-writer produces a single object per shard containing data from all tenant services assigned to that shard. This approach minimizes the number of write operations to object storage, significantly reducing costs compared to writing individual objects for each tenant or service.
Ingestion clients are blocked until data is durably stored in object storage and an entry for the object is created in the metadata index. This guarantees data durability without requiring local disk persistence.
By default, ingestion is synchronous with median latency expected to be less than 500ms using default settings and popular object storage providers such as Amazon S3, Google Cloud Storage, and Azure Blob Storage.
Profiles are accumulated in an in-memory database before being flushed to object storage. The in-memory structure includes:
Profiles from the same application (identified by the service_name label) are co-located in the same segments. This co-location is maintained by the distributor's routing algorithm and is crucial for:
Unlike the v1 ingester which required local disk storage, the segment-writer is completely stateless:
The segment writer relies on at-least-once delivery semantics. If a write fails after the segment has been uploaded to object storage but before the metastore acknowledges the metadata, the client retries the request. This can result in the same profile appearing in multiple segments, which is resolved during compaction.
If the segment writer cannot register metadata with the metastore (for example, during metastore unavailability), the metadata is written to a dead letter queue (DLQ) directory in object storage. The metastore recovers these entries in the background, ensuring that data is eventually made visible to queries.
The segment-writer flush behavior can be configured to balance between: