Kafka partition synchronization strategy
When you configure a data synchronization job to Kafka, you can adjust the Kafka partition synchronization strategy to improve performance. For example, you can synchronize data to different partitions based on hash results.
Hash algorithm
DTS uses Java’s default hashcode algorithm to calculate hash values.
Configuration method
Configure the Policy for Shipping Data to Kafka Partitions during the Configure Objects step of your data synchronization job.
After you start the data synchronization job, do not change the number of partitions in the destination topic. Otherwise, the synchronization task may fail or result in data inconsistency for downstream consumers.
Strategy details
Source database is Kafka
| Policy | Description | Advantage and disadvantage |
| Ship All Data to Partition 0 | Migrates all data and DDL statements to Partition 0 of the destination topic. |
|
| Ship Data to Separate Partitions Based on Hash Values of Database and Table Names | Uses the database and table names as the partition key to calculate the hash value, then migrates the data and DDL statements of each table to the corresponding partition of the destination topic. Note
|
|
| Ship Data to Separate Partitions Based on Hash Values of Primary Keys | Uses a table column as the partition key to calculate the hash value. By default, the primary key is used. If a table does not have a primary key, the unique key is used instead. Each row is migrated to the corresponding partition of the destination topic. You can also specify one or more columns as partition keys. Note
|
|
Source database is Tair/Redis
|
Policy Name |
Description |
Pros and cons |
|
Ship All Data to Partition 0 |
Deliver all data and DDL information to Partition 0 of the destination topic. |
|
|
Ship the full data and incremental data of an ApsaraDB for Redis instance to separate partitions |
Deliver full data and incremental data from the Redis instance to different partitions in the destination topic. |
|
|
Ship data to separate partitions based on hash values of Redis Keys |
Use the Redis key as the partition key to compute a hash value. Then, deliver both full and incremental data to different partitions in the destination topic. |
|
Source database is another database
|
Policy Name |
Description |
Pros and cons |
|
Ship All Data to Partition 0 |
Deliver all data and DDL information to Partition 0 of the destination topic. |
|
|
Ship Data to Separate Partitions Based on Hash Values of Database and Table Names |
Combine the database name and table name as the partition key to compute a hash value. Then, deliver each table’s data and DDL information to different partitions in the destination topic. Note
|
|
|
Ship Data to Separate Partitions Based on Hash Values of Primary Keys |
Use table columns (by default, the primary key. If no primary key exists, use a unique key) as the partition key to compute a hash value. Then, deliver different rows to different partitions in the destination topic. You can also specify one or more columns as the partition key. Note
|
|