Do we have an impulse to explore the system when we see the figure (a)? Such a colorful interface, hidden behind what kind of mystery! When a user enters a domain name, such as www.taobao.com, how the page is displayed, when the user searches the search box, the system is how to deal with, the user in the second kill activity, the system is how to deal with. After more than two years of experience in the Internet industry, as well as their own thinking, here I would like to explore the e-commerce system architecture, explore how the system is designed, and design the various tradeoffs of the system.
Figure (i)
Hidden in the colorful interface, is a large and complex system, the figure (ii) is a bird's eye view of the system. I have only described some of the branch subsystems, omitting other auxiliary subsystems.
How does each subsystem work in this complex system?
How does 1:user access a page similar to www.taobao.com? User enters the www.taobao.com domain name in the browser, and the browser resolves the IP address that the domain name points to through the DNS server. There may be more than one IP address, possibly multiple. Which one to choose, is generally returned by DNS based on a certain policy.
2: If the browser chooses an IP address, then through the IP address to access the page server, that is, webserver. In terms of reliability and performance, WebServer not only deploys a single machine, but multiple units. This allows the deployment to be load-balanced and to function properly after a child node crashes. Our approach can be implemented with an additional load balancer approach, or by LVS.
3:webserver loading the page details, load it through the details system. The detailed system aggregates information from multiple subsystems: commodity subsystem, picture Subsystem (CDN), active subsystem.
4: User login account, is through the user account subsystem, the subsystem to support the Unified account mode: Through the mailbox login, QQ account login, account login.
5: When the user enters the baby name in the search box, the search request is done through the search subsystem. The search subsystem periodically builds indexes from the prepared DB increments, which tolerates a certain delay in searching.
In fact, some real-time search systems can be used, such as Solr, or a large system aggregation of small systems, the new data through the message queue into the search system in memory, or real-time system, and then in the user search by the aggregation of the way to return results.
6: Users buy goods, the first to add items to the shopping cart, which requires a shopping cart system, shopping system to access the inventory system, to determine whether there is current, if there is goods to allow users to add to the shopping cart, and calculate the total price. When adding a shopping cart, whether to allow users to reduce inventory, depending on the user experience and the contradiction between malicious users: if you do not allow the reduction of inventory, sometimes the user will have to order the time, there is no goods. If the inventory is allowed to be reduced, there is a malicious user occupying inventory that affects other users ' purchases.
7: Inventory system records the price of goods, inventory and other light information, for performance considerations, the personal feel that the inventory subsystem is the use of memory, its data source commodity system (or direct access to the database).
8: Order System: During the activity, the order system will encounter spikes, so the order system should be asynchronous.
9: Commodity system: A system that spits out commodity information.
10:db adopts the main and standby mode, now common pattern: write the main, Chabe. This mode has the primary and standby data consistency problem. The real-time availability of data depends on the synchronization, the simpler way, the backup function of the database itself, or in the commodity system by asynchronous write. What is the basis for the writing of the Lord Chabe? As long as the read and write separation, improve performance.
11: Cross-region disaster recovery, the use of asynchronous approach, this impact performance is relatively small, but data consistency is not guaranteed. Here can only be specific business to take a different strategy, the consistency of the requirements of the sub-system, the use of remote and simultaneous write.
12: Subsystems are delivered in an SOA-based manner, and an RPC framework is now generally used. An open source ice is a good choice for individuals.
13: Each subsystem, in the region to adopt the main standby mode. The underlying data is all hung up, and data is accessed across regions in the underlying system. So a cross-region data access agent is required, while the downgrade provides the business.
Or to cut the access to another area, consider the load situation in another area.
Here, the architecture principle of e-commerce system is briefly introduced, then the design of each subsystem is discussed.
E-commerce system architecture--aerial view of the system