Skip to main content

Configuration Presets

Not sure which settings to use? Dekaf provides configuration presets for common scenarios. These set sensible defaults that you can override as needed.

Producer Presets​

ForHighThroughput​

Optimized for sending many messages with maximum efficiency. This producer preset selects LZ4: install Dekaf.Compression.Lz4 and explicitly register it at startup, as shown below. See Compression for registration in consumer applications.

using Dekaf;
using Dekaf.Compression;
using Dekaf.Compression.Lz4;

CompressionCodecRegistry.Default.AddLz4();

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForHighThroughput()
.BuildAsync();

Settings applied:

SettingValueEffect
AcksLeader (All by default, see below)Faster acknowledgment when idempotence is disabled
LingerMs100Allows batching
BatchSize2MBLarger batches
CompressionLZ4Reduces network usage

Best for: Log aggregation, metrics, analytics, high-volume event streams

ForLowLatency​

Optimized for minimal delay between sending and delivery:

using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForLowLatency()
.BuildAsync();

Settings applied:

SettingValueEffect
AcksLeader (All by default, see below)Fast acknowledgment when idempotence is disabled
LingerMs0No batching delay
BatchSize256KBSmaller batches

Best for: Real-time notifications, interactive applications, low-volume critical messages

Acks and Idempotence​

ForHighThroughput() and ForLowLatency() set Acks.Leader, but idempotence is enabled by default and idempotent producers require Acks.All. When idempotence is enabled, BuildAsync() logs a warning and overrides acks to All, so the final acks for these presets is All. To keep Acks.Leader, disable idempotence:

using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForLowLatency()
.WithIdempotence(false) // Keeps Acks.Leader; retries may write duplicates
.BuildAsync();

ForReliability​

Optimized for maximum durability and exactly-once semantics:

using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForReliability()
.BuildAsync();

Settings applied:

SettingValueEffect
AcksAllWait for all replicas
EnableIdempotencetrue (default, not changed by the preset)Prevent duplicates

Best for: Financial transactions, order processing, any data that cannot be lost

Consumer Presets​

ForHighThroughput​

Optimized for processing many messages efficiently:

using Dekaf;

var consumer = await Kafka.CreateConsumer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithGroupId("my-group")
.ForHighThroughput()
.BuildAsync();

Settings applied:

SettingValueEffect
MaxPollRecords1000Larger batches
FetchMinBytes1KBWait for more data
FetchMaxWaitMs200msSame as the default; higher values stall when the prefetch pipeline restarts after hitting memory limits
MaxPartitionFetchBytes4MBLarger fetch responses reduce round-trip overhead per byte
FetchMaxBytes100MB, adapting up to 200MBLarger fetch responses across partitions
FetchBufferMemory1000MB unless configuredBounds queued and in-flight fetch responses (pipeline depth × adaptive fetch maximum)
PrefetchPipelineDepth5Prefetches aggressively to hide network latency
ConnectionsPerBroker3 (standalone consumers)Two fetch connections plus one coordination connection
AdaptiveFetchSizingEnabledGrows fetch sizes while the consumer keeps up and shrinks them under prefetch memory pressure
CheckCrcsfalseSkips client-side CRC32C re-validation; re-enable with WithCheckCrcs(true) after the preset

Best for: Batch processing, ETL pipelines, analytics

ForLowLatency​

Optimized for processing messages as quickly as possible:

using Dekaf;

var consumer = await Kafka.CreateConsumer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithGroupId("my-group")
.ForLowLatency()
.BuildAsync();

Settings applied:

SettingValueEffect
MaxPollRecords100Smaller batches
FetchMinBytes1Return immediately
FetchMaxWaitMs100msReduce waiting

Best for: Real-time processing, alerts, notifications

Overriding Preset Values​

Presets are just starting points. Override any setting by calling the appropriate method after the preset:

using Dekaf;
using Dekaf.Compression;
using Dekaf.Compression.Lz4;

CompressionCodecRegistry.Default.AddLz4();

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForHighThroughput()
.WithAcks(Acks.All) // Override: want reliability too
.WithLinger(TimeSpan.FromMilliseconds(200)) // Override: even more batching (preset uses 100ms)
.BuildAsync();

The order matters - later calls override earlier ones:

using Dekaf;

// Final linger is 0 and batch size is 256KB (from ForLowLatency).
// Final acks is All: ForLowLatency sets Acks.Leader, but BuildAsync()
// overrides it to All because idempotence is enabled by default.
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForReliability() // Sets Acks.All
.ForLowLatency() // Overrides to Acks.Leader, linger 0, batch size 256KB
.BuildAsync();

Combining Presets with Security​

Presets work alongside security configuration:

using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("kafka.example.com:9093")
.UseTls()
.WithSaslScramSha512("username", "password")
.ForReliability() // Performance preset
.BuildAsync();

Custom Presets​

Create your own preset extensions for consistency across your application:

using Dekaf;
using Dekaf.Compression;
using Dekaf.Compression.Lz4;

CompressionCodecRegistry.Default.AddLz4();

// Usage
var producer = await Kafka.CreateProducer<string, Order>()
.WithBootstrapServers("localhost:9092")
.ForOrderProcessing()
.BuildAsync();

public static class DekafPresets
{
public static ProducerBuilder<TKey, TValue> ForOrderProcessing<TKey, TValue>(
this ProducerBuilder<TKey, TValue> builder)
{
return builder
.ForReliability()
.UseLz4Compression()
.WithLinger(TimeSpan.FromMilliseconds(1)); // Slight batching for efficiency
}

public static ConsumerBuilder<TKey, TValue> ForOrderProcessing<TKey, TValue>(
this ConsumerBuilder<TKey, TValue> builder)
{
return builder
.WithOffsetCommitMode(OffsetCommitMode.Manual)
.WithAutoOffsetReset(AutoOffsetReset.Earliest)
.ForLowLatency();
}
}

Choosing a Preset​

ScenarioProducer PresetConsumer Preset
Log aggregationForHighThroughputForHighThroughput
Metrics collectionForHighThroughputForHighThroughput
Real-time alertsForLowLatencyForLowLatency
Order processingForReliabilityForLowLatency
Financial transactionsForReliabilityForLowLatency
ETL pipelinesForHighThroughputForHighThroughput
Chat messagesForLowLatencyForLowLatency
Audit logsForReliabilityForHighThroughput

What If No Preset Fits?​

If none of the presets match your needs, configure settings individually:

using Dekaf;
using Dekaf.Compression;
using Dekaf.Compression.Zstd;

CompressionCodecRegistry.Default.AddZstd();

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.All)
.WithLinger(TimeSpan.FromMilliseconds(2))
.WithBatchSize(32768)
.WithIdempotence(true)
.UseZstdCompression()
.BuildAsync();

See Producer Options and Consumer Options for all available settings.