apisix icon indicating copy to clipboard operation
apisix copied to clipboard

feat: dynamic partition key for each request in kafka-logger plugin

Open icy-fish opened this issue 1 month ago • 1 comments

Description

I'm using APISIX as my LLM gateway to proxy LLM request and collection agent trajectory data, send those data to Kafka, then processed by logstash.

To ensure requests in single agent chat session being processed in the order of its original sending sequence, the best way may be enqueue requests of a single user into a specified Kafka partition, that means I need to ensure same kafka-logger "key" config for a specified user.

Existing kafka-logger can only set a fixed string as "key" for single route, means all requests processed by this route will go to same kafka partition. This can partly solve my issue, but comes out a new problem: only 1 Kafka partition being used, then only 1 consumer(Logstsh) can actually work to ensure logs being processed orderly, I cannot scale-up my service to increase throughput.

So the best solution may be set unique kakfa-logger "key" for a single user, which in my case, can be extracted from HTTP request header, like "x-auth-token".

Hope you can considering this feature, thanks!

icy-fish avatar Oct 12 '26 02:10 icy-fish

Hi, I'd like to contribute to this feature. I plan to investigate how the Kafka Logger currently handles message keys and how request-derived values could be supported while preserving the existing static-key behavior. Is anyone already working on this, and would it be okay for me to take it on?

aryan9948 avatar Oct 12 '26 19:10 aryan9948