Smooth Migration from Client-Side to Proxy-Side Sharding in Database Architecture
The article explains how to transition from client‑side sharding with Sharding‑JDBC to proxy‑side sharding using Rainbow Bridge DAL by adding new, switchable data sources, employing AbstractRoutingDataSource and configuration flags for gradual migration, while addressing read‑write separation, unsupported SQL functions, and ensuring backward compatibility.
This article discusses the migration from client-side sharding to proxy-side sharding in database architecture, specifically using ShardingSphere and Rainbow Bridge DAL. The author explains the background of database horizontal splitting due to increasing order volumes and high traffic during promotions. Client-side sharding using Sharding-JDBC offers simplicity and high performance but lacks centralized management and requires individual project upgrades. Proxy-side sharding through Rainbow Bridge DAL provides centralized management, traffic control, shadow database support for testing, and slow SQL monitoring.
The article presents two migration approaches: directly modifying old data sources to connect to Rainbow Bridge (fast but risky) and adding new data sources with switchable configuration (more stable and rollback-friendly). The recommended approach involves adding new data sources, implementing dynamic switching through AbstractRoutingDataSource, and using configuration switches for gradual migration. Key implementation steps include configuring dual data sources, adding dynamic data source management, using @ConditionalOnProperty for old data source control, ensuring read-write separation compatibility, and rewriting sharding algorithms.
Important considerations include handling unsupported select last_insert_id() operations, implementing forced slave node queries through HintManagerHolder.clear() compatibility, and using @ForceSlave annotations for elegant query routing. The article provides code examples for SqlHintUtils class and migration steps, emphasizing the importance of backward compatibility and smooth transition strategies.
DeWu Technology
A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.