Skip to content

Instantly share code, notes, and snippets.

Type Compression Ratio CPU Usage Compressions Speed Network Bandwidth Usage
Gzip Highest Highest Slowest Lowest
Snappy Moderate Moderate Moderate Moderate
Lz4 Lowest Lowest Fastest Highest
Zstd Moderate Moderate Moderate Moderate
Details Why / Benefits
Partition

Extra Credit

Instructions

  1. Create a topic called "compacted-expiring-topic" using the kafka-topics command
  2. Make sure the topic has a combined cleanup policy and the proper retention and segment timings
    1. Essentially combine the configurations used in the previous two exercises
  3. Repeat the exercise steps from either 1.a.1 or 1.b.1, but make sure you set the "generate-test-data.ps1" mode to "retention-policy-delete-publisher".

Extra Credit

Why do you think even with compaction, you can get duplicates?

Click to view the answer...
There are two key aspects to compaction that allow for duplicates:
    The cleanup policy compact guarantees only that at least one message for each key will be available
Setting Description
segment.ms The period of time after which Kafka will force the log to roll even if the segment file isn’t full
Description Use Case
Delete
Method Action Return Objects Used From DI
/users
ProduceUpdate(User user) Produces a JSON serialized user
ProducerDelete(long userId) Produces a Null value for the userId key
Use the built in Confluent serializer
Message Part Type Serializer
Key long (Int64)
Key String value of the loop iteration i
Value String value of the exact time