Kafka partition = unit of parallelism + ordering. Producer hash(key) % numPartitions → which partition receives the message. Same key always same partition. Null key → round-robin (or sticky-batched in newer clients).
Changing partition count breaks the hash mapping. Plan partitions for peak parallelism and don't change frequently. Consumer count ≤ partition count.