You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when messages are being received by iggy-server (SDK users call SendMessages API) the packet response is sent to user after messages batch processed, which means:
whole batch is acknowledged and verified
whole batch is stored into SmartCache (if cache is enabled)
if reached messages_required_to_save count, then iggy-server in context of this very request is calling tokio write or write_all
Last step is taking most time. If batch size is 1000, and messages_required_to_save is 5000, then every 5th request server has to write 5000 messages to disk inside it's busy loop, so other requests cannot be processed in the mean time, when server is writing the data.
The aim of this task is to add a new tokio task, which will handle writing to disk, so server can handle other requests, without waiting for data to be written for every SendMessages request.
This task should be part of Segment, and it should:
be able to receive whole batch of messages via channel (e.g. tokio or flume)
be able to write above messages to disk
have API for saving messages that works like fire and forget (receive messages and save to disk)
have API for saving messages that works like request-response (receive messages and send response back when write is done)
All communication with this tokio task should be done via channels, and it should expose nice API that can be called by Segement. Channels should be NOT visible outside. They should be only part of API implementation.
This is kind-of dangerous, because when cache is disabled these messages will not be able to be polled by users - this is risk we are ready to take.
The text was updated successfully, but these errors were encountered:
linearbot
changed the title
Improve send via asynchronous saving messages in separate tokio task per segment
Improve send via adding separate, per-segment tokio task
Nov 3, 2024
Currently, when messages are being received by iggy-server (SDK users call
SendMessages
API) the packet response is sent to user after messages batch processed, which means:SmartCache
(if cache is enabled)messages_required_to_save
count, then iggy-server in context of this very request is calling tokiowrite
orwrite_all
Last step is taking most time. If batch size is 1000, and
messages_required_to_save
is 5000, then every 5th request server has to write 5000 messages to disk inside it's busy loop, so other requests cannot be processed in the mean time, when server is writing the data.The aim of this task is to add a new tokio task, which will handle writing to disk, so server can handle other requests, without waiting for data to be written for every
SendMessages
request.This task should be part of
Segment
, and it should:write
is done)All communication with this tokio task should be done via channels, and it should expose nice API that can be called by
Segement
. Channels should be NOT visible outside. They should be only part of API implementation.This is kind-of dangerous, because when cache is disabled these messages will not be able to be polled by users - this is risk we are ready to take.
The text was updated successfully, but these errors were encountered: