当前位置:网站首页>System design: Agent & redundancy & replication

System design: Agent & redundancy & replication

2022-06-24 05:03:00 Xiaochengxin post station

agent

A proxy server is an intermediate server between a client and a back-end server . The client connects to the proxy server to request a web page 、 file 、 Connection and other services . in short , A proxy server is a kind of software or hardware , Act as a mediator for clients seeking resource requests from other servers .

Usually , The proxy is used to filter requests 、 Record request , Or sometimes conversion requests ( By adding / Delete the header 、 encryption / Decrypt or compress resources ).

Another advantage of proxy server is that the cache can handle many requests . If multiple clients access a specific resource , The proxy server can cache this resource and provide it to all clients , Without having to access the remote server .

So when to use it ? It is used here for all the promotion scenarios , For example, let me give a more specific example . The author once worked in Jingdong , I will take Jingdong as an example , Jingdong's APP The homepage directly exposes all JD users , In particular, hundreds of millions of users may be active during the promotion , Also participate in product promotion 、 seckill , So for these hot commodities , How do we deal with it ?

There is no doubt that there should be an access gateway , Why? ? Because the three sharp tools of big promotion are caching 、 Current limiting 、 Downgrade . So sometimes you will find that the page is returning to you. Now the page fault is recovering , Downgraded . For example, sometimes you find yourself busy , Please do not click repeatedly , Current limiting . And sometimes , You find that you clearly see commodities , But when I placed the order, I found it was gone , Because the inventory has been sold out when the cache is synchronized .

So how does the gateway handle it ? Often is Nginx+Lua proxy server + Three level cache .

Proxy server type

The proxy can reside on the client's local server , It can also reside anywhere between the client and the remote server . Here are some famous proxy server types :

Open agent

An open proxy is any Internet A proxy server that users can access . Usually , The proxy server only allows netgroups ( Closed agent ) User store and forward in DNS Or Internet services such as web pages , To reduce and control the bandwidth used by the group . however , Use open proxy ,Internet Any user on can use this forwarding service . There are two well-known types of open proxies :

1. Anonymous proxy - These agent revisions are published on the server , But there is no resolution IP Address . For example, our domain name DNS It actually hides our internal servers IP Address .

2. Transparent proxy - Like our VIP It's actually our IP Address mapping .

Reverse proxy

The reverse proxy retrieves resources from one or more servers on behalf of the client . These resources are then returned to the client , It looks like they come from the proxy server itself

redundancy

Redundancy refers to the replication of key components or functions of the system in order to improve the reliability of the system , Usually in the form of backup or fault protection , Or to improve the actual system performance . for example , If only one copy of a file is stored on a server , Then losing the server means losing the file . Because losing data is rarely a good thing , We can solve this problem by creating duplicate or redundant copies of files .

Redundancy plays a key role in eliminating single point of failure in a system , And provide backup in case of crisis . for example , If there are two service instances running in the production environment , And one of them is out of order , Then the system can fail over to another .

Copy

Replication means sharing information to ensure redundant resources ( Such as software or hardware components ) Consistency between , To improve reliability 、 Fault tolerance or accessibility .

Replication is widely used in many database management systems (DBMS), There is usually a master-slave relationship between the original and the copy . The master gets all updates , Then pass the update to the master slave server . Each slave outputs a message , Indicates that it has successfully received updates , This allows subsequent updates to be sent .

Added by the author

In fact, in essence , The proxy server is equivalent to our privacy , That is, the high cohesion of software design principles 、 Low coupling . We act as an agent , It can easily screen out some things we don't want to pay attention to ( Such as authentication 、 cache 、 Polymerization, etc. ), We can focus more on our own business . Redundancy is actually a state after replication , We are trying to achieve redundancy to improve our high availability , That's why we choose master-slave replication . A similar idea is to preserve replicas between different clusters , such as ES The use of copies .

Reference material

grok_system_design_interview.pdf

原网站

版权声明
本文为[Xiaochengxin post station]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/08/20210826194031716y.html