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

(Why not) use message batching? #273

Open
SimonHeybrock opened this issue Nov 21, 2024 · 5 comments
Open

(Why not) use message batching? #273

SimonHeybrock opened this issue Nov 21, 2024 · 5 comments

Comments

@SimonHeybrock
Copy link
Member

SimonHeybrock commented Nov 21, 2024

One of the things Beamlime does is to consume, say, 14 ev44 messages per second, push them through the internal message router, collect them for a time interval, concat and hand them to the data reduction handler via the internal message router.

Can we just use message batching? That might significantly simplify the logic.

@YooSunYoung
Copy link
Member

How exactly batch them...?

@SimonHeybrock
Copy link
Member Author

Not sure exactly how it would work in practice, but something like

messages = detector_consumer.consume(num_messages=20, timeout=1.0)

@YooSunYoung
Copy link
Member

YooSunYoung commented Nov 26, 2024

If it's about consuming multiple messages at once, yes, we should probably do that.

But I didn't do that since that timeout blocks the whole process.

AOI kafka seems to have a better interface for that and it probably doesn't block the event loop:

https://aiokafka.readthedocs.io/en/stable/api.html#aiokafka.AIOKafkaConsumer

It also supports batch processing of messages but it seems like it only works if producer publishes messages in batch according to this documentation: https://docs.confluent.io/kafka/design/efficient-design.html ...?

@SimonHeybrock
Copy link
Member Author

That is not how understood the mechanism. The consumer can decide how to fetch. Obviously, if we fetch too frequently we may only get a single message. But if we are willing to accept some more latency (which we also have with the "manual" beamlime-side batching) then we can fetch batches.

@YooSunYoung
Copy link
Member

The consumer can decide how to fetch.

Yes. What I said is, the batch messages of kafka and consuming multiple messages are two different concepts.

But if we are willing to accept some more latency (which we also have with the "manual" beamlime-side batching) then we can fetch batches.

Yeah, but beamlime-side batching is to concatenate each fields of the dataset. How can it be handled by consumer itself...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants