"Abstract" in this paper, a two-tier distributed database architecture is established by introducing the memory database layer. This scheme is used to solve the problem of data storage and access in massive and high concurrency systems, especially for the complex and complex Internet stations of electronic commerce and other data models. These years the Internet station develops rapidly, in order to deal with the high concurrent access under the massive data, has produced each kind of distributed architecture design idea, for instance Key-value engine, data partition and so on. And for E-commerce sites, a large number of data problems still have an important feature, is the data structure and the relationship between the information, Taobao so, Alibaba is so, this is with the community, video, blog and other internet sites of significant differences.
1. Is NoSQL a panacea? NoSQL, Key-value engines such as BigTable, Cassendra and so on in many large Web sites are adopted, a good solution to the massive data storage and access problems. For E-commerce sites, Key-value and NoSQL are not the panacea for this problem. Most of them can only be used for some simple data model applications.
There are two reasons for this:
1 Data model complex Taobao and Alibaba members, baby, supply and demand, orders and other core Entity Data Model complex, the number of attributes dozens of to hundreds. For example: Members (Member) contains basic information, contacts, industry and commerce, accounts and other fields of information, in addition, between the core entities, peripheral entities and core entities there is a complex relationship.
2 complexity of the business: The complexity of the model stems from the complexity of business and logic. E-commerce Site a large number of query scenarios are structured inquiries, such as: Taobao on the query "sellers in Jiangsu, Zhejiang and Shanghai, the price of 50-200 yuan Men's T-shirt," in Alibaba "List a member of all orders to be shipped" such inquiries (of course, Aliba) mainly for multiple Non-key fields, Even for a column-based key-value database such as BigTable, Cassandra, its simple query API is not up to this kind of requirement. So in Alibaba and Taobao, Oracle, MySQL and other relational databases will still play an important role.
2. The MySQL cluster introduces the K-V engine and so on the non relational database is to solve the massive data in the high concurrent environment the efficient reading and writing problem, the maximum degree in the reliable persistence (durable) and the High Access performance (performance) chooses a balance point. In highly structured systems, the same considerations drive us to consider alternative solutions. At present, a common practice is MySQL read-write discrete cluster, 1 or a few master write, most slave read, master and slave to change data synchronization. First of all, this scheme is a lot of practice, reliable and feasible. However, writing directly to DB is still time-consuming (see table 1, table 2), data replication, and possibly inconsistent latency. Is there a quicker solution? 3. Memory relational database The reliable persistence index is stored on devices such as disk. Figure 1 shows the basic access mode for a traditional disk database. Figure 1 is the persistence-driven reliability that data is not stored on disk first, and memory storage performance is much higher than disk storage. The following table shows the performance comparisons for Oracle and Altibase, which have a performance of 5-7 times that of Oracle on inserts and queries. Database test Results TPS Oracle 203 sec 246/sec altibase 28.32 sec 1785/stopwatch 1. Oracle, altibase Performance comparison-insert 50,000 "7" Database test results TPS Oracle 885 sec 112/Sec altibase 170 sec 588/Stopwatch 2 Oracle, altibase Performance Comparison-associated query 100,000 "7" by This is visible: PM >>> Pd (PM-memory Database read-write performance, Pd-disk database read-write performance) combined with the previous analysis of model complexity and business complexity reasons, relational databases (RDBMS) must be used. Therefore, this two-point consideration can be extrapolated to another solution: the memory-type relational database. Disk-type relational database Key-value engine memory relational database function-structured operations and queries y N y performance Low high table 3. DB selection and comparison analysis in this scenario, we can take memory first as a "disk", read and write operations are for the memory database, no longer directly with the disk database interaction, which is better to avoid the simple MySQL read-write separation of the structure of the time delay and consistency problems. As shown in the following illustration: Figure 24. The persisted data of the memory database is eventually to be stored on disk, and changes in the data in the memory database need to be replicated to the disk database. At this point, the process of copying data from memory to disk can be viewed as an asynchronous operation of the original write operation, which showsHowever, asynchronous operations make the front end of the write operation appear faster. As shown in the following illustration: Figure 3 in a transaction type (OLTP) system, the memory database needs to be aligned with the disk database at startup. As a result, the memory database needs to have the same library table definition, and the required library table data is loaded into the memory database at the first boot. 5. Memory database Clustering At present, the classic MySQL cluster, through reading and writing separation, horizontal segmentation, to achieve mass data storage. In order to deal with the massive data storage, the memory database also needs to do the cluster. Vertical and horizontal segmentation strategy, usability strategy and MySQL cluster architecture design is basically the same. As shown in the following figure, Ameoba is a distributed database agent that controls data routing. The only difference is that, because of the high performance of the memory database, you can no longer read and write separation design. Figure 4 6. Mixed partitioning (Hybrid Shard) with the analysis of section 4th, memory data will eventually need to be persisted to disk. A mixed partition (Hybrid Shard) is needed to solve this problem. That is, the original MySQL node to assume a horizontal partition, will be a memory database node and a MySQL node together. H-shard = MDB + MySQL. This database architecture will form a cluster consisting of a two-level database (2LDB), mixed partitions. As shown in the following figure: Figure 5 7. Memory database selection Common memory database products include business and free version of two categories. Commercial edition such as: Altibase,timesten,berkley DB and so on. They are widely used in high-performance computing applications such as telecommunications, finance and securities. The commercial edition is powerful, however, the price is more expensive, is not suitable for the current "cheap pc+ free Software" architecture constructs the idea. I have worked with China Mobile system providers, including billing, operating systems such as the use of TimesTen to provide high-performance operations, but also mainly for the high frequency of small data calculations, such as billing price, preferential calculation, such as the use of single node mode. Open source domain products are mainly h2,hsqldb,derby and so on. In a mixed partitioning architecture, the memory database assumes the responsibility for OLTP, so that, in addition to read and write performance, functional integrity, transactions, and so on need to be a priority assessment factor. 8. The challenges of the new architecture are challenged by introducing a memory database as an intermediate persistence layer and then adding a distributed architecture to support massive data access. The first and most visible scenario is the complexity of the new architecture, just as the massive MySQL cluster architecture was born initially. We use H2, an open source High-performance memory database as an example to illustrate: 1 integration of Ameoba and H2ameoba is a distributed database agent, it and MySQL integration has been successfully used in Alibaba's core business. If you only consider database nodes as a single store, MySQL node and H2 node There is no essential difference. JDBC Driver, db segmentation, routing, all by Ameoba unified responsibility. 2 asynchronous persistence for each logical mixed partition = H2 + MySQL, who will complete the H2 of data changes in the asynchronous write MySQL. A better solution is for the memory database to provide a real-time incremental replicator (Replicator), for example, a dual-machine hot standby mechanism based on online log replication. Products such as altibase provide this functionality. 3 If the High availability memory database crashes, the data no longer exists. Therefore, first of all, the data can be quickly asynchronously written to MySQL for persistent storage. At the same time, we should have robust fault-tolerant and failover mechanism to ensure that a H2 node crashes, the alternate H2 node in the same logical partition can replace the work immediately. One scenario is for distributed database proxies, such as Ameoba, to be resolved by at least 2 nodes per shard,h2, in Primary-secondary mode, as shown in Figure 6: Figure 6 Another scenario is the memory database real-time replication feature mentioned earlier. Although some memory db such as H2 itself can support memory, disk level two storage, but its own provision of disk storage and access scenarios less reliable than MySQL. Therefore, the use of memory-type primary-secondary mode is more feasible. 4 The Distributed Transaction Database segmentation architecture brings the distributed transaction problem, which is challenging for some scenarios with higher requirements. Ameoba is still in the process of being resolved. The Ameoba + H2 portfolio faces the same challenges. At present, a more consistent view and practice is cold treatment-as far as possible without business. Consistency issues are resolved by the use of data revisions based on the characteristics of the business, and individual business uses compensation transactions. Because most applications today, even the core business, the requirements of the transaction is not high. 9. Further thinking 1) A variety of data segmentation patterns in a large Internet station, different applications and data need to do different processing. On the basis of the overall vertical segmentation mode, the function of large data is selected for horizontal segmentation, for example: supply and demand, order, transaction record. 2 data cache Although the Memory Database layer (MDB) can more efficiently support transactional databases, especially for structured applications and complex query services, Key-value caching is still a necessary design for high-frequency queries (query) and entity lookup (find). Cache provides higher query speed and reduces access pressure on MDB, especially high concurrency scenarios with read-write intensive. Because of this architecture, the memory database remains as a storage store, not as a cache. Figure 7 shows that the DCL layer is also required on top of the MDB layer to provide high-performance caching services. 10. This paper presents a distributed database architecture, which is based on the introduction of the Memory database layer and the establishment of a two-tier, multiple-partition. This scheme is used to solve massive highHigh-performance data storage and access problems in concurrent systems, especially business complex internet sites such as E-commerce. Its core ideas are: 1 High performance: It is to provide high-performance relational database access service through the memory database, which is the most important goal of this architecture; 2 persistence: Through two-level database and asynchronous write-complete persistence; 3. Massive data support: Massive data support through vertical and horizontal partitioning 4 High Availability: Based on Ameoba, the high availability of MDB is further realized by the primary standby node, and the secondary disk database can recover the data quickly. "Reference" 1. Alibaba Ameoba distributed Database design and Practice 2. Yeu Xuqiang, "Taobao architect Yeu Xuqiang's annual Outlook," HTTP://WWW.INFOQ.COM/CN3. Guangdong Mobile BOSS2.0 Distributed Database Architecture scheme, billing system design and practice. 4. Cassandra,http://cassandra.apache.org/5. Oracle, TimesTen Official document, HTTP://WWW.ORACLE.COM/TIMESTEN/INDEX.HTML6. Fenng, "Oracle Memory Database-timesten", Http://www.dbanotes.net/database/oracle_timesten.html7. Zhang Xing, Baowen, "Memory database in the BSS account processing application", "Billing &oss World", HTTP://DATABASE.51CTO.COM/ART/200612/36973.HTM8. Titan, "Introduction to Common Memory Databases", http://titan.javaeye.com/blog/3643459. Ricky Ho, "NoSQL mode", programmer 2010-1; "Query processing of the NoSQL database", programmer 2010-2 This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/tolys/archive/ 2010/10/25/5963506.aspx