中文
首页/案例/Apache ShardingSphere & JD Baitiao: Story of an Implementation Journey

Apache ShardingSphere & JD Baitiao: Story of an Implementation Journey

Apache ShardingSphere has become the best solution for JD Baitiao’s very large storage scenarios and scale-up. JD’s shopping festival weighed very much on our big data storage. I mean, like hundreds of millions of data sets.
2021/12/12by SphereEx
JD Technology Group is a business subgroup of JD Group that focuses on technology as an industry service, and is committed to providing technical products and solutions for enterprises, financial institutions, governments and other types of customers across the value chain.

Apache ShardingSphere has become the best solution for JD Baitiao’s very large storage scenarios and scale-up. JD’s shopping festival weighed very much on our big data storage. I mean, like hundreds of millions of data sets.

JD Baitiao, an internet credit products provider launched in 2014, has always been challenged by data explosion. Every shopping festival is like a technical test for us, but every time the technical staff professionals take proactive strategic initiatives in data architecture development to ensure everything goes smoothly.

— Dongfang Zhang,JD Batiao R&D Director

The Baitiao Data Architecture Evolution

Launched in Feb. 2014, JD Baitiao’s data architecture has already evolved for several times because of rapid increase in data volume and rapid business growth.

From 2014 to 2015

Baitiao first adopted the Solr + HBase solution to connect core business systems and other systems with key databases. Solr indexing is able to achieve fast search responses and HBase is used to store a massive amount of data.

  • A Solr cluster can help the core database reduce reads and writes stress.
  • However, Solr is not perfect: it has unsatisfying extensibility and intrusions.

From 2015 to 2016

The company chose NoSQL to store monthly data tables in Mongo DB clusters, temporarily meeting the demand for importing/exporting massive data in payment settlement scenarios.

  • The change made it quite efficient to query hot data. In addition, thanks to such unstructured data storage, staff can easily modify table structures.
  • Nevertheless, the plan was still problematic: bad extensibility, intrusions, and memory hog.

From 2016 to 2017

Growing business and growing data. Tens of billions of data volume imposed more performance and volume pressure on MongoDB. JD Baitiao’s Big Data Platform used DBRep and MySQL Slave to capture data changes and store the information data in its message center, to later be written to ES and HBase.

  • This plan was actually much better. It focused on real-time data and improved extensibility.
  • However, Baitiao faced high costs to maintain its code because of the data sharding problem in its architecture.

The architecture evolution of JD Baitiao is just an illustration of rapidly growing Internet consumer finance. All the methods Baitiao adopted in the past were not comprehensive, indicating that every solution would be outdated soon.

Time to Adopt a Decoupled Architecture

To ensure good system performance even with rapidly increasing data volumes, the technical team first chose the sharding architecture pattern that not only guaranteed excellent performance, but also kept code under control.

The data striping plan was actually based on application architecture:

The product continuously developed but the early solution had now become one of the biggest problems. The old data sharding plan makes code even more complex and increases maintenance expenditure. Developers have to spend much time adjusting sharding every time when the application upgrades, so they cannot concentrate on their own developments. In fact, tight coupling is to blame for the problem.

Therefore, the team decided to use a mature sharding component that simplifies system upgrades and architecture changes. To compare Baitiao’s shard and ShardingSphere shard, their differences are shown in the following table.

jd_en_1.png

For Baitiao, decoupling was the next task.

Apparently, JD Baitiao‘s data architecture will experience a brand-new journey to decoupling. The following three directions definitely fueled its transformation:

Concentration: instead of database sharding built in its architecture, it applied a sharding component to place more energy on it own product development.

Easier Upgrade: it used a decoupled architecture to simplify the R&D process of system upgrades.

Future-Oriented Plan: it aims to improve system extensibility so that Baitiao will be more capable of confidently holding large online shopping festivals like the 618 Shopping Festival and Double 11 Shopping Festival (also known as Singles Day on November 11th).

JD Baitiao is a huge business, so its business scenario is truly related to finance, high concurrency, and massive data volumes. Baitiao’s sharding component must have the following features:

  1. Be a mature product
  2. Have excellent performance
  3. Be able to handle big data
  4. Have an extensible architecture

The Apache ShardingSphere Solution

The lightweight Java framework ShardingSphere-JDBC is Apache ShardingSpheres’s first product providing services such as a Java Database Connectivity (JDBC) API. ShardingSphere JDBC uses jar archive file installation package and allows the client-side to directly connect to databases. So, it requires no extra deployment dependencies. It is like an enhanced JDBC driver fully compatible with JDBC and ORM frameworks.

ShardingSphere — JDBC provides the following features, making it the best solution in the Baitiao scenario.

Mature Product: ShardingSphere — JDBC is a mature product developed for years, and its open source community is very active.

Excellent Performance: its micro-kernel and lightweight design hardly hinder performance.

Minimum Changes: it supports native MySQL protocol and minimizes R&D workload.

Extensibility: users can combine with the migration sync component to easily extend data.

jd_en_2.png

After being systematically tested for several times, Apache ShardingSphere became JD Baitiao’s first choice of data sharding middleware. The cooperation started at the end of 2018.

Product Adaptation

To provide Baitiao with better services and support the business, Apache ShardingSphere has made many improvements to its product features and performance during the implementation process. At the same time, the user case helps optimize the product in return.

Upgrade the SQL Engine

Baitiao’s business logic is extremely complicated; its diversified scenario demands require the best SQL compatibility levels. Thus, Apache ShardingSphere restructures the SQL parser module to support more SQLs.

  • Single data node routing: 100% SQL compatibility
  • Multi data node routing:comprehensively support DML, DDL, DCL, TCL and partly DAL. Support features such as pagination, deduplication, ranking, grouping, aggregation and correlated query.

Distributed Key

Apache ShardingSphere provides built-in distributed key generators, such as UUID, and SNOWFLAKE. It also provides its distributed key generation API so that users can develop custom key generation algorithms to meet their special needs.

Shard Key Value Injection

If a SQL has no shard condition, Apache ShardingSphere uses ThreadLoad to manage shard key value, and users can program and add a shard condition to HintManager, making the condition only effective in the current thread. That’s so-called SQL zero intrusion.

Additionally, Apache ShardingSphere continues to optimize its other features in order to meet Baitiao’s need for high performance such as:

  • SQL parsing result cache
  • JDBC metadata cache
  • Bind table & Broadcast table
  • Automated execution engine & Stream merge

JD Baitiao & ShardingSphere teams joint efforts amde all indicators of the product live up to their expectation. The resulting final performance is almost the same as that of a native JDBC.

jd_en_3.png

Cutover

Apache ShardingSphere uses its custom HASH strategy to shard data, effectively avoiding the hot data problem. The total of data nodes almost reaches ten thousand. The cutover process lasts for about 4 weeks.

  1. After DBRep reads data, Apache ShardingSphere synchronizes the data to the target database cluster.
  2. Two clusters run together. After a data migration, Baitiao uses its own tool to verify business and data.

DBRep is fundamental to the product design of ShardingSphere-Scaling. The automation feature of Scaling definitely facilitates migration and scale-up.

Apache ShardingSphere Brings Many Benefits

Simplified Upgrade Path

The decoupled architecture effectively simplifies a technology stack required in a system upgrade, so the developer team no longer need to worry about table sharding. Instead, they can focus on the business itself. In brief, ShardingSphere greatly helps Baitiao optimize the upgrade path.

Save R&D Cost

Baitiao directly uses the mature product Apache ShardingSphere, so they do not need to reinvent the wheel and save a lot of time and energy.

Improve Architecture Extensibility

Baitiao also uses the sync migration component Scaling that makes system scale-up even more flexible. It’s the company’s secret for online shopping festival successes.

Summary

The growth of JD Baitiao’s business greatly stimulates its data architecture upgrades. This time, it chose Apache ShardingSphere to decouple its architecture and make future upgrades less complicated. Thank to this from now on, developers only have to concentrate on their own product optimization because its data architecture is extensible enough. The case is really a good example of ShardingSphere application in the consumer finance scenario.

Now, there are more and more internet credit payment models. In the future, Apache ShardingSphere in collaboration with JD Technology will explore more business scenarios, and contribute finance-related technological innovations, further improving Internet finance.

About Apache ShardingSphere

ShardingSphere is one of the Apache Software Foundation Top-Level Open Source projects, used by over 170 enterprises worldwide, across various verticals such as finance, e-commerce, cloud services, tourism, logistics, education, and entertainment. Its GitHub community has so far cumulated over 14,000 stars.

We welcome more technical professionals to write articles and share their experiences and thoughts. If you are interested, feel free to contact us:

ShardingSphere Github: https://github.com/apache/shardingsphere

ShardingSphere Twitter: https://twitter.com/ShardingSphere

ShardingSphere Slack Channel: apacheshardingsphere.slack.com

分享文章
wechat qrcode

扫码关注
微信公众号

Apache ShardingSphere & iQiyi: What's Database Mesh?
eHualu Story’s Data Processing Shortcut

推荐阅读

Apache ShardingSphere & Energy Monster

NASDAQ-listed Energy Monster is the largest provider of mobile device charging services in Asia. This article illustrates how Energy Monster uses ShardingSphere-JDBC.

Apache ShardingSphere & China Unicom Digital Technology: Ensuring Stability, Efficiency, and Replicability at Scale

China Unicom Digital Technology, a global telco operator with 310 million subscribers, chose ShardingSphere to manage its gov and enterprise hotlines data infrastructure.

Heterogeneous migration: reducing Dangdang’s customer system RTO 60x and increasing speed by 20%

E-commerce giant DangDang rebuilt its architecture & migrated 350M users with ShardingSphere & MySQL. RTO improved 60x, response speed by 20%, and introduced cross-data source double write, R/W split, and intelligent gateway innovations.

Apache ShardingSphere & Bilibili

The ShardingSphere community visited one of its enterprise users: the major Chinese video-on-demand streaming platform - Bilibili. Originally known for anime, comics & games, Bilibili has since expanded - as did its total users.

Apache ShardingSphere & Huimin: Huimin’s Transaction Middle Platform Architecture

HuiMin does order fulfillment for over 1 million supermarkets. With ShardingSphere HuiMin shifted to microservices & built a new "middle platform" architecture with packaged business capability for order transaction processing.
即刻免费体验新一代数据库增强引擎
400-900-2818 GitHub
合作伙伴:中国信通院重庆大学ShardingSphere
Privacy PolicyTerms Of UseDisclaimerCookie PolicyDo Not Sell My Personal Information
wechat qrcode

扫码关注
微信公众号