Optimizing your Kafka Cluster depends upon your cluster usage & use-case.
Based on your main concern like throughput or CPU utilization or Memory/Disk usage, you need to modify different parameters and some changes may have an impact on other aspects. For example, if acknowledgments is set to "all", all brokers that replicate the partitions need to acknowledge that the data was written prior to confirming the next message needs to be sent. This will ensure data consistency but increase CPU utilization and network latency.
Refer Benchmarking Apache Kafka: 2 Million Writes Per Second (On Three Cheap Machines) article written by Jay Kreps(Co-founder and CEO at Confluent).
Please let me know if this helps.