Complete the code to set the correct number of partitions for a Kafka topic.
kafka-topics --create --topic my-topic --partitions [1] --replication-factor 3 --bootstrap-server localhost:9092
Setting partitions to 10 allows Kafka to handle more load by distributing messages across multiple partitions.
Complete the code to increase the Kafka producer batch size for better throughput.
producerConfig.put("batch.size", [1]);
Setting batch.size to 16384 bytes allows the producer to send larger batches, improving throughput under load.
Fix the error in the consumer configuration to properly set the fetch max bytes.
consumerConfig.put("fetch.max.bytes", [1]);
Setting fetch.max.bytes to 1048576 (1 MB) allows the consumer to fetch larger batches, improving performance under load.
Fill both blanks to create a dictionary comprehension that maps topic names to their partition counts if partitions are greater than 3.
partitions_map = {topic: [1] for topic, partitions in topics.items() if partitions [2] 3}This comprehension creates a dictionary with topics having more than 3 partitions, mapping topic names to their partition counts.
Fill all three blanks to create a dictionary comprehension that maps uppercase topic names to their partition counts if partitions are less than or equal to 5.
filtered = {{ [1]: [2] for [3], partitions in topics.items() if partitions <= 5 }}This comprehension maps uppercase topic names to their partition counts for topics with 5 or fewer partitions.