0
0
Kafkadevops~20 mins

Amazon MSK in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Amazon MSK Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Kafka consumer configuration?
Consider the following Kafka consumer configuration snippet for Amazon MSK. What will be the output when the consumer tries to read messages from a topic that does not exist?
Kafka
Properties props = new Properties();
props.put("bootstrap.servers", "b-1.mskcluster.example.com:9092,b-2.mskcluster.example.com:9092");
props.put("group.id", "test-group");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
consumer.subscribe(Collections.singletonList("nonexistent-topic"));
ConsumerRecords<String, String> records = consumer.poll(Duration.ofSeconds(5));
System.out.println("Number of records: " + records.count());
ANumber of records: 0
BException: org.apache.kafka.common.errors.UnknownTopicOrPartitionException
CNumber of records: null
DConsumer hangs indefinitely waiting for messages
Attempts:
2 left
💡 Hint
Think about how Kafka handles subscriptions to topics that do not exist yet.
🧠 Conceptual
intermediate
1:30remaining
Which Amazon MSK feature ensures data durability across multiple availability zones?
Amazon MSK is designed to be highly available and durable. Which feature primarily ensures that your Kafka data is safe even if one availability zone fails?
AReplication factor configured on Kafka topics
BUsing a single broker in one availability zone
CEnabling auto-scaling on the MSK cluster
DUsing client-side caching in Kafka producers
Attempts:
2 left
💡 Hint
Think about how Kafka replicates data to avoid data loss.
🔧 Debug
advanced
2:30remaining
Why does this Kafka producer fail to send messages to Amazon MSK?
Examine the following Kafka producer code snippet. It fails to send messages to the MSK cluster. What is the most likely cause?
Kafka
Properties props = new Properties();
props.put("bootstrap.servers", "b-1.mskcluster.example.com:9092");
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer<String, String> producer = new KafkaProducer<>(props);
ProducerRecord<String, String> record = new ProducerRecord<>("my-topic", "key1", "value1");
producer.send(record);
producer.close();
AIncorrect topic name format; topics must start with 'msk-' prefix
BKafkaProducer requires a consumer group id to send messages
CProducer is missing a call to flush() before close()
DMissing security configuration for SASL/SCRAM authentication
Attempts:
2 left
💡 Hint
Amazon MSK clusters often require authentication settings in the client configuration.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in this Kafka topic creation command for Amazon MSK.
Which option contains the correct syntax to create a Kafka topic named 'orders' with 3 partitions and a replication factor of 2 using kafka-topics.sh CLI?
Akafka-topics.sh --create --topic orders --partition 3 --replication 2 --bootstrap-server b-1.mskcluster.example.com:9092
Bkafka-topics.sh --create --topic orders --partitions 3 --replication-factor 2 --bootstrap-server b-1.mskcluster.example.com:9092
Ckafka-topics.sh --create --topic orders --partitions=3 --replication-factor=2 --bootstrap-server b-1.mskcluster.example.com:9092
Dkafka-topics.sh --create orders --partitions 3 --replication-factor 2 --bootstrap-server b-1.mskcluster.example.com:9092
Attempts:
2 left
💡 Hint
Check the exact option names and their spelling for partitions and replication factor.
🚀 Application
expert
3:00remaining
How to configure an Amazon MSK cluster for encryption in transit and at rest?
You want to secure your Amazon MSK cluster so that all data is encrypted both when moving between clients and brokers, and when stored on disk. Which configuration steps are required?
AUse plaintext communication and enable EBS encryption only
BEnable SASL authentication only; encryption is automatic
CEnable TLS encryption for client-broker communication and enable AWS KMS encryption for EBS volumes
DConfigure client-side encryption libraries; no MSK cluster changes needed
Attempts:
2 left
💡 Hint
Think about both network encryption and storage encryption options in MSK.