Sobes.tech
Middle+

How many partitions were in the topics and how was their number chosen?

sobes.tech AI

Answer from AI

The number of partitions in topics is usually chosen based on performance, scalability, and message processing parallelism requirements.

Main factors when choosing the number of partitions:

  • Performance and parallelism: The more partitions, the more consumers can read from the topic in parallel, increasing throughput.
  • Cluster resources: Each partition requires resources (memory, file descriptors), too many partitions can negatively affect stability.
  • Load balancing: Partitions allow for even distribution of data and load among brokers.
  • Data volume and write speed: With large volumes and high write speeds, more partitions help avoid bottlenecks.

For example, if you have 3 brokers and want to ensure parallel processing with 6 consumers, you can create 6 partitions so each consumer can read from its own partition.

Ultimately, the number of partitions is chosen based on load analysis, the number of consumers, and infrastructure capabilities. This number is usually fixed when creating the topic but can be increased later if needed.