Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve send via adding separate, per-segment tokio task #1324

Open
linear bot opened this issue Nov 3, 2024 · 0 comments
Open

Improve send via adding separate, per-segment tokio task #1324

linear bot opened this issue Nov 3, 2024 · 0 comments
Assignees
Labels
performance Change impacts performance server iggy-servere related change

Comments

@linear
Copy link

linear bot commented 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:

  • 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.

@linear linear bot added performance Change impacts performance server iggy-servere related change labels Nov 3, 2024
@hubcio hubcio self-assigned this Nov 3, 2024
@linear linear bot 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
@hubcio hubcio assigned haze518 and unassigned hubcio Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Change impacts performance server iggy-servere related change
Projects
None yet
Development

No branches or pull requests

2 participants