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

enhancement(loki sink): Partition HTTP requests to loki by stream & re-enable concurrency #8615

Merged
merged 18 commits into from
Aug 21, 2021

Conversation

ktff
Copy link
Contributor

@ktff ktff commented Aug 6, 2021

Closes #6041
Closes #6932

This PR adds partitioning of requests by stream, on top of the already partitioning by tenant. To enable this, inner struct PartitionBatchSink is also extended with ability to order requests per partition. This ordering guarantee could maybe be useful as a configurable option on some other sinks.

As a side effect, to test this, concurrency in the sink is also re-enabled.

ktff added 8 commits August 3, 2021 20:39
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
@ktff ktff added type: enhancement A value-adding code change that enhances its existing functionality. sink: loki Anything `loki` sink related labels Aug 6, 2021
@ktff ktff self-assigned this Aug 6, 2021
@netlify
Copy link

netlify bot commented Aug 6, 2021

✔️ Deploy Preview for vector-project canceled.

🔨 Explore the source changes: 20a581a

🔍 Inspect the deploy log: https://app.netlify.com/sites/vector-project/deploys/6121181b1023e300082dd781

Signed-off-by: ktf <krunotf@gmail.com>
@ktff ktff requested a review from bruceg August 6, 2021 12:02
ktff added 4 commits August 6, 2021 14:18
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
src/sinks/loki.rs Outdated Show resolved Hide resolved
Comment on lines +811 to +815
// So, since all of the events are of the same partition, and if there is concurrency,
// then if ordering inside paritions isn't upheld, the big line events will take longer
// time to flush than small line events so loki will receive smaller ones before large
// ones hence out of order events.
test_out_of_order_events(OutOfOrderAction::Drop, batch_size, events.clone(), events).await;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this test is fundamentally racy, isn't it? Is there any way to provoke out of order events without racing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is.

Is there any way to provoke out of order events without racing

Not really. There are two more ways to provoke them:

  • Fail requests and force them to retry.
    • This isn't quite testing what it needs too since retry logic can correct this.
    • A mock loki server which we can configure to fail requests would be needed.
  • Stall the start of the server so that requests pile up.
    • This is yet again racy.

What we can do is to increase the number of events to increase the chance of out of order event happening.

src/sinks/util/sink.rs Show resolved Hide resolved
src/sinks/util/sink.rs Outdated Show resolved Hide resolved
src/sinks/util/sink.rs Outdated Show resolved Hide resolved
ktff added 3 commits August 18, 2021 17:00
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
@ktff ktff requested a review from bruceg August 20, 2021 16:28
src/sinks/loki.rs Outdated Show resolved Hide resolved
@jszwedko
Copy link
Member

jszwedko commented Aug 20, 2021

@ktff It'd be nice to merge this by Monday if we can to get it into the next release. I see it approved but just want to make sure you didn't want to make any other tweaks. Nice work on re-enabling concurrency here; it'll make a lot of people happy.

ktff added 2 commits August 21, 2021 16:45
Signed-off-by: ktf <krunotf@gmail.com>
Signed-off-by: ktf <krunotf@gmail.com>
@ktff ktff merged commit dc57c2b into master Aug 21, 2021
@ktff ktff deleted the ktff/loki_streams branch August 21, 2021 17:37
@wgb1990
Copy link

wgb1990 commented Sep 1, 2021

@ktff Hi,partitioning of requests by stream is not suitable for the role of aggregator,because there will be a large number of label combinations in the aggregator, which eventually leads to the slow sending of Loki. In my case, the final events are stacked in the buffer.

@ktff
Copy link
Contributor Author

ktff commented Sep 1, 2021

@wgb1990 by buffer if I assume you mean batch. Events shouldn't be in batch more than batch.timeout_secs, where default value is 1 sec. If you are still seeing events being in batch for a longer period of time, open a issue for it since that would be a bug.

which eventually leads to the slow sending of Loki

If on the other hand you mean that throughput is low because you have a large number of streams but only a few events per stream per second, true, the older solution would be better for that use case. That is doable, so in that case open a feature issue with your use case. I imagine it could be done with a simple enum option or something more dynamic.

@wgb1990
Copy link

wgb1990 commented Sep 2, 2021

@ktff #8998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sink: loki Anything `loki` sink related type: enhancement A value-adding code change that enhances its existing functionality.
Projects
None yet
4 participants