コミットログ:Kafkaのデータ保存方法
Kafkaがメッセージを追記専用のコミットログとして保存する方法、オフセットと保持の仕組み、そしてこの設計がKafkaを高速かつ堅牢にする理由を学びます。
「コミットログ:Kafkaのデータ保存方法」はCoddyKit上の無料Apache Kafka & Stream Processing Fundamentalsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはApache Kafka & Stream Processing Fundamentals学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Apache Kafka & Stream Processing Fundamentalsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Kafka Is a Log
At its core Kafka is a distributed, append-only commit log. Producers append to the end and data is never modified in place — that's the secret to its speed and durability.
Append-Only Writes
Every record is written sequentially to the end of a partition's log. Sequential disk writes are far faster than random ones, sustaining high throughput on cheap disks.
The Offset
Each record gets a monotonically increasing offset — its position in the partition. Offsets are unique within a partition and never reused.
Partition 0: [off 0][off 1][off 2][off 3] -> next write off 4Reads Don't Delete
Unlike a queue, consuming a record does not delete it. Many consumers read the same log independently, each tracking its own offset.
Log Segments
A partition log is split into segment files on disk. Only the active segment is written to; older segments are immutable and can be deleted or compacted.
00000000000000000000.log
00000000000000010000.logRetention by Time
Kafka keeps data for a configurable period regardless of whether it's consumed. The default retention is 7 days.
retention.ms=604800000Retention by Size
You can also cap a partition by size. Whichever limit hits first — time or bytes — triggers deletion of the oldest segments.
retention.bytes=1073741824Log Compaction
Instead of deleting by age, compaction keeps only the latest record per key — perfect for changelog topics where you just want each key's current value.
cleanup.policy=compactZero-Copy Reads
Kafka serves reads straight from the OS page cache to the network using zero-copy, skipping extra memory copies. Another big reason consumption is so fast.
Durability via Flush and Replicas
Records are durable because they're written to disk and replicated to other brokers. Even if the OS cache is lost, replicas preserve the data.
Putting It Together
The commit log explains Kafka's character: sequential writes for speed, offsets for replayable reads, retention and compaction for storage, replication for durability.
Quick Check
Test your understanding of the commit log.
Recap
You learned Kafka's storage: an append-only commit log with stable offsets, reads that don't delete, retention plus compaction, and replication for durability.
よくある質問
「コミットログ:Kafkaのデータ保存方法」レッスンは無料ですか?
はい。「コミットログ:Kafkaのデータ保存方法」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Apache Kafka & Stream Processing Fundamentalsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Apache Kafka & Stream Processing Fundamentalsコースには全4レッスンが含まれています。
「コミットログ:Kafkaのデータ保存方法」で何を学びますか?
Kafkaがメッセージを追記専用のコミットログとして保存する方法、オフセットと保持の仕組み、そしてこの設計がKafkaを高速かつ堅牢にする理由を学びます。 ブラウザで直接実行するハンズオンコードでApache Kafka & Stream Processing Fundamentalsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Apache Kafka & Stream Processing Fundamentalsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのApache Kafka & Stream Processing Fundamentalsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「コミットログ:Kafkaのデータ保存方法」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このApache Kafka & Stream Processing Fundamentalsレッスンでコードを書いて実行できますか?
はい。すべてのApache Kafka & Stream Processing Fundamentalsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Apache Kafkaとは
- Kafkaの基本概念:ブローカーとトピック
- Kafkaのローカル環境構築
- コミットログ:Kafkaのデータ保存方法