---
title: "Kafka, Latency, and You: Minimizing Latency with Kafka & ClickHouse"
description: "End-to-end latency in a Kafka → Kafka Connect → ClickHouse pipeline can be measured by stamping messages with offset, partition, timestamp and topic via single message transforms, recording insert time with a DEFAULT now() column, and charting median/p75/p95 deltas per minute in SQL."
url: "https://swe.quest/articles/kafka-latency-and-you-minimizing-latency-with-kafka-clickhouse-89c71c2fc7e4578d"
canonical: "https://clickhouse.com/blog/measure-visaualize-minimize-kafka-latency-clickhouse"
source: "ClickHouse"
published: "2023-09-13"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["messaging","analytics","performance","data-pipelines"]
---

# Kafka, Latency, and You: Minimizing Latency with Kafka & ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-09-13, 8 min read, How-to. Original: [https://clickhouse.com/blog/measure-visaualize-minimize-kafka-latency-clickhouse](https://clickhouse.com/blog/measure-visaualize-minimize-kafka-latency-clickhouse)

## Summary

End-to-end latency in a Kafka → Kafka Connect → ClickHouse pipeline can be measured by stamping messages with offset, partition, timestamp and topic via single message transforms, recording insert time with a DEFAULT now() column, and charting median/p75/p95 deltas per minute in SQL. Tuning levers include consumer fetch and poll settings (fetch.min/max.bytes, fetch.max.wait.ms, max.poll.records), keeping partitions modest with at least one task per partition, and batching inserts of 10,000–100,000 rows to avoid "Too Many Parts" errors. On the ClickHouse Cloud side, idle-sleep timeouts, instance sizing, and asynchronous inserts can cut latency, with async inserts giving weaker durability guarantees.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Queues & messaging](https://swe.quest/tags/messaging.md) (Backend & APIs)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)

## Prerequisites

- Kafka topics and partitions ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- Kafka Connect basics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- ClickHouse MergeTree tables ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

Kafka, ClickHouse, Kafka Connect, ClickHouse Cloud, Single Message Transforms, Confluent Cloud

## Related posts

- [Asynchronous Data Inserts in ClickHouse](https://swe.quest/articles/asynchronous-data-inserts-in-clickhouse-7e5b81fdcf244f48.md): ClickHouse · 2023-08-01 · Medium · 19 min read · Analytics & OLAP, Storage engines, Performance engineering, Observability
  ClickHouse asynchronous inserts move batching from the client to the server.
- [Real-time Event Streaming with ClickHouse, Kafka Connect and Confluent Cloud](https://swe.quest/articles/real-time-event-streaming-with-clickhouse-kafka-connect-and-confluent-cloud-afbdec81890c4edb.md): ClickHouse · 2023-06-22 · Medium · 18 min read · Queues & messaging, Data pipelines, Analytics & OLAP, Stream processing
  ClickHouse's official Kafka Connect sink, which uses the KeeperMap table engine for exactly-once semantics, can now be deployed as a Confluent Cloud Custom Connector.
- [ClickHouse v21.11 Released](https://swe.quest/articles/clickhouse-v21-11-released-1011a7b63db415f6.md): ClickHouse · 2021-11-11 · Medium · 4 min read · Analytics & OLAP, Databases
  ClickHouse 21.11 adds asynchronous inserts, which buffer many small concurrent INSERTs server-side and flush them as a single batch.
- [Essential Monitoring Queries - part 1 - INSERT Queries](https://swe.quest/articles/essential-monitoring-queries-part-1-insert-queries-eda633e3819dfbe1.md): ClickHouse · 2022-12-28 · Medium · 10 min read · Analytics & OLAP, Observability, SQL
  ClickHouse system tables such as part\_log, query\_log, asynchronous\_insert\_log, asynchronous\_metric\_log and parts can be queried with SQL to monitor and troubleshoot INSERT workloads.
- [Announcing a New Official ClickHouse Kafka Connector](https://swe.quest/articles/announcing-a-new-official-clickhouse-kafka-connector-5e810526c099fceb.md): ClickHouse · 2023-01-12 · Medium · 8 min read · Queues & messaging, Data pipelines, Analytics & OLAP, Consistency models
  ClickHouse released a beta open-source Kafka Connect sink that aims for exactly-once delivery into ClickHouse.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
