A Schema Registry is a service that stores and manages schemas for Kafka messages. It helps ensure that producers and consumers agree on the data format.
Click to reveal answer
intermediate
Why is schema evolution important in Kafka?
Schema evolution allows schemas to change over time without breaking existing data or applications. The Schema Registry supports this by validating compatibility between schema versions.
Click to reveal answer
beginner
What formats does Schema Registry commonly support?
Schema Registry commonly supports Avro, JSON Schema, and Protobuf formats for defining message schemas.
Click to reveal answer
intermediate
How does Schema Registry help prevent data corruption?
By enforcing schema compatibility and validating messages against registered schemas, Schema Registry prevents producers from sending incompatible data that could corrupt consumers.
Click to reveal answer
intermediate
What is the role of schema ID in Kafka messages when using Schema Registry?
The schema ID is a unique identifier stored in the message payload that tells consumers which schema version to use to decode the message.
Click to reveal answer
What does Schema Registry primarily manage in Kafka?
AKafka topics
BMessage schemas
CConsumer groups
DBroker configurations
✗ Incorrect
Schema Registry manages message schemas to ensure data format consistency.
Which of these is NOT a schema format supported by Schema Registry?
AAvro
BJSON Schema
CXML Schema
DProtobuf
✗ Incorrect
Schema Registry does not natively support XML Schema.
What does schema compatibility ensure?
ASchemas can change without breaking consumers
BMessages are encrypted
CTopics are balanced
DConsumers read faster
✗ Incorrect
Compatibility ensures schema changes do not break existing consumers.
Where is the schema ID stored in Kafka messages when using Schema Registry?
AIn the broker config
BIn the topic name
CIn the consumer group
DIn the message payload
✗ Incorrect
The schema ID is embedded in the message payload to identify the schema version.
How does Schema Registry help producers and consumers?
ABy enforcing agreed data formats
BBy managing Kafka partitions
CBy controlling network traffic
DBy storing message payloads
✗ Incorrect
Schema Registry enforces data format agreements between producers and consumers.
Explain what a Schema Registry is and why it is useful in Kafka.
Think about how producers and consumers agree on message structure.
You got /4 concepts.
Describe how schema evolution works with Schema Registry and why compatibility matters.
Consider what happens when data formats change over time.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a Schema Registry in Kafka?
easy
A. To encrypt Kafka messages during transmission
B. To monitor Kafka broker performance
C. To route messages between Kafka topics
D. To store and manage data schemas for Kafka messages
Solution
Step 1: Understand the role of Schema Registry
Schema Registry stores and manages the structure (schema) of data used in Kafka messages.
Step 2: Compare with other Kafka components
Monitoring, routing, and encryption are handled by other Kafka tools, not Schema Registry.
Final Answer:
To store and manage data schemas for Kafka messages -> Option D
Quick Check:
Schema Registry = data schema storage [OK]
Hint: Schema Registry manages data formats, not Kafka internals [OK]
Common Mistakes:
Confusing Schema Registry with Kafka brokers
Thinking it handles message routing
Assuming it encrypts messages
2. Which of the following is the correct way to register a schema using Kafka Schema Registry API?
easy
A. DELETE /topics/{topic}/schemas with schema in YAML
B. GET /schemas/{id} with schema in XML
C. POST /subjects/{subject}/versions with schema in JSON
D. PUT /brokers/{brokerId}/schemas with schema in CSV
Solution
Step 1: Identify the correct HTTP method and endpoint
Registering a schema uses POST on /subjects/{subject}/versions with JSON schema.
Step 2: Check other options for correctness
GET retrieves schemas, DELETE removes topics (not schemas), PUT on brokers is invalid for schema registration.
Final Answer:
POST /subjects/{subject}/versions with schema in JSON -> Option C
Quick Check:
Register schema = POST with JSON [OK]
Hint: Register schemas with POST and JSON format [OK]
Common Mistakes:
Using GET instead of POST to register
Confusing schema formats (JSON vs XML/YAML/CSV)
Using wrong API endpoints
3. Given this code snippet using Kafka Schema Registry client, what will be the output?
A. Registering the same schema twice causes an error
B. No error; registering same schema returns same ID
C. Schema string is not valid JSON
D. Missing schema version in registration call
Solution
Step 1: Check schema validity
The schema string is valid JSON describing a record with an int field.
Step 2: Understand Schema Registry behavior on duplicate schemas
Registering the same schema again returns the same schema ID without error.
Final Answer:
No error; registering same schema returns same ID -> Option B
Quick Check:
Duplicate schema registration returns same ID [OK]
Hint: Duplicate schema registration is safe and returns same ID [OK]
Common Mistakes:
Assuming duplicate registration causes error
Thinking schema string is invalid JSON
Expecting version parameter in register call
5. You want to evolve a Kafka message schema by adding a new optional field without breaking existing consumers. Which Schema Registry feature helps achieve this safely?
hard
A. Schema compatibility settings (e.g., BACKWARD compatibility)
B. Schema encryption for secure transmission
C. Schema version rollback to previous schema
D. Schema validation disabling for faster registration
Solution
Step 1: Understand schema evolution needs
Adding a new optional field requires compatibility so old consumers still work.
Step 2: Identify Schema Registry feature for compatibility
Schema compatibility settings like BACKWARD ensure new schemas don't break old consumers.
Step 3: Eliminate other options
Encryption, rollback, or disabling validation do not help safe schema evolution.
Final Answer:
Schema compatibility settings (e.g., BACKWARD compatibility) -> Option A