Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the overall architecture of Web technology?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the overall architecture of Web technology". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

At the beginning, all kinds of frameworks are matched and then thrown into the Tomcat container to run, when our files, databases, and applications are all on the same server.

Service separation

With the launch of the system, the number of users will gradually increase, it is obvious that a server can not meet the load of the system, then we have to prepare in advance when the server is not overloaded.

Because we are a single architecture, optimizing the architecture in a short period of time is not realistic, adding machines is a good choice. At this point, we may have to deploy the application and the database service separately, and if possible, we can deploy the file server separately.

Reverse proxy

In order to improve the service processing capacity, we add a proxy server in front of the Tomcat container. I usually use Nginx, of course, if you are more familiar with Apache.

The user's request is sent to the reverse proxy, which then forwards the request to the back-end server.

Strictly speaking, Nginx belongs to Web server and generally handles static HTML, CSS and JS requests, while Tomcat belongs to Web container and specializes in handling JSP requests. Of course, Tomcat also supports html, but the effect is not as good as Nginx.

The advantages of reverse proxy are as follows:

Dynamic and static separation

Based on the above Nginx reverse proxy, we can also achieve static and static separation. Static requests such as HTML, CSS, JS and other requests are handed over to Nginx for processing, and dynamic requests are distributed to the backend Tomcat for processing.

Upgrading Nginx to 1.9.5 + can usher in the HTTP/2.0 era and speed up website visits.

Of course, if the company is not short of money, CDN is also a good choice.

Service split

In this era when distributed microservices have become popular, we don't need to step on too many holes and it's easy to split them up. There are already relatively mature technologies on the market, such as Alibaba's open source Dubbo (officials have made it clear that maintenance has begun), and the Spring family's Spring Cloud, of course, how to implement it, both in terms of technology and business.

Dubbo

SpringCloud

Micro-service and lightweight communication

Continuous integrated deployment

After the split of the service, with continuous integration deployment coming along, you may use the following tools: Docker, Jenkins, Git, Maven.

The picture comes from the network, and the basic topology is as follows:

The entire continuous integration platform architecture evolves as shown in the following figure:

The overall architecture of Web technology

The overall architecture of Web technology

Service cluster

Linux clusters are mainly divided into three categories (high availability clusters, load balancing clusters, scientific computing clusters). In fact, what we most often come into contact with in production is the load balancing cluster.

Implementation of load balancing

Distributed session

As we all know, services are generally divided into stateless and stateless, and distributed sessoion is for stateful services.

Several implementation methods of distributed Session

Several Management modes of distributed Session

Session Replication management (that is, session replication)

Session Sticky management

Centralized cache management

What is currently used in production

Load balancing strategy

There are two key factors in the advantages and disadvantages of the load balancing strategy and the difficulty of its implementation: the load balancing algorithm, the way and ability to detect the status of the network system.

1. Rr polling scheduling algorithm. As the name implies, polling for distribution requests.

Pros: easy to implement

Disadvantages: do not consider the processing power of each server

2. Wrr weighted scheduling algorithm. We set the weight weight for each server, and the load balancer dispatches the server according to the weight, and the number of times the server is called is proportional to the weight.

Advantages: taking into account the different processing power of the server

3. Sh original address hash: extract the user IP, get a key according to the hash function, and then look up and deal with the corresponding value, that is, the target server IP, according to the static mapping table. If the target machine is overloaded, null is returned.

4. Dh destination address hash: same as above, but now the IP of the destination address is extracted for hashing.

Advantages: the above two algorithms can achieve the same user to access the same server.

5. Lc is at least connected. Priority is given to forwarding requests to servers with a small number of connections.

Advantages: make the load of each server in the cluster more uniform.

6. Wlc weighted least join. Add weights to each server on the basis of lc. The algorithm is: (number of active connections * 256 + number of inactive connections) / weight, and the servers with small calculated values are selected first.

Pros: requests can be allocated according to the capabilities of the server.

7. The minimum expected delay of sed. In fact, sed is similar to wlc, except that the number of inactive connections is not considered. The algorithm is: (number of active connections + 1) * 256 / weight. Similarly, servers with small values are selected first.

8. Nq never stands in line. Improved sed algorithm. Let's think about the circumstances under which we can "never queue", that is, when the number of connections to the server is 0, then if the number of connections to the server is 0, the equalizer forwards the request directly to it without sed calculation.

9. LBLC has the least connection based on locality. According to the destination IP address of the request, the equalizer finds out the server in which the IP address is recently used, and forwards the request to it. If the server is overloaded, the least number of connections algorithm is used.

10. Minimum locality-based connections of LBLCR with replication. According to the destination IP address of the request, the equalizer finds out the "server group" recently used by the IP address, note that it is not a specific server, and then uses the minimum number of connections to pick out a specific server from the group and forward the request. If the server is overloaded, then according to the minimum number of connections algorithm, find a server among the servers in the cluster that are not in the server group, join the server group, and then forward the request.

Separation of reading and writing

MySQL master-slave configuration, read-write separation and the introduction of middleware, open source MyCat, Ali DRDS are all good choices.

If there is a high requirement for high availability, but there is no corresponding technical guarantee, it is recommended to use Aliyun's RDS or Redis-related database to save effort and money.

Full-text retrieval

If there are search business needs, the introduction of solr or elasticsearch is also a good choice, do not cram everything into the relational database.

Cache optimization

The introduction of caching is nothing more than to reduce the pressure on back-end database services and prevent them from going on strike.

The common caching services are Ehcache, OsCache, MemCache and Redis. Of course, these are the mainstream caching technologies that can stand the test, especially Redis has been widely used in distributed cluster services and proved its superior performance.

Message queue

Asynchronous notification: such as SMS verification, email verification, these non-real-time feedback logic operations.

Traffic sharpening: it should be a common scenario in message queues, and it is widely used in second kill or group robbery activities.

Log processing: logs are essential in the system, but how to deal with logs with high concurrency is indeed a technical task, which may overwhelm the entire service if you are not careful. The open source log ELK that we often use in our work is why there is a Kafka or redis in the middle (the difference between an influx of people and a queue).

Messaging: peer-to-peer communication (person-to-person) or publish-subscribe mode (chat room).

Log service

The ELK open source log group mentioned in the message queue is a good choice for small and medium-sized startups.

The overall architecture of Web technology

Safety optimization

All of the above, without a guarantee of safety, may return to zero.

Essential vocabulary for architectural pretending

High availability

High concurrency

Distributed transaction

Queue

Expand capacity

network security

The necessary tools for architecture installation

Operating system

Linux (essential), some soft

Load balancing

DNS, F5, LVS, Nginx, OpenResty, HAproxy, load balancer SLB (Aliyun)

Distributed framework

Dubbo 、 Motan 、 Spring-Could

Database middleware

DRDS (Aliyun), Mycat, 360 Atlas, Cobar (no maintenance)

Message queue

RabbitMQ 、 ZeroMQ 、 Redis 、 ActiveMQ 、 Kafka

Registration center

Zookeeper 、 Redis

Caching

Redis 、 Oscache 、 Memcache 、 Ehcache

Integrated deployment

Docker 、 Jenkins 、 Git 、 Maven

Storage

OSS 、 NFS 、 FastDFS 、 MogileFS

Database

MySql 、 Redis 、 MongoDB 、 PostgreSQL 、 Memcache 、 HBase

The network

Private network VPC, elastic public network IP, CDN

This is the end of the content of "what is the overall architecture of Web technology". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report