Evolusi Skema dan Mode Kompatibilitas
Pelajari cara Confluent Schema Registry menegakkan kompatibilitas saat skema berubah serta cara memilih kompatibilitas mundur, maju, atau penuh dengan aman.
Evolusi Skema dan Mode Kompatibilitas adalah pelajaran Apache Kafka & Stream Processing Fundamentals gratis di CoddyKit. Ini adalah pelajaran 4 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Apache Kafka & Stream Processing Fundamentals, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Apache Kafka & Stream Processing Fundamentals mencakup 4 pelajaran total.
Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.
Why Schemas Evolve
Data contracts change over time — you add fields, deprecate others, rename things. Schema evolution is the discipline of changing schemas without breaking existing producers and consumers.
The Compatibility Problem
Producers and consumers often deploy at different times. A new producer might emit a v2 schema while old consumers still expect v1.
Without rules, that mismatch causes deserialization failures in production.
Backward Compatibility
Backward: new schema can read data written with the old schema.
- Safe changes: delete a field, add a field with a default.
- Upgrade consumers first.
Forward Compatibility
Forward: old schema can read data written with the new schema.
- Safe changes: add a field, delete a field that had a default.
- Upgrade producers first.
Full Compatibility
Full requires both backward and forward compatibility at once.
- Only changes safe in both directions are allowed (add/remove fields with defaults).
- Producers and consumers can be upgraded in any order.
Transitive Variants
Each mode has a transitive version (BACKWARD_TRANSITIVE, etc.).
Non-transitive checks only against the latest schema; transitive checks against all prior versions — stronger guarantees, more constraints.
Setting Compatibility
Compatibility is configured per subject (or globally) via the Schema Registry REST API.
curl -X PUT \
http://localhost:8081/config/orders-value \
-H 'Content-Type: application/vnd.schemaregistry.v1+json' \
-d '{"compatibility": "BACKWARD"}'A Backward-Safe Avro Change
Adding a field with a default keeps old data readable under BACKWARD mode.
{
"type": "record",
"name": "Order",
"fields": [
{"name": "id", "type": "string"},
{"name": "amount", "type": "double"},
{"name": "currency", "type": "string", "default": "USD"}
]
}Testing Before You Register
The registry can check a candidate schema against the current one before you commit it.
curl -X POST \
http://localhost:8081/compatibility/subjects/orders-value/versions/latest \
-H 'Content-Type: application/vnd.schemaregistry.v1+json' \
-d '{"schema": "...escaped avro..."}'Breaking Changes
Changes that almost always break compatibility:
- Renaming a field (treated as delete + add).
- Changing a field's type incompatibly.
- Adding a required field with no default.
For these, create a new subject/topic version instead.
Choosing a Mode
Rules of thumb:
- BACKWARD (default) when you upgrade consumers first.
- FORWARD when producers lead.
- FULL for independently deployed teams.
- Use transitive variants for long-lived, replayable topics.
Quick Check
Test your understanding of compatibility modes.
Recap
You learned schema evolution and compatibility modes.
- BACKWARD: new reads old, upgrade consumers first.
- FORWARD: old reads new, upgrade producers first.
- FULL: both, any order.
- Transitive variants check all prior versions; renames and required no-default fields break compatibility.
Pertanyaan yang Sering Diajukan
Apakah pelajaran “Evolusi Skema dan Mode Kompatibilitas” gratis?
Ya — teks lengkap “Evolusi Skema dan Mode Kompatibilitas” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Apache Kafka & Stream Processing Fundamentals, upgrade ke CoddyKit PRO. Kursus Apache Kafka & Stream Processing Fundamentals mencakup 4 pelajaran total.
Apa yang akan aku pelajari di “Evolusi Skema dan Mode Kompatibilitas”?
Pelajari cara Confluent Schema Registry menegakkan kompatibilitas saat skema berubah serta cara memilih kompatibilitas mundur, maju, atau penuh dengan aman. Kamu berlatih Apache Kafka & Stream Processing Fundamentals dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.
Apakah aku perlu pengalaman untuk memulai Apache Kafka & Stream Processing Fundamentals?
Tidak diperlukan pengalaman sebelumnya. Apache Kafka & Stream Processing Fundamentals di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 4 dari 4.
Berapa lama pelajaran “Evolusi Skema dan Mode Kompatibilitas” memakan waktu?
Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.
Bisakah aku menulis dan menjalankan kode dalam pelajaran Apache Kafka & Stream Processing Fundamentals ini?
Ya. Setiap pelajaran Apache Kafka & Stream Processing Fundamentals menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.
Semua pelajaran dalam kursus ini
- Mengapa Pengelolaan Skema?
- Skema Avro & Protobuf
- Mengintegrasikan Schema Registry dengan Kafka
- Evolusi Skema dan Mode Kompatibilitas