The basic knowledge of high concurrency and high Availability large Web site architecture features (i)

Source: Internet
Author: User
Tags haproxy

Large site Architecture Features: 1. High concurrency? (large number of user visits)

Solution: Split system, service, message middleware, caching, concurrency

High Concurrency Design principles

System design not only need to consider the realization of business functions, but also to ensure that the system high concurrency, high availability, high reliability and so on. You should also consider system capacity planning (traffic, capacity, etc.), SLA designations (throughput, response time, availability, downgrade scenarios, etc.), monitoring alarms (machine load, response time, availability, etc.), contingency plans (disaster tolerance, demotion, current limit, isolation, cut traffic, rollback, etc.).

Split system

When we start from scratch to make a new system, will be the first system function module architecture design, then is directly to do a chatty vertical MVC system, use a war package for release management, or need to follow some rules to split the module, design SOA or micro-service system is better? The author believes that it is necessary to base on the human and material conditions of the project and how many users and volumes the project needs to support. A good system design should be able to meet the current needs and problems, control implementation and schedule risk, predict and plan for the future, avoid over-design, after the launch of a basic core version, then continue to iterate and improve.

Today, let's talk about some of the dimensions and principles of module splitting for SOA, microservices system architecture design.

System dimension: According to the system function, business split, such as, coupons, shopping cart, settlement, orders and other systems.

Functional dimension: The system functions in the fine-grained split, coupon system is divided into coupons backstage system, the voucher system, the issuing system.

Read-Write Dimensions: for example, in commodity systems, if the query volume is large, can be divided into two services, respectively, for the query services and write services,

Read-write proportional feature splitting, reading more, can consider multilevel cache, write more, can consider the sub-database sub-table.

AOP Dimension: According to the access characteristics, according to the AOP split, such as the Product Details page can be divided into CDN, page rendering System, CDN is an AOP system

Module Dimensions: Dividing the overall code structure into Web, Service, DAO

Service of

In a distributed system, the business logic layer is encapsulated into an interface form and exposed to other system calls, then this interface can be understood to be called a service.

When the service is more and more, will need to use the service governance, then will use the Dubbo, Springcloud Service governance framework

The follow-up will be discussed in depth Dubbo and Springcloud.

Service evolution: In-process services-Standalone remote service-cluster manual enrollment service-autoenrollment and discovery services-grouping, isolation, routing-service governance for services

Consider service grouping, isolation, current throttling, black-and-white lists, timeouts, retry mechanisms, routing, fault compensation, and more

Practice: Using Nginx, HaProxy, LVS and so on to achieve load balancing, ZooKeeper, Consul and other implementation of automatic registration and discovery Services

Message Queuing

Message middleware is a client-server asynchronous communication framework, the message middleware is divided into point-to-point and publish-subscribe communication mode, the producer sends the message, the consumer can not wait, asynchronously accept the producer sends the message.

In the e-commerce system, Message Queuing is used to push the message asynchronously, noting that the message failed to retry the power of the problem.

Idempotent problem resolution with persistent log + global ID record.

Caching technology

Browser-Side Caching

App Client Cache

CDN (Content Delivery Network) cache

Access-Layer Caching

Application-tier caching

Distributed cache

For backstop data or exception data, it should not be cached, otherwise the user will see the data for a long time.

Concurrency

The string behavior is parallel.

2. High Availability? (High concurrency guarantee system is not down)

Solution: Downgrade, current limit, tangent flow, rollback

High-availability design principles

Offload is achieved through load balancing and reverse proxy.

Protect your service from avalanche by limiting current.

Partially available and lossy services are implemented through demotion.

Fault isolation is achieved through isolation.

Avoid avalanche caused by requests piling up by reasonably set timeouts and retry mechanisms.

Quickly fix the wrong version with a rollback mechanism.

Downgrade

One important design for highly available services is the downgrade switch, which is based on the following ideas when designing a downgrade switch:

1. Switch Centralized management: Push the switch to each application via push mechanism.

2. Degraded multi-level read service: For example, a service call is downgraded to read-only cache, ReadOnly distributed cache, read-only default degraded data (such as inventory status default stock).

3. Switch pre-placement: If the architecture is nginx–>tomcat, can be placed in front of the Nginx access layer, the Nginx layer to do the switch, request traffic back to the source backend application or just a small amount of traffic back to the source.

4. Business downgrade: When high concurrent traffic comes in, in the e-commerce system to promote the design of the protection of the user can order, can pay is the core requirements, and ensure the final consistency of the data. This makes it possible to change some synchronous calls to asynchronous calls, prioritize data with high-priority data or special features, and allocate traffic to the system reasonably to ensure system availability.

Current limit

Purpose: To prevent malicious requests from attacking or exceeding system spikes

Practice:

Malicious request traffic only accesses the Cache

Use of Nginx limit processing for traffic that penetrates back-end applications

Malicious IP using Nginx deny policy or iptables deny

Cut flow

Purpose: To shield the faulty machine

Practice:

DNS: Change the domain name resolution portal, such as dnspod can add alternate IP, normal IP failure, will switch to the alternate address; Effective practice is relatively slow

Httpdns: To bypass operator Localdns for accurate traffic scheduling

Lvs/haproxy/nginx: Remove the faulty node

Can be rolled back

Fast fallback to the last stable version at any time when the release version fails

3. Website Evolution Process

The Distributed architecture->soa (Service Oriented architecture-oriented to the business logic layer), micro services

Monolithic architecture

SSH, SSM tiered structure development (Legacy project)

Distributed architecture

Splits a project into n multiple sub-items (split according to business logic)
such as the e-commerce system. Split into coupons system, order system, payment system, message system, trading system, and ultimately all the split sub-projects into a process, through the domain name jump access.

Soa

Service Oriented architecture, business logic, and attempts to demonstrate layer separation.
involves RPC Remote call technology (Dubbo, Springcloud)
The business logic layer is extracted, encapsulated as a service (interface), to other subsystem calls.
Soap=http+xml format
ESB (Message bus)

Micro-Service

Evolved based on SOA, inherits SOA benefits, removes SOA layer ESB message bus, uses Http+json (restful)

The difference between microservices architecture and SOA

1 microservices architectures evolve based on SOA, inheriting SOA benefits MicroServices architecture removes the ESB message bus in the SOA architecture, using Http+json (restful).
2. MicroServices architecture is more granular than SOA architecture, allowing professional people to do professional things (focus), purpose to improve efficiency, each service to the service between the non-impact, micro-service architecture, each service must be independent deployment, non-impact, micro-service architecture is more lightweight, lightweight.
In the 3.SOA architecture, there may be a sharing of database storage, and microservices emphasize that each service is a separate database, ensuring that each service is not affected by the service.
4. Project features: The microservices architecture is more suited to agile development and faster iteration of the Internet company than the SOA architecture because of its granular granularity.

Learn more about Ant class

Basic knowledge of high concurrency and high Availability large Web site architecture features (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.