// Module included in the following assemblies:
//
// upgrade/assembly-upgrade-kafka.adoc

[id='con-strategies-for-upgrading-clients-{context}']

= Strategies for upgrading clients

[role="_abstract"]
Upgrading Kafka clients ensures that they benefit from the features, fixes, and improvements that are introduced in new versions of Kafka. 
Upgraded clients maintain compatibility with other upgraded Kafka components.
The performance and stability of the clients might also be improved.

Consider the best approach for upgrading Kafka clients and brokers to ensure a smooth transition.
The chosen upgrade strategy depends on whether you are upgrading brokers or clients first. 
Since Kafka 3.0, you can upgrade brokers and client independently and in any order.
The decision to upgrade clients or brokers first depends on several factors, such as the number of applications that need to be upgraded and how much downtime is tolerable.

If you upgrade clients before brokers, some new features may not work as they are not yet supported by brokers. 
However, brokers can handle producers and consumers running with different versions and supporting different log message versions.

.Upgrading clients when using Kafka versions older than Kafka 3.0

Before Kafka 3.0, you would configure a specific message format for brokers using the `log.message.format.version` property (or the `message.format.version` property at the topic level). 
This allowed brokers to support older Kafka clients that were using an outdated message format. 
Otherwise, the brokers would need to convert the messages from the older clients, which came with a significant performance cost.

Apache Kafka Java clients have supported the latest message format version since version 0.11. 
If all of your clients are using the latest message version, you can remove the `log.message.format.version` or `message.format.version` overrides when upgrading your brokers.

However, if you still have clients that are using an older message format version, we recommend upgrading your clients first. 
Start with the consumers, then upgrade the producers before removing the `log.message.format.version` or  `message.format.version` overrides when upgrading your brokers. 
This will ensure that all of your clients can support the latest message format version and that the upgrade process goes smoothly.

You can track Kafka client names and versions using this metric:

* `kafka.server:type=socket-server-metrics,clientSoftwareName=<name>,clientSoftwareVersion=<version>,listener=<listener>,networkProcessor=<processor>`  

[TIP]
====
The following Kafka broker metrics help monitor the performance of message down-conversion:

* `kafka.network:type=RequestMetrics,name=MessageConversionsTimeMs,request={Produce|Fetch}` provides metrics on the time taken to perform message conversion. 
* `kafka.server:type=BrokerTopicMetrics,name={Produce|Fetch}MessageConversionsPerSec,topic=([-.\w]+)` provides metrics on the number of messages converted over a period of time.  
====