The content of this article comes from alibaba employee Li Zhihui’s book “core principle and case analysis of large Website technology Architecture”, this book is worth a look, so it is sorted out.

First, the architecture evolution of large websites

1.1 Features of large website software

  • High concurrency and high traffic
  • High availability: the system provides service 24/7
  • Huge amounts of data
  • Users are widely distributed
  • Poor security environment
  • Requirements change quickly and are released frequently
  • Incremental development

1.2 Evolution and development of large-scale website architecture

  • Initial site architecture: a server with applications, databases, files, and other resources. Like the LAMP architecture
  • Application and data service separation: three servers (with different hardware resources), namely application server, file server, and database server
  • Use caching to improve web site performance: there are two types, local caches cached on application servers and remote caches cached on dedicated distributed caching servers
  • Improve web site concurrency with application server clusters: load balancing scheduling servers to distribute access requests to any machine in the application server cluster
  • Read/write separation of databases: Databases use primary/secondary hot backup. When the application server writes data to the primary database, the primary database synchronizes data updates to the secondary database through the primary/secondary replication mechanism. Application servers use specialized data access modules to be transparent to applications
  • Use reverse proxies and CDN to speed web site response: Both are based on caching. The reverse proxy is deployed in the central machine room of the website, and the CDN is deployed in the network provider’s machine room
  • Use distributed file systems and distributed database systems: The last resort for database splitting is more commonly a business branch
  • Use NoSQL and search engines: Better support for scalable distribution
  • Service separation: Services on the entire website are divided into different applications. Each application is deployed and maintained independently. Applications are connected through hyperlinks or message queues to distribute data or access the same data storage system
  • Distributed services: Common services are extracted and deployed independently

1.3 Values of the evolution of large-scale website architecture

  • The core value of large site architecture is flexibility to adapt to the needs of the site
  • The main force driving the development of large website technology is the business development of website

1.4 Mistakes in website architecture design

  • Follow the solutions of big companies
  • Technology for technology’s sake
  • Trying to solve every problem with technology

Second, large website architecture model

2.1 Website architecture mode

  • layered
  • segmentation
  • distributed

    • Distributed applications and services
    • Distributed static resource
    • Distributed data and storage
    • Distributed computing
  • The cluster
  • The cache

    • Cdn
    • The reverse proxy
    • The local cache
    • Distributed cache
  • asynchronous

    • Provide system availability
    • Speed up website response
    • Eliminate high concurrent access peaks
  • Redundancy Servers run redundantly and databases are backed up redundantly
  • automation
  • Security: Prevent XSS attacks and SQL injection

Three, large site core architecture elements

  • performance
  • availability
  • Scalability is constantly adding servers to a server cluster
  • expansionary

Instantaneous response: high-performance architecture for the site

4.1 Website performance test

  • Different perspectives on site performance

    • User perspective site performance response time
    • Developer perspective on site performance, response time, and shine
    • Website performance resources from an operations perspective
  • Performance test indicators

    • The response time
    • concurrency
    • Throughput QPS TPS HPS
    • Performance counter
  • Performance test method

    • The performance test
    • The load test
    • Pressure test
    • Stability test
  • Performance Test Report
  • Performance optimization strategy

    • Performance analysis
    • Performance optimization

4.2 Web Front-end Performance Optimization

  • Browser Access optimization

    • Reducing HTTP requests
    • Using browser caching
    • Enable compression
    • CSS is at the top of the page and JS is at the bottom
    • Reduce cookie transmission
  • CDN acceleration. (the content of distribute network)
  • The reverse proxy

4.3 Application Server Performance Optimization

  • Distributed cache

    • The fundamentals of caching
    • Use caching wisely

      • Frequently modifying data
      • No hot access
      • Data inconsistency with dirty reads
      • Cache availability
      • Cache warming
      • Cache penetration The cache does not exist and accesses the database directly
    • Distributed cache architecture
    • Memcached
  • Asynchronous operations
  • Use cluster
  • Code optimization

    • multithreading
    • Resource reuse
    • The data structure
    • The garbage collection

4.4 Storage Performance Optimization

  • Mechanical hard drives vs. solid-state drives
  • B+ tree vs. LSM tree
  • RAID vs. HDFS

Five, safe: the site’s highly available architecture

5.1 Measurement and assessment of website usability

  • Site viability metrics
  • Site usability assessment

5.2 Highly available Website architecture

5.3 Highly available Applications

  • Failover of stateless services through load balancing
  • Session management of application server clusters

    • Session replication
    • The session binding
    • Use cookies to record sessions
    • The session server

5.4 High-availability Applications

  • Hierarchical management
  • timeout
  • The asynchronous call
  • Service degradation random access denial (Twitter)
  • Idempotent design

5.5 Highly available Data

  • Principle of CAP

    • Data persistence
    • Data accessibility
    • Data consistency

      • Strong data consistency
      • Data user consistency
      • Data final consistency
  • The data backup
  • Failure to transfer

    • Failure to confirm
    • Access to the transfer
    • Data recovery

5.6 High Availability Software Quality Assurance

  • Web site
  • Automated testing
  • Pre-release verification
  • Code control

    • Trunk development, branch release
    • Branch development, trunk release
  • Automated publishing
  • Gray released

5.7 Website operation monitoring

  • Monitoring data collection

    • Collect user behavior logs
    • Server Performance Detection
    • Operational data report
  • Monitoring management

    • The system alarm
    • Failure to transfer
    • Automatic graceful degradation

Never ending: The site’s scalability architecture

6.1 Website scalability design

  • Physical separation of different functions to achieve scaling
  • A single function scales through a cluster

6.2 Scaling for an APPLICATION Server Cluster

  • HTTP redirection load balancing
  • Dns Load balancing for domain name resolution
  • Reverse proxy load balancing
  • IP load Balancing
  • Data link layer load balancing
  • Load balancing algorithm

    • polling
    • Weighted polling
    • random
    • The minimum link
    • Hash the original address

6.3 Scalability design of distributed Cache cluster

  • Memcached Access model for distributed cache clusters
  • Scalability challenges for Memcached distributed cache clusters
  • Consistent hash algorithm for distributed cache

6.4 Scalability Design of A Data Store Server Cluster

  • Scalability design for relational database clusters
  • Scalability design of Nosql database

7. Improvise: The extensible architecture of the site

7.1 Build an extensible Website Architecture

7.2 Using distributed message queues to reduce system coupling

  • Event-driven architecture
  • Distributed message queue

7.3 Creating reusable Service Platforms using Distributed Services

  • Web Services and enterprise-level distributed services
  • Requirements and characteristics of distributed services for large web sites

    • Load balancing
    • Failure to transfer
    • Efficient telecommunication
    • Integrated heterogeneous system
    • The application is minimally intrusive
    • Version control
    • Real-time monitoring
  • Distributed service framework design

7.4 Extensible data structures

7.5 Use open platform to build website ecosystem

  • API interface
  • Transfer agreement
  • security
  • The audit
  • routing
  • process

8, impregnable: the security architecture of the site

8.1 The website application attack and defense

  • XSS attacks

    • disinfection
    • httponly
  • Injection attacks

    • Open source
    • Wrong echo
    • The blinds
    • disinfection
    • Parameter binding
  • CSRF attacks

    • The form token
    • Verification code
    • referer check
  • Other attacks and vulnerabilities

    • error code
    • HTML comments
    • File upload
    • Directory traversal
  • Web Application Firewall
  • Scanning for website security vulnerabilities

8.2 Information encryption technology and key security management

  • One-way hash encryption
  • Symmetric encryption
  • Asymmetric encryption
  • Key security Management

8.3 Information Filtering and Anti-spam

  • Text matching
  • Classification algorithm
  • The blacklist

8.4 E-commerce risk control

  • risk

    • Account risk
    • Buyers risk
    • Risk of the seller
    • Trading risk
  • Risk control

    • The rule engine
    • Statistical models