Study Notes on large-scale website architecture

Source: Internet
Author: User
Tags website performance database sharding

Study Notes on large-scale website architecture

Preface

I have been reading two books recently:

1. Analysis of core principles and cases of large-scale website Technical Architecture

2. Zeng xianjie's large-scale website system and Java middleware practices

After reading and thinking about my current job, I feel that I have benefited a lot and benefited a lot. I have deepened my understanding of large websites. Next I will share my study notes.

 

Study Notes

 

1. Development History of large-scale website architectures (the red letter is the key to each development process)

 

(1) From a small website, a server, applications, databases, files, and other resources are all stored on one server.

 

(2) As the website business develops, one server gradually cannot meet the requirements. Therefore, the application and data must be separated. After the application and data are separated, three servers should be used: Application Server, file server, and database server.

 

(3) The website is further developed, and the database pressure is too high, leading to access latency. Therefore, Using Cache improves the website performance (Remember, using cache is the first step to improve the website performance ), there are two types of cache used by websites: local cache cached on the application server and remote cache cached on the dedicated distributed cache server.

 

(4) The use of cache effectively relieves the database access pressure, but the application server still becomes the bottleneck of the entire website during peak website access periods. In this case, do not try to replace a more powerful server. For large websites, no matter how powerful the server is, it cannot meet the growing business needs of the website, therefore, we can improve the load pressure by adding servers, and then distribute access requests from users' browsers to a server in the application server cluster through the Server Load balancer scheduling server.

 

(5) Although the use of cache can make most of the data leave the database, but the cache does not hit, cache expired data will still go through the database, after the website reaches a certain scale, the database read and write pressure is still high and becomes the bottleneck of the website. In this case, database read/write splitting can be used to improve the load pressure on the database. The application server writes data to the database, and the Application Server reads data to the database. Currently, most mainstream databases provide master-slave hot standby, by configuring the master-slave relationship between the two databases, You can synchronize data updates from one database server to another.

 

(6) As the website business continues to grow, the number of users continues to grow. Due to the complicated network environment in China, the speed of users accessing websites in different regions varies greatly. Therefore, you can use reverse proxy and CDN to speed up user access and reduce the load pressure on backend servers, because the basic principles of reverse proxy and CDN are Cache

 

(7) after the database is read/write separated, one server is split into two servers, but it still cannot meet the business needs of the website. Therefore, you can use a distributed database. The main splitting method is Business Database sharding, deploy different business data on different physical servers

 

(8) In order to cope with increasingly complex business scenarios, large websites can split the services of the entire website into different applications by means of separation and governance. Each application is deployed independently, you can establish a relationship through the super chain or distribute data through the message queue.

 

With the development of large websites, most technical problems have been solved.

 

2. The key to high-performance websites is to control the concurrency. As long as this can be done, a lot of tricky data problems will not be a problem.

 

3. Do not try to solve all problems through technology. Business problems can also be solved through business means.

 

For example, at the beginning of 12306, the website had to handle tens of millions of visits at a time when it sold tickets at, which directly led to the collapse of 12306 of the website. Various professionals and professionals had different opinions and made suggestions. But can this problem be solved only through technology? Therefore, in response to this demand, 12306 should not only improve its technical architecture, but also adjust its business architecture. Do not sell tickets, in the ticket sales mode, the queuing mechanism is introduced, and the ticket sales on the entire site is changed to time-based tickets. The concurrency is controlled, and the performance of the entire website is improved.

 

4. An important goal and driving force of computer software development is to reduce software coupling. The less the relationship between things, the less mutual influence, and the more independent the development.

 

5. asynchronous architecture is a typical producer-consumer model.

 

6. advantages of using asynchronous queues

 

(1) Improve system availability

 

(2) Speed up Website access

 

(3) Eliminate concurrent access peaks

 

 

 

7. Website scalability refers to the constant addition of servers to clusters to relieve the increasing pressure on concurrent user access and increasing data storage requirements.

 

8. metrics for measuring architecture scalability

 

(1) Whether multiple server architecture clusters are available

 

(2) Is it easy to add a new server to the server?

 

(3) Can the added server provide services that are no different from the original server?

 

(4) Are there limits on the total servers in the cluster?

 

9. Reflect the system's idle important indicators Load

 

System Load, also known as Load, refers to the sum of the number of threads currently being executed by the CPU and waiting for being executed by the CPU. It is an important indicator that reflects the System's idle time. In multi-core CPUs, the perfect situation is that all CPUs are in use and no threads are waiting for processing. If the Load value is lower than the number of CPUs, the CPU is idle and resources are wasted. If the Load value is higher than the CPU data, the process is waiting for CPU scheduling and resources are wasted.

 

10. browser access Optimization

 

(1) Reduce http requests and combine CSS, JS, and images. Do not initiate multiple http requests to obtain the data.

 

(2) Use browser Cache to store static resources. Cache-Control, Expires, Pragma, and Last_Modified are both HTTP headers and cached headers.

 

(3) Enable compression to effectively reduce the amount of data transmitted by communication

 

(4) Put CSS on top and JS on the bottom, because JS downloads will be executed immediately, and the page loading speed may be blocked.

 

(5) Reduce Cookie Transmission

 

11. Cache Usage Details

 

(1) do not write the frequently modified data into the cache. Generally, the read/write ratio is at least, that is, at least two reads are performed for a single write, such as Sina Weibo, popular Weibo posts may be read millions of times for a single write, which is highly cost-effective.

 

(2) If there is no hotspot for access and most of the data is not concentrated on a small part of the data, it makes no sense to cache the data because the cache has a failure mechanism, most of the data has not been accessed again and is squeezed out of the cache.

 

(3) tolerate data inconsistency for a certain period of time, unless the cache is notified immediately when the data is updated, but this will also bring about consistency between overhead and things.

 

(4) use a distributed cache cluster to improve cache availability

 

(5) The newly started cache does not have any data. During the cache reconstruction process, the system performance and database load are not very good. Therefore, based on projects and services, load part of data at startup, Which is cache push

 

(6) Make invalid parameters on the cache and set the expiration time to avoid improper business or malicious attacks and frequently call interfaces to query the database, once data cannot be found in a Key-value database, the database enters the invalid cache and no data is returned when the Key-value is accessed again within a period of time.

 

12. Message Queue has a good load shifting effect (as mentioned earlier). However, you must modify the business process properly for cooperation.

 

Through asynchronous processing, transaction messages generated in a short period of high concurrency are stored in the message queue, so that concurrent transactions can be flattened during peak periods. However, note that data may fail in subsequent operations such as business Verification and database writing because the data is immediately returned to the user after being written to the message queue, therefore, after the message queue is used for asynchronous business processing, you need to modify the business process for cooperation. For example, after the order is submitted, the order data is written to the message queue and cannot be returned to the user immediately after the order is submitted successfully, if the order consumer process in the message queue really finishes processing the order, or even the goods are delivered out of the warehouse, the user is notified via email or SMS to succeed in order to avoid transaction disputes.

This article permanently updates the link address:

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.