Current under the tide of Internet +, as is known to all, taobao, jingdong these trading system to produce the amount of data is huge, every day of every trading day concurrency is amazing, especially the “double 11”, “6.18” these activities, the peak response of the system is put forward very high requirements, so the system architecture also had the very requirements.

Two days before I wrote this blog, I heard that a certain system broke down with 25 users, which was really shocking. So I thought about what technologies we could adopt in the Internet trading system to solve the problem of large data volume and high concurrency under the Internet platform.

Firstly, different technologies are classified according to the architecture hierarchy, as shown in the following figure:

 

Internet Technology Architecture Layered Strategy diagram

Next, I will explain the general principles and ideas of each technology one by one for your reference and learning:

First, the Internet layer

1. Load balancing

Load Balance is distributed among multiple operation units, such as the Web server, FTP server, enterprise critical application server, and other critical task servers, to complete tasks together.

For example, Nginx is a load balancing server that uses reverse proxies to direct traffic to different servers. Current cloud platforms all provide load balancing services, but for a separate fee, such as Alibaba’s SLB.

2. Content Delivery Network (CDN)

The basic idea of content distribution network is to avoid the bottlenecks and links on the Internet that may affect the speed and stability of data transmission, so that the content transmission is faster and more stable.

Through the server placed throughout the network node of a layer of intelligence on the basis of the existing Internet virtual network, CDN system can in real time according to the network traffic and each node connections, load condition and to the user’s distance and comprehensive information such as response time will the user’s request to guide users closest service node.

Its purpose is to enable users to obtain the required content nearby, solve the situation of crowded Internet network, improve the response speed of users to visit the website. You don’t need to do this alone, you can do it with off-the-shelf products like Akamai(better, more expensive), Verizon EdgeCast(cheaper), ChinaCach; If it is a cloud platform, it basically provides this service, but it also needs to pay. For example, Ali Cloud provides different forms of acceleration based on its OWN CDN acceleration. For example, PCDN based on P2P technology, SCDN for enhanced protection against DDoS, CC, and Web application attacks, and full-site acceleration.

Second, Web server layer

1, the Session – > cookies

The traditional B/S architecture is to put user sessions into sessions, which has no problem when the number of online users is not high. However, with the distributed or micro-service architecture adopted by the Internet today, it is difficult to maintain sessions alone, because sessions will be distributed on different servers, and Session synchronization will face great problems. So one way is to put Session maintenance into cookies, independent of one or more servers, and reduce server overhead. Of course, you can also use the memory cache server to store Session information uniformly, and some memory cache servers can persist the memory data to disk to improve availability and recoverability, so there will be no synchronization problems.

2, the Static page

Dynamic page static, why to dynamic web pages in the form of static web pages published? A big reason is search engines; Another important reason is to improve program performance.

Many large sites, when you go in to see it is very complex pages, but it does not take long to load, the reason is to get resources or database data before the user, and then through static processing, generate static pages. The static page is accessed by everyone, and the static page itself is accessed many times faster than the dynamic page, so the performance of the application is greatly improved. Usage scenarios are those that require frequent access but the data is not frequently updated. In this case, it is time to static dynamic pages, such as taobao’s baby information page, the dynamic part of the page can be loaded with AJAX, such as the number of monthly sales.

3, the Cache

Caching, the caching of the Web services layer depends on three aspects:

  • Browser-side cache, such as CSS/JS;
  • In CDN and other technologies to do a lot of page caching to improve the speed of nearby access;
  • Build a memory cache server to cache frequently accessed pages, such as the home page.

4, Gzip

Using the principle that the browser can automatically perform Gzip decompression to compress pages and resources (including images, JavaScript, CSS, etc.) to reduce file size and improve network loading speed.

5, One file

The principle is to combine multiple contents that need to be loaded into a file to reduce loading times and network connection time and improve access efficiency, such as combining small ICONS into a large picture and CSS/JavaScript into a file.

6, Cluster

Clustering in contrast to traditional high performance computing technology, a computer cluster is a highly closely coordinated computing task performed by a loosely integrated set of computer software and/or hardware connected together. In a sense, they can be thought of as a computer.

Individual computers in a clustered system, usually called nodes, are usually connected over a local area network, but other connections are possible. Cluster computers are often used to improve the computing speed and/or reliability of a single computer. In general, Cluster machines are much more cost-effective than individual machines (such as workstations or supercomputers), and most clusters manage Cluster nodes master-slave, such as Websphere Cluster.

The difference between a cluster and a common distributed service is that the same service is deployed on multiple servers. Distributed services are divided into multiple sub-services, or different services are deployed on different servers.

To put it simply, distribution improves efficiency by shortening the execution time of a single task, while clustering improves efficiency by increasing the number of tasks executed per unit of time.

Application server or business server layer

1, Distributed/Distributed micro service | | | SC/service center Decouple/decoupling

Distributed system is a software system that supports distributed processing. It is a system that performs tasks on a multi-processor architecture interconnected by communication networks. To put it simply, distributed processing means that multiple connected computers undertake different parts of the same task, which run simultaneously under human control and complete the same task together. It includes distributed operating system, distributed programming language and compilation system, distributed file system, distributed database system, distributed scheduling system and so on. This is often accompanied by the need to do load balancing, fusing and current limiting; You have to consider whether it’s full or incremental, and so on.

So with the development of the distributed micro service architecture becomes more and more popular, its main function is to functional decomposition to the discrete individual service, and reduces the coupling of the system, and provide more flexible service support, and surrounding areas of business components to create applications, these applications can be developed independently, management, and iteration. The use of cloud architecture and desktop deployment, management, and service capabilities in decentralized components makes product delivery easier, so business decoupling and unbundling becomes increasingly important.

Now the development of containers (Docker) makes distributed, microservices more flexible and easy, and also provides a good infrastructure to support large data volumes and high concurrency.

2, the Cache

The cache of this layer is mainly for high-frequency data, such as the cache of intermediate calculation results, and it is mainly based on memory cache, such as Memcached and Redis, and some also provide cache persistence, such as Redis. In distributed computing, batch data is often cached for prefetch to improve computing speed.

3. Synchronous to asynchronous /MQ

The idea of synchronous to asynchronous, on the one hand, does not let the process or thread block in the sequence of execution, so as to speed up the execution of the program, just like Node.js with asynchronous and Java with synchronization to do the same calculation test, a lot of times the speed of Node.js is faster than Java, do not believe you can try, like double 11 shopping is using the asynchronous mechanism.

On the other hand, instead of keeping the user waiting, the user can continue to do other things and notify the user when the asynchronous execution is complete. Message queuing (MQ) is used extensively, and there are many popular products, from the earliest WebsphereMQ to now Kafka and RabbitMQ, some of which are even tightly integrated with popular open source frameworks such as RabbitMQ and SpringBoot.

Data access, file access, internal network access layer

1, read and write separation

In the case of large amount of concurrent data, read operation frequency far exceeds write operation, so read/write separation is adopted to improve read speed. The idea is to let the master database handle transactional add, change, DELETE operations (INSERT, UPDATE, DELETE), while the slave database handles SELECT query operations. The following is the earliest read/write separation strategy adopted by Taobao:

 

Read/write separation diagram

2, the DB Cluster

Cluster will not do too much description, database cluster is to use at least two or more database servers, constitute a virtual single database logical image, like a single database system, to provide transparent data services to clients. Its purpose is to increase data throughput, improve database performance, and meet the requirements of data read and write speed in a large amount of data.

The RDS cloud database of Ali Cloud inherits the above two characteristics. It looks like a MySQL cluster on the outside, providing unified transparent access, while it automatically realizes read and write separation internally, providing great convenience for high-performance database storage.

3. Distributed storage (DAS/NAS/SAN)

Three kinds of distributed storage solutions, we can baidu, various introductions are more, here no longer repeat, such as Ali’s OSS storage is also a distributed storage.

4, the Cache

Cache is everywhere, even the CPU has the second level cache, in the data access layer, can according to the data you need to make full use of caching technology to provide a read/write speed, such as the requirement is not particularly big data for statistical analysis, real-time and cached do statements, etc., can be read from the buffer directly at this time, increase the speed of the statistics.

NoSQL, Key/Value

NoSQL refers to a non-relational database. With the rise of the Internet Web2.0 website, the traditional relational database has been unable to cope with the Web2.0 website, exposing many problems that are difficult to overcome, while the non-relational database is due to its own characteristics (high scalability, distributed computing, low cost, flexibility of architecture, semi-structured data, No complex relationship) has developed very rapidly. The creation of NoSQL database is to solve the challenges brought by large-scale data sets and multiple data types, especially the problems of big data application. Its database types include column storage, document storage, Key/Value storage, object storage and graph storage, etc.

6, Split/ Split/ Partition

Table partitioning is an effective way for DB to optimize very large tables. It is determined by different partitioning strategies defined by the database, such as modulus, timing and hashing. It is a very effective means and in many cases is more effective than table partitioning.

For example, there is a code table using partition table to divide 1 million records in 10 partitions (ID every from 1 to 100,000 for a partition), so write query statement, as long as the query conditions are given the required code, DB will automatically locate to the corresponding partition for query, greatly reducing the query time.

The use of table split that must be specified according to the query code to query the table, to find the corresponding record, it is up to the DBA or architect according to the business needs to define how to split. Table segmentation is divided into horizontal segmentation and vertical segmentation:

  • Horizontal partitioning: Placing rows of data into two separate tables based on the values of one or more columns of data;
  • Vertical split: Put the primary code and some columns in one table, and then put the primary code and other columns in another table.

7, BGP

The border gateway protocol is mainly used for the interconnection between ass (Autonomous systems) on the Internet. The main function of BGP is to control route propagation and select the best route. China Netcom and China Telecom both have AS numbers (autonomous system numbers). Most of the major network operators in China connect with their AS numbers through THE BGP protocol.

In this solution, you need to apply for IDC’s OWN IP address segment and AS number from CNNIC (China Internet Network Information Center), and then broadcast this IP address to mobile devices through BGP. Netcom, China Telecom and other network operators use BGP to interconnect and move devices. All backbone routing devices of Netcom and Telecom determine the best route to the IP segment of the IDC room to ensure high-speed access for mobile, Netcom, and telecom users. Many cloud platforms now support BGP.

Five, the summary

“Cache” and “induction” and “points” is a large amount of data the Internet architecture under high concurrency strategy using the most three strategies, from above, the technical level, “points” is occupied most of the technology at the core of the thought, so consider to think about what where, how, also have to think of a way to close a lot of business scenarios.