0
0
Microservicessystem_design~20 mins

Event schema design in Microservices - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Event Schema Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Event Schema Versioning

In event-driven microservices, why is it important to version event schemas?

ATo ensure backward compatibility when event structure changes
BTo limit the number of events a service can produce
CTo encrypt event data for security purposes
DTo reduce the size of events for faster transmission
Attempts:
2 left
💡 Hint

Think about what happens when event consumers expect a certain format but producers change it.

query_result
intermediate
2:00remaining
Identify the Correct Event Schema Output

Given this JSON event schema for a user registration event, which option correctly represents a valid event instance?

{
  "eventType": "UserRegistered",
  "version": 2,
  "payload": {
    "userId": "12345",
    "email": "user@example.com",
    "timestamp": "2024-06-01T12:00:00Z"
  }
}
A{"eventType": "UserRegistered", "version": 2, "payload": {"userId": "12345", "email": "user@example.com", "time": "2024-06-01T12:00:00Z"}}
B{"eventType": "UserRegistered", "version": 2, "payload": {"userId": "12345", "email": "user@example.com", "timestamp": "2024-06-01T12:00:00Z"}}
C{"eventType": "UserRegistered", "version": "two", "payload": {"userId": "12345", "email": "user@example.com", "timestamp": "2024-06-01T12:00:00Z"}}
D{"eventType": "UserRegistered", "payload": {"userId": 12345, "email": "user@example.com"}}
Attempts:
2 left
💡 Hint

Check for correct data types and required fields matching the schema.

🧠 Conceptual
advanced
2:00remaining
Detect Schema Definition Syntax Error

Which option contains a syntax error in this Avro event schema snippet?

{
  "type": "record",
  "name": "OrderPlaced",
  "fields": [
    {"name": "orderId", "type": "string"},
    {"name": "amount", "type": "double"},
    {"name": "items", "type": {"type": "array", "items": "string"}}
  ]
}
A
{
  "type": "record",
  "name": "OrderPlaced",
  "fields": [
    {"name": "orderId", "type": "string"},
    {"name": "amount", "type": "double"},
    {"name": "items", "type": {"type": "array", "items": "string"}
  ]
}
B
{
  "type": "record",
  "name": "OrderPlaced",
  "fields": [
    {"name": "orderId", "type": "string"},
    {"name": "amount", "type": "double"},
    {"name": "items", "type": {"type": "array", "items": "string"}}
  ]
}
C
}
]  
}}"gnirts" :"smeti" ,"yarra" :"epyt"{ :"epyt" ,"smeti" :"eman"{    
,}"elbuod" :"epyt" ,"tnuoma" :"eman"{    
,}"gnirts" :"epyt" ,"dIredro" :"eman"{    
[ :"sdleif"  
,"decalPredrO" :"eman"  
,"drocer" :"epyt"  
{
D
{
  "type": "record",
  "name": "OrderPlaced",
  "fields": [
    {"name": "orderId", "type": "string"},
    {"name": "amount", "type": "double"},
    {"name": "items", "type": "array", "items": "string"}
  ]
}
Attempts:
2 left
💡 Hint

Look for missing brackets or commas in JSON structure.

optimization
advanced
2:00remaining
Optimizing Event Schema for Size

You want to reduce the size of your event messages without losing essential information. Which schema design choice helps achieve this?

AUse verbose nested objects for clarity
BInclude all possible fields with default values even if unused
CUse shorter field names and optional fields for rarely used data
DAdd redundant fields to improve data integrity
Attempts:
2 left
💡 Hint

Think about what makes data smaller to send over the network.

🔍 Analysis
expert
3:00remaining
Identify the Cause of Event Consumer Failure

An event consumer fails to process events after a schema update. The new schema added a required field without a default value. What is the most likely cause?

AThe event topic name was changed without updating the consumer
BThe producer is sending events with extra fields ignored by the consumer
CThe consumer has outdated credentials to access the event stream
DThe consumer expects the new required field but old events lack it, causing deserialization errors
Attempts:
2 left
💡 Hint

Consider what happens when required data is missing in older events.