GitHub user hubcio closed a discussion: Support sending messages in the
background
At 25.02.2025 there was interesting discussion on discord.
The discussion revolved around performance optimizations and feature
enhancements in iggy compared to Kafka. Participants debated strategies such as
sticky partitioning, batching, and compression, noting that intelligent client
implementations have a significant impact on overall throughput and latency.
They compared Kafka’s round-robin partitioning with sticky partitioning,
emphasizing that filling one partition’s batch before moving to the next can
greatly improve performance and cost efficiency by reducing network load.
The conversation also touched on API for sending messages in background and
error handling during background sends. Participants discussed the merits of
different failure handling strategies, such as blocking until a send succeeds,
blocking with a timeout, or failing immediately. To address these options, they
proposed introducing a new enum, `IggyBackgroundSendFailureMode`, which would
allow clients to choose the desired behavior when a background send fails.
As a summary of this discussion, I propose task to support this API:
Create an extension for the `IggyProducerBuilder` that introduces configurable
parameters for background sending.
Changes in existing fields:
- `batch_size` - should be changed to `batch_length`.
- `send_interval` - should be changed to `linger_time`, determines how long
messages should remain in the queue before sending
Add new fields (optional?):
- `background_send` - determines if send in background functionality should be
enabled
- `batch_size` - value (in bytes) of how much data should be buffered before
sending
- `maximum_buffer_size` - maximum value (in bytes) of buffered data, if
exceeded error will be reported (see `IggyBackgroundSendFailureMode`)
- `failure_mode` - determines behavior of `send_messages` when buffer is full
(or in general on failure)?
Ensure that the new API integrates seamlessly with the current `send_messages`
method, providing optional background sending.
Handle all cases with conflicting parameters set in builder, e.g.
`maximum_buffer_size` should not be set when `background_send` is set to false.
Is is not certain how errors on send should be handled when buffer is not full.
Perhaps error channel to communicate errors would be sufficient.
Proposal of enum:
```rust
/// Determines how the `send_messages` API should behave when problem is
encountered
#[derive(Debug, Clone)]
pub enum IggyBackgroundSendFailureMode {
/// Block until the send succeeds
Block,
/// Block with a timeout, after which the send fails
BlockWithTimeout(IggyDuration),
/// Fail immediately without retrying
FailImmediately,
}
```
@spetz @numinnex what's your opinion on this?
GitHub link: https://github.com/apache/iggy/discussions/1593
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]