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:

using Dekaf;

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

Settings applied:

SettingValueEffect
AcksLeaderFaster acknowledgment
LingerMs5Allows batching
BatchSize64KBLarger 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
AcksLeaderFast acknowledgment
LingerMs0No batching delay
BatchSize16KBSmaller batches

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

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
EnableIdempotencetruePrevent 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
FetchMaxWaitMs500msAllow batching

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;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForHighThroughput()
.WithAcks(Acks.All) // Override: want reliability too
.WithLingerMs(10) // Override: even more batching
.BuildAsync();

The order matters - later calls override earlier ones:

using Dekaf;

// Final acks will be Leader (from ForLowLatency)
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForReliability() // Sets Acks.All
.ForLowLatency() // Overrides to Acks.Leader
.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;

public static class DekafPresets
{
public static ProducerBuilder<TKey, TValue> ForOrderProcessing<TKey, TValue>(
this ProducerBuilder<TKey, TValue> builder)
{
return builder
.ForReliability()
.UseLz4Compression()
.WithLingerMs(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();
}
}

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

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;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.All)
.WithLingerMs(2)
.WithBatchSize(32768)
.EnableIdempotence()
.UseZstdCompression()
.BuildAsync();

See Producer Options and Consumer Options for all available settings.