当前位置:网站首页>3. Business and load balancing of high architecture
3. Business and load balancing of high architecture
2022-07-06 06:54:00 【Ybb_ studyRecord】
Three high architecture business and load balancing
Three high architecture business and load balancing
Ensure the plan first Simple available , Then consider universality and reusability
General idea : Load balancing , cache ( Reduce link depth ), Message queue ( Peak shaving decoupling asynchronous ), Sub database and sub table
Dynamic and static separation
Dynamic data and static data
All users see the same page , It is also static data ( The first user's request , Make it static )
Data classified as static , Just for caching , Improve performance , Reduce links .
app cache , Browser cache ,apache, cache
stock
1. Large amount of visits , Is the bottleneck
2. For data consistency , Lock it , It is also a bottleneck
Lock stock
Ideas : Load balancing , cache , Sub database and sub table
1 Inventory fields 100 Inventory .10 Inventory fields ,10 Inventory .
A watch : goods id, Total inventory .
reids: goods id- stock -1:10 , goods id- stock -2:10
Total inventory :100 , Lock stock :1 (++)
When you release the lock , Lock stock –
Three high methodology
Writing data , Reading data .
Write : Read / write separation , Sub database and sub table , Delayed operation
read : Multi level cache , Optimization of request data
Less data transmission . Reduce cpu,io.
Low number of requests ( A page , There are few requests )
Less dependence .( High availability .5 individual 0.99=0.95)
Short path , short url.( The path is short , cache .)
Reduce transmission
Avoid single point . Downgrade plan
Estimate the number of system users , It's larger than the quantity
Current limiting , Refuse . Dynamic expansion and contraction
Load balancing of three high architecture
indicators
Concurrency number
1. Number of concurrent users , Some users use business , Another part of users Hang up , No specific operation .
2. Number of concurrent connections . Link between user and server . Some links are transmitting data , Some links Just links .
3. Number of concurrent requests . Request static data , It may be a write operation .
4. Number of concurrent threads . In the system , Number of concurrent threads .
The number of callers of services at the same time
throughput
Within unit time , The amount of data requests that can be accepted and returned .
1. Look at business logic .
2. Look at the requested data .
TPS: Transaction Per Second. The number of transactions per second .( Define the transaction as a whole request 、 operation 、 return )
QPS:Queries Per Second. Queries per second .
TPS and QPS The relationship between : Opening the home page is a transaction , It depends on the specific scene . One TPS May include more than one QPS
Mean response time
User's perspective . response time ( Request issued , Response received , Time between )
Average of all response times .
Reliability index
Mean time between failures .
System on-line , To the first failure , Average running time .
Formula calculation :
Amdal's law :
Speedup ratio : Response time before optimization / Optimized response time . r.
Increase the proportion : Response time of a module / Total time . <=1,p.
Average response time of the whole system : t new =t Old time *((1-p)+p/r).
Acceleration ratio of the whole system : 1/((1-p)+p/r).
Purpose : Optimize P Systems with high value . enlarge r
The relationship between indicators
The relationship between concurrency and throughput :
Began to increase , When it is full, it reaches the maximum , Slowly descend behind
Concurrent number pairs response time :
The front rises slowly , After the index rose
The impact of average response time on concurrency
User perspective : Concurrency is not affected by the system
System perspective : The more concurrent , The longer the response time , The longer the response time , The more concurrent , A vicious cycle .
Reliability index and other indexes
The worse other indicators , The worse the reliability index
How to optimize the system
Concurrency number
Reduce concurrency . Prevent the system concurrency from being too high .
Development Engineer : Current limiting
Architects :
Daily plan 、 industrial design .
Ticket gate , Drive more than one , shunt
Put the original request to a system , Distributed to different systems .
take request Various stages before reaching the system , Make a request shunt .
first floor :DNS The server , Domain name resolves to IP Address
A Record (Address).ip.
CName Record (Canonical name Alias ). Domain name to domain name .
Use A Record and CNAME The difference of domain name resolution A Record is to resolve a domain name to a IP Address (Address, Special numbers IP Address ), and CNAME The record is to resolve the domain name to another domain name . Its function is almost ,CNAME Point several host names to an alias , In fact, it points to IP The address is the same , Because this alias also needs to be a A Records of the . But use CNAME Records can be easily changed IP Address . If a server has 100 Website , They all do aliases , The server changes IP when , Just change the alias A Just record it .
One domain name maps to multiple ip Address
One domain name maps to multiple domains , Multiple domain names map to multiple ip Address
dns Load balancing : Add multiple domain names A Record (IP Address ).
The second floor :CDN The server , Send the request to , The server closest to the user's network topology
characteristic : It takes up a lot of traffic , Not often
( Topological proximity It's dynamic , Network load , Content availability , Equipment working status )
Conventional http The access process is that the user fills in the domain name to be accessed in the browser , The browser calls the domain name resolution function library to resolve the domain name , To get the corresponding IP Address ; Re pass IP Address sends a data access request to the service host of the domain name , Get the requested data , Finally, return the required content .CDN The basic idea of is to avoid bottlenecks and links on the Internet that may affect the speed and stability of data transmission , By placing node servers everywhere in the network, an intelligent virtual network based on the existing Internet is formed .CDN The system can connect each node according to the network traffic in real time 、 Load condition , As well as the distance to the user and response time and other comprehensive information , Redirect the user's request to the nearest service node .
Kill two birds with one stone :
1. Reduce Concurrency per system
2. Let the user access the system closest to him ( Network topology recently ), Reduce network latency , Reduce average response time
Higher deployment costs , The synchronization of data will be complicated
Find a special CDN provider
cnd node , Cache nodes , Edge node .
Origin station .
User request —> Edge node ( Static resources such as pictures , If so, go back to , No access to the source site and cache )
Caching static content : Configure rule list , Decide which data needs caching
Dynamic content : Source station processing
Example 1: Not introduced CDN
Suppose your original server is in South China , There is a picture on the server , here , All users , Want to access this picture , Can only run to this server in South China , Even if the user is in North China .
Example 2: introduce CDN
introduce CDN after , The interview situation is different .CDN The most important function is to realize the nearby access of resources . For example, Alibaba cloud is in South China 、 East China 、 In North China CDN The server , that , Users in North China visit that picture at this time , You can run directly to North China CDN On the server , So the speed is faster .
What is? “ Origin station ”
But there's a problem here , On the server in North China , Where did the picture come from , Will not come out of thin air . This is it. ” Origin station “ The role of the .
North China users visit North China DDN The server , North China CDN The server found that there was no picture the user wanted , So I ran to ” Origin station “ Look for that picture , After finding , Return to the user , And cache it locally . Next time there is a request to visit , Directly return the cached image .
This is it. ” Origin station “ The role of the , The above process , Namely ” Back to the source “. The general process is
user --> CDN The server --> Origin station
Reduce the concurrency of user system ( Blocking flow ).
Reduced average response time .
Reduce network congestion .
How to learn fastest : Design by yourself . Then compare the advantages and disadvantages of others' plans
The purpose of the request is baidu.com, Don't let users go to the real server , Call the request to the node closest to me .
Intercept
边栏推荐
猜你喜欢
【每日一题】729. 我的日程安排表 I
19. Actual memory management of segment page combination
Misc of BUU (update from time to time)
My seven years with NLP
(practice C language every day) reverse linked list II
How to convert flv file to MP4 file? A simple solution
Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation
接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
我的创作纪念日
Basic commands of MySQL
随机推荐
Entity Developer数据库应用程序的开发
Misc of BUU (update from time to time)
Basic commands of MySQL
Leetcode daily question (1997. first day where you have been in all the rooms)
Day 248/300 thoughts on how graduates find jobs
《从0到1:CTFer成长之路》书籍配套题目(周更)
Classification des verbes reconstruits grammaticalement - - English Rabbit Learning notes (2)
Arduino tutorial - Simon games
详解SQL中Groupings Sets 语句的功能和底层实现逻辑
编译,连接 -- 笔记 -2
将ue4程序嵌入qt界面显示
Leetcode - 152 product maximum subarray
SSO流程分析
【刷题】怎么样才能正确的迎接面试?
[hot100] 739. Température quotidienne
BUU的MISC(不定时更新)
PCL realizes frame selection and clipping point cloud
librosa音频处理教程
Is it difficult for girls to learn software testing? The threshold for entry is low, and learning is relatively simple
成功解决AttributeError: Can only use .cat accessor with a ‘category‘ dtype