简体   繁体   中英

How to choose Kafka transaction id for several applications, hosted in Kubernetes?

I have a classic microservice architecture. So, there are differ applications. Each application may have 1..N instances. The system is deployed to Kubernetes. So, we have many differ PODs , which can start and stop in any time.

I want to implement read-process-write pattern, so I need Kafka transactions.

To configure transactions, I need to set some transaction id for each Kafka producer. (Actually, I need transaction-id-prefix , because of I use Spring for my applications, and it has such API ). These IDs have to be the same, after application is restarted.

So, how to choose Kafka transaction id for several applications, hosted in Kubernetes?

If the consumer starts the transaction (read-process-write) then the transaction id prefix must be the same for all instances of the same app (so that zombie fencing works correctly after a rebalance). The actual transaction id used is <prefix><group>.<topic>.<partition> .

If you have multiple apps, they should have unique prefixes (although if they consume from different topics, they will be unique anyway).

For producer-only transactions, the prefix must be unique in each instance (to prevent kafka fencing the producers).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM