CN116886704A - Server management system, method, equipment and medium based on micro-service architecture - Google Patents
Server management system, method, equipment and medium based on micro-service architecture Download PDFInfo
- Publication number
- CN116886704A CN116886704A CN202310944167.2A CN202310944167A CN116886704A CN 116886704 A CN116886704 A CN 116886704A CN 202310944167 A CN202310944167 A CN 202310944167A CN 116886704 A CN116886704 A CN 116886704A
- Authority
- CN
- China
- Prior art keywords
- module
- service
- microservice
- server
- cluster
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 25
- 230000003111 delayed effect Effects 0.000 claims abstract description 21
- 230000036541 health Effects 0.000 claims description 26
- 238000007726 management method Methods 0.000 claims description 20
- 238000002955 isolation Methods 0.000 claims description 11
- 238000003860 storage Methods 0.000 claims description 9
- 230000002159 abnormal effect Effects 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 4
- 230000003213 activating effect Effects 0.000 claims 1
- 238000004891 communication Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 238000013461 design Methods 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000001934 delay Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 238000006467 substitution reaction Methods 0.000 description 3
- 206010033799 Paralysis Diseases 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 238000009826 distribution Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000005192 partition Methods 0.000 description 2
- 241000700189 Hystrix <Rodentia> Species 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007257 malfunction Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
- H04L67/1014—Server selection for load balancing based on the content of a request
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1031—Controlling of the operation of servers by a load balancer, e.g. adding or removing servers that serve requests
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
- H04L67/1044—Group management mechanisms
- H04L67/1048—Departure or maintenance mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
- H04L67/63—Routing a service request depending on the request content or context
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer And Data Communications (AREA)
Abstract
本发明属于微服务架构技术领域,具体提供基于微服务架构的服务器管理系统、方法、设备及介质,所述系统包括微服务模块,微服务模块连接有服务网关集群模块,服务网关集群模块连接有负载均衡模块,负载均衡模块连接有外部请求模块;服务网关集群模块和微服务模块均连接有服务器注册模块,微服务器连接有服务器容错模块;外部请求模块接收客户端的高并发、高通量的访问请求;负载均衡模块根据客户端的访问请求自动分配应用的传入流量;服务网关集群模块对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;服务产生故障或者延迟时,通过服务器容错模块对故障进行隔离和容错。提高访问流畅性,而且降低延迟。
The invention belongs to the technical field of microservice architecture and specifically provides a server management system, method, equipment and medium based on microservice architecture. The system includes a microservice module, the microservice module is connected to a service gateway cluster module, and the service gateway cluster module is connected to Load balancing module, the load balancing module is connected to the external request module; the service gateway cluster module and the microservice module are both connected to the server registration module, and the microserver is connected to the server fault tolerance module; the external request module receives high-concurrency and high-throughput access from the client request; the load balancing module automatically distributes the incoming traffic of the application according to the client's access request; the service gateway cluster module parses the access request, queries the service registry according to the parsing result, finds the target service, and calls it; when the service fails or is delayed, the server The fault tolerance module isolates and tolerates faults. Improve access fluency and reduce latency.
Description
技术领域Technical field
本发明涉及微服务架构技术领域,具体涉及一种基于微服务架构的服务器管理系统、方法、设备及介质。The present invention relates to the technical field of microservice architecture, and specifically relates to a server management system, method, equipment and medium based on microservice architecture.
背景技术Background technique
微服务是一种用于开发软件系统的架构风格,与传统的单体架构(将所有组件组合到一起)完全相反,单体架构只专注于单个应用程序,微服务小而独立,微服务架构看似条理分明,但实际还是比较复杂的。对于微服务架构来说,分布式几乎是必会用的技术(例如分布式服务器),由于分布式本身的复杂性,导致微服务架构也变得比较复杂。Microservices is an architectural style for developing software systems. It is completely opposite to the traditional monolithic architecture (which combines all components together). The monolithic architecture only focuses on a single application. Microservices are small and independent. Microservice architecture It seems clear and logical, but in reality it is quite complicated. For microservice architecture, distribution is almost a must-have technology (such as distributed server). Due to the complexity of distribution itself, microservice architecture has also become more complicated.
微服务架构风格是使用一套小服务来开发单个应用的方式,每个服务运行在自己的进程中,并使用轻量级机制通信,这些服务基于业务能力构建,并能够通过自动化部署机制来独立部署,这些服务使用不同的编程语言实现,以及不同数据存储技术,并保持最低限度的集中式管理。The microservice architectural style is a way to develop a single application using a set of small services. Each service runs in its own process and uses lightweight mechanisms to communicate. These services are built based on business capabilities and can be independently deployed through automated deployment mechanisms. Deployment, these services are implemented using different programming languages, as well as different data storage technologies, and maintain a minimum of centralized management.
目前关于微服务架构的部署,由于微服务之间存在错综复杂的依赖关系,一次请求可能会依赖多个后端的服务,在实际生产使用中这些服务可能会产生故障或者延迟,在一个高流量高数据传输的系统中,某个服务一旦产生延迟,可能会在短时间内耗尽系统资源,将整个系统都拖垮,进而造成系统瘫痪、宕机。Regarding the current deployment of microservice architecture, due to the intricate dependencies between microservices, a request may rely on multiple backend services. In actual production use, these services may cause failures or delays. In a world with high traffic and high data In the transmission system, once a certain service is delayed, system resources may be exhausted in a short period of time, bringing down the entire system, causing system paralysis and downtime.
发明内容Contents of the invention
针对某个服务一旦产生延迟,可能会在短时间内耗尽系统资源,将整个系统都拖垮,进而造成系统瘫痪、宕机的问题,本发明提供一种基于微服务架构的服务器管理系统、方法、设备及介质。In view of the problem that once a delay occurs in a certain service, system resources may be exhausted in a short period of time and the entire system will be brought down, causing system paralysis and downtime, the present invention provides a server management system based on a microservice architecture. Methods, equipment and media.
第一方面,本发明技术方案提供一种基于微服务架构的服务器管理系统,包括微服务模块,微服务模块的输入端连接有服务网关集群模块,服务网关集群模块的输入端连接有负载均衡模块,负载均衡模块的输入端连接有外部请求模块;In a first aspect, the technical solution of the present invention provides a server management system based on a microservice architecture, including a microservice module. The input end of the microservice module is connected to a service gateway cluster module, and the input end of the service gateway cluster module is connected to a load balancing module. , the input end of the load balancing module is connected to an external request module;
服务网关集群模块输出端和微服务模块的输入端均连接有服务器注册模块,微服务器的输出端连接有服务器容错模块;The output end of the service gateway cluster module and the input end of the microservice module are both connected to the server registration module, and the output end of the microserver is connected to the server fault tolerance module;
外部请求模块,用于接收客户端的高并发、高通量的访问请求;The external request module is used to receive high-concurrency and high-throughput access requests from clients;
负载均衡模块,用于根据客户端的访问请求自动分配应用的传入流量;The load balancing module is used to automatically distribute the incoming traffic of the application based on the client's access request;
服务网关集群模块,用于对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;The service gateway cluster module is used to parse access requests, query the service registry according to the parsing results, discover the target service, and call it;
当微服务模块所提供的目标服务产生故障或者延迟时,通过服务器容错模块对故障进行隔离和容错。When the target service provided by the microservice module fails or is delayed, the fault is isolated and tolerated through the server fault tolerance module.
作为本发明技术方案的进一步限定,服务网关集群模块包括多组网关,客户端均通过请求网关访问微服务模块;网关,用于收集数据以及访问日志信息。As a further limitation of the technical solution of the present invention, the service gateway cluster module includes multiple groups of gateways. Clients access the microservice module by requesting the gateway; the gateway is used to collect data and access log information.
作为本发明技术方案的进一步限定,服务网关集群模块还包括动态路由模块、限流容错模块和身份认证及安全控制模块;As a further limitation of the technical solution of the present invention, the service gateway cluster module also includes a dynamic routing module, a current limiting fault tolerance module, and an identity authentication and security control module;
动态路由模块,用于动态的将访问请求路由到所需要的服务集群;Dynamic routing module, used to dynamically route access requests to the required service cluster;
限流容错模块,用于为每种类型的请求分配容量,当请求数量超过阀值时抛掉外部请求来限制流量;The current limiting fault tolerance module is used to allocate capacity for each type of request. When the number of requests exceeds the threshold, external requests are thrown away to limit traffic;
身份认证及安全控制模块,用于对每个外部请求进行用户认证,拒绝没有通过认证的请求。The identity authentication and security control module is used to authenticate users for each external request and reject requests that fail authentication.
作为本发明技术方案的进一步限定,负载均衡模块包括负载均衡控制模块和安全加密模块;As a further limitation of the technical solution of the present invention, the load balancing module includes a load balancing control module and a security encryption module;
负载均衡控制模块,用于在多网关中自动分配应用的传入流量;Load balancing control module for automatically distributing an application's incoming traffic across multiple gateways;
安全加密模块,用于保证客户端请求的安全性。Security encryption module, used to ensure the security of client requests.
作为本发明技术方案的进一步限定,该系统还包括集群服务器,所有的微服务在集群服务器中进行注册,并定时发送健康检查到集群服务器;As a further limitation of the technical solution of the present invention, the system also includes a cluster server, in which all microservices are registered and health checks are regularly sent to the cluster server;
集群服务器在接收到微服务的最后一次健康检查后,等待第一时间阈值未接收到微服务的健康检查,在集群服务器自我保护模式关闭的情况下清除该微服务的注册信息。After receiving the last health check of the microservice, the cluster server waits for the first time threshold and clears the registration information of the microservice when the self-protection mode of the cluster server is turned off.
集群服务器在设定时间内丢失超多设定阈值数量的服务时,会进入自我保护模式,在自我保护模式下集群服务器等待第一时间阈值未接收到微服务的健康检查时,集群服务器也不会将其删除。When the cluster server loses more than the set threshold number of services within the set time, it will enter the self-protection mode. In the self-protection mode, the cluster server will not receive the health check of the microservice after waiting for the first time threshold. It will be deleted.
作为本发明技术方案的进一步限定,服务器容错模块,用于当服务异常或者第二设定阈值数量的服务延时时,主动启动熔断,或自动启动熔断模式,且服务隔离设定时间段以后,设置进入半熔断状态,若仍然调用失败,则回到熔断状态,若调用成功,则关闭熔断模式。As a further limitation of the technical solution of the present invention, the server fault-tolerant module is used to actively activate the fuse when the service is abnormal or the second set threshold number of service delays, or automatically activate the fuse mode, and after the service isolation set time period, The setting enters the semi-fuse state. If the call still fails, it returns to the fuse state. If the call is successful, the fuse mode is turned off.
作为本发明技术方案的进一步限定,服务器容错模块,用于设置不同的服务使用不同的线程池;当服务调用出现异常时,直接抛弃异常;当程序运行超时、熔断启动或线程池已满时启用回退;还用于对服务的并发访问量进行限制,设置单位时间内的并发数,超出限制的请求拒绝并回退。As a further limitation of the technical solution of the present invention, the server fault-tolerant module is used to set different services to use different thread pools; when an exception occurs in the service call, the exception is directly discarded; it is enabled when the program runs out of time, the circuit breaker is started, or the thread pool is full. Rollback; also used to limit the concurrent access to the service, set the number of concurrencies per unit time, and reject requests that exceed the limit and rollback.
第二方面,本发明技术方案提供一种基于微服务架构的服务器管理方法,应用于第一方面所述的系统,所述方法包括如下步骤:In the second aspect, the technical solution of the present invention provides a server management method based on microservice architecture, which is applied to the system described in the first aspect. The method includes the following steps:
接收客户端的高并发、高通量的访问请求;Receive high-concurrency and high-throughput access requests from clients;
根据客户端的访问请求自动分配应用的传入流量;Automatically distribute the application's incoming traffic based on client access requests;
对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;Parse the access request, query the service registry according to the parsing results, discover the target service, and call it;
当目标服务产生故障或延迟时,对故障的服务进行隔离和容错。When a target service fails or is delayed, the failed service is isolated and fault-tolerant.
作为本发明技术方案的进一步限定,该方法还包括:As a further limitation of the technical solution of the present invention, the method also includes:
将所有的微服务注册到集群服务器中并生成服务注册表;Register all microservices into the cluster server and generate a service registry;
通过设置微服务定时发送健康检查来进行微服务的管理。Manage microservices by setting them to send health checks regularly.
作为本发明技术方案的进一步限定,通过设置微服务定时发送健康检查来进行微服务的管理的步骤包括:As a further limitation of the technical solution of the present invention, the steps of managing the microservice by setting the microservice to regularly send health checks include:
微服务定时发送健康检查到集群服务器;Microservices regularly send health checks to cluster servers;
集群服务器在接收到微服务的最后一次健康检查后,等待第一时间阈值未接收到微服务的健康检查;After receiving the last health check of the microservice, the cluster server waits for the first time threshold to receive the health check of the microservice;
判断集群服务器在设定时间内是否丢失超多设定阈值数量的服务;Determine whether the cluster server has lost more than a set threshold number of services within a set time;
若是,集群服务器自我保护模式开启;If so, the cluster server self-protection mode is turned on;
清除该微服务的注册信息;Clear the registration information of the microservice;
若否,集群服务器自我保护模式关闭;If not, the cluster server self-protection mode is turned off;
不清除该微服务的注册信息。Do not clear the registration information of this microservice.
作为本发明技术方案的进一步限定,对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用的步骤包括:As a further limitation of the technical solution of the present invention, the steps of parsing the access request, querying the service registry according to the parsing result, discovering the target service and calling it include:
对每个外部请求进行用户认证;User authentication for each external request;
判断是否认证通过;Determine whether the certification is passed;
若是,动态的将访问请求路由到所需要的服务集群;If so, dynamically route the access request to the required service cluster;
为每种类型的请求分配容量,当请求数量超过阀值时抛掉外部请求来限制流量;Allocate capacity to each type of request, and when the number of requests exceeds the threshold, external requests are thrown away to limit traffic;
查询服务注册表发现目标服务进行调用;Query the service registry to find the target service and call it;
若否,拒绝没有通过认证的请求。If not, reject the request without authentication.
作为本发明技术方案的进一步限定,当目标服务产生故障或延迟时,对故障的服务进行隔离和容错的步骤包括:As a further limitation of the technical solution of the present invention, when the target service fails or is delayed, the steps of isolating and fault-tolerating the failed service include:
当目标服务异常或者超过第一阈值的目标服务延时,设置主动启动熔断执行直接返回;When the target service is abnormal or the target service delay exceeds the first threshold, set the active circuit breaker to execute and return directly;
或自动启动熔断模式,且服务隔离设定时间段以后,设置进入半熔断状态,若仍然调用失败,则回到熔断状态,若调用成功,则关闭熔断模式;Or automatically start the circuit breaker mode, and after the service isolation set time period, the setting enters the semi circuit breaker state. If the call still fails, it returns to the circuit breaker state. If the call is successful, the circuit breaker mode is turned off;
作为本发明技术方案的进一步限定,当目标服务产生故障或延迟时,对故障的服务进行隔离和容错的步骤包括:As a further limitation of the technical solution of the present invention, when the target service fails or is delayed, the steps of isolating and fault-tolerating the failed service include:
当目标服务调用出现异常时,判断是否存在程序运行超异常、熔断启动和线程池已满的情况;When an exception occurs in the target service call, determine whether there is a program running abnormally, circuit breaker startup, or the thread pool is full;
若是,启用回退;If so, enable fallback;
若否,直接抛弃异常,或返回上一步。If not, discard the exception directly or return to the previous step.
作为本发明技术方案的进一步限定,该方法还包括:收集访问日志信息。As a further limitation of the technical solution of the present invention, the method further includes: collecting access log information.
第三方面,本发明技术方案还提供一种电子设备,所述电子设备包括:至少一个处理器;以及与所述至少一个处理器通信连接的存储器;存储器存储有可被至少一个处理器执行的计算机程序指令,所述计算机程序指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如第一方面所述的基于微服务架构的服务器管理方法。In a third aspect, the technical solution of the present invention also provides an electronic device. The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores information that can be executed by the at least one processor. Computer program instructions, the computer program instructions are executed by the at least one processor, so that the at least one processor can execute the server management method based on the microservice architecture as described in the first aspect.
第四方面,本发明技术方案还提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如第一方面所述的基于微服务架构的服务器管理方法。In a fourth aspect, the technical solution of the present invention also provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions. The computer instructions cause the computer to execute as described in the first aspect. A server management method based on microservice architecture.
从以上技术方案可以看出,本发明具有以下优点:本发明基于微服务架构,在高负载高并发的场景,从数据输入到输出,进行自动分配应用的传入流量,提高访问流畅性,而且降低延迟;当目标服务产生故障或者延迟时,可对其故障进行隔离和容错,降低服务器在使用过程中由于某个服务产生延迟,导致整个系统耗尽资源,进而出现拖垮整个系统,提高系统运行时稳定性、可靠性。It can be seen from the above technical solutions that the present invention has the following advantages: the present invention is based on a microservice architecture, and in high-load and high-concurrency scenarios, automatically distributes the incoming traffic of applications from data input to output, improving access fluency, and Reduce latency; when the target service fails or is delayed, its fault can be isolated and fault-tolerant, reducing the delay caused by a certain service during the use of the server, causing the entire system to run out of resources, thereby bringing down the entire system and improving the system Runtime stability and reliability.
此外,本发明设计原理可靠,结构简单,具有非常广泛的应用前景。In addition, the design principle of the invention is reliable, the structure is simple, and it has very broad application prospects.
由此可见,本发明与现有技术相比,具有突出的实质性特点和显著地进步,其实施的有益效果也是显而易见的。It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious.
附图说明Description of the drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those of ordinary skill in the art, It is said that other drawings can also be obtained based on these drawings without exerting creative work.
图1是本发明实施例提供的系统的示意性连接框图。Figure 1 is a schematic connection block diagram of a system provided by an embodiment of the present invention.
图2是本发明实施例中服务网关集群模块连接示意图。Figure 2 is a schematic connection diagram of the service gateway cluster module in the embodiment of the present invention.
图3是本发明实施例中服务器容错模块模式示意图。Figure 3 is a schematic diagram of the server fault tolerance module mode in the embodiment of the present invention.
图4是本发明一个实施例的方法的示意性流程图。Figure 4 is a schematic flow chart of a method according to an embodiment of the present invention.
图5是本发明实施例中电子设备连接框图。Figure 5 is a connection block diagram of electronic equipment in the embodiment of the present invention.
具体实施方式Detailed ways
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of both. In order to clearly illustrate the relationship between hardware and software Interchangeability, in the above description, the composition and steps of each example have been generally described according to functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered to be beyond the scope of the present invention.
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and/or processor devices and/or microcontroller devices. entity.
在本申请所提供的实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口、装置或单元的间接耦合或通信连接,也可以是电的,机械的或其它的形式连接。In the embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or can be integrated into another system, or some features can be ignored, or not implemented. In addition, the coupling or direct coupling or communication connection between each other shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本发明的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本发明的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本发明的各方面。为了使本技术领域的人员更好地理解本发明中的技术方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。Furthermore, the described features, structures or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to provide a thorough understanding of embodiments of the invention. However, those skilled in the art will appreciate that the technical solutions of the present invention may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other instances, well-known methods, apparatus, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the present invention. In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described The embodiments are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of the present invention.
由于微服务之间存在复杂的依赖关系,一次请求可能会依赖多个后端服务,在实际生产中这些服务又可能会产生故障或者延迟,一旦某个服务产生延迟,可能会在短时间内耗尽系统资源,拖垮整个系统,降低系统可靠性、稳定性,给服务器业务处理能力带来隐患,给客户造成损失。鉴于此,如图1所示,本发明实施例提供一种基于微服务架构的服务器管理系统,包括微服务模块,微服务模块的输入端连接有服务网关集群模块,服务网关集群模块的输入端连接有负载均衡模块,负载均衡模块的输入端连接有外部请求模块;Due to the complex dependencies between microservices, a request may rely on multiple backend services. In actual production, these services may malfunction or be delayed. Once a service is delayed, it may consume time in a short period of time. It exhausts system resources, brings down the entire system, reduces system reliability and stability, brings hidden dangers to the server's business processing capabilities, and causes losses to customers. In view of this, as shown in Figure 1, an embodiment of the present invention provides a server management system based on a microservice architecture, including a microservice module. The input end of the microservice module is connected to a service gateway cluster module. The input end of the service gateway cluster module A load balancing module is connected, and an external request module is connected to the input end of the load balancing module;
服务网关集群模块输出端和微服务模块的输入端均连接有服务器注册模块,微服务器的输出端连接有服务器容错模块;The output end of the service gateway cluster module and the input end of the microservice module are both connected to the server registration module, and the output end of the microserver is connected to the server fault tolerance module;
外部请求模块,用于接收客户端的高并发、高通量的访问请求;The external request module is used to receive high-concurrency and high-throughput access requests from clients;
负载均衡模块,用于根据客户端的访问请求自动分配应用的传入流量;The load balancing module is used to automatically distribute the incoming traffic of the application based on the client's access request;
服务网关集群模块,用于对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;The service gateway cluster module is used to parse access requests, query the service registry according to the parsing results, discover the target service, and call it;
当微服务模块所提供的目标服务产生故障或者延迟时,通过服务器容错模块对故障进行隔离和容错。When the target service provided by the microservice module fails or is delayed, the fault is isolated and tolerated through the server fault tolerance module.
外部请求模块接收客户端的高并发、高通量的访问,负载均衡模块自动分配应用的传入流量,即可以起到一个分流的作用,同时对服务进行加密,保证客户端请求的安全性;服务网关集群模块则通过查询服务注册表就可以发现目标服务进行调用;其中服务网关集群模块和微服务模块的服务访问由集群服务器来实现注册与发现;在微服务模块的输出端连接有服务器容错模块,在高负载高并发的场景,当微服务模块所提供的目标服务产生故障或者延迟时,可通过服务器容错模块对其故障进行隔离和容错。这样,整个设计就是从输入到输出,对流量和服务疏通导流,解决了目前由于微服务之间存在错综复杂的依赖关系,降低服务器在使用过程中,由于某个服务产生延迟,导致整个系统耗尽资源,进而出现拖垮整个系统的现象,提高系统运行时稳定性的优点。The external request module receives high-concurrency and high-throughput access from the client, and the load balancing module automatically distributes the incoming traffic of the application, which can play a role of diversion and at the same time encrypt the service to ensure the security of client requests; service The gateway cluster module can discover the target service and call it by querying the service registry; the service access of the service gateway cluster module and microservice module is registered and discovered by the cluster server; a server fault tolerance module is connected to the output end of the microservice module , In high load and high concurrency scenarios, when the target service provided by the microservice module fails or is delayed, the server fault tolerance module can be used to isolate and tolerate the fault. In this way, the entire design is to unblock traffic and services from input to output, solve the current intricate dependencies between microservices, and reduce the consumption of the entire system due to delays in certain services during the use of the server. It will exhaust resources and bring down the entire system, which has the advantage of improving the stability of the system during operation.
在有些实施例中,服务网关集群模块包括多组网关,客户端均通过请求网关访问微服务模块;网关,用于收集数据以及访问日志信息。In some embodiments, the service gateway cluster module includes multiple groups of gateways, and clients access the microservice module by requesting the gateways; the gateways are used to collect data and access log information.
使用的时候,当网关服务转发外部请求调用前端服务时,通过查询服务注册表就可以发现目标服务进行调用,一次请求可能涉及到多个服务之间的相互调用。When used, when the gateway service forwards an external request to call the front-end service, the target service can be found and called by querying the service registry. A request may involve mutual calls between multiple services.
如图2所示,服务网关集群模块由多组gateway模块(本申请中的网关)构成,其中gateway模块就可以理解是外界系统和企业内部系统之间的一道门,所有的客户端均通过请求gateway模块访问微服务模块。As shown in Figure 2, the service gateway cluster module is composed of multiple groups of gateway modules (gateways in this application). The gateway module can be understood as a door between the external system and the internal system of the enterprise. All clients pass the request The gateway module accesses the microservice module.
需要说明的是,服务网关集群模块还包括动态路由模块、限流容错模块和身份认证及安全控制模块;It should be noted that the service gateway cluster module also includes a dynamic routing module, a current limiting fault tolerance module, and an identity authentication and security control module;
动态路由模块,用于动态的将访问请求路由到所需要的服务集群;Dynamic routing module, used to dynamically route access requests to the required service cluster;
限流容错模块,用于为每种类型的请求分配容量,当请求数量超过阀值时抛掉外部请求来限制流量;The current limiting fault tolerance module is used to allocate capacity for each type of request. When the number of requests exceeds the threshold, external requests are thrown away to limit traffic;
身份认证及安全控制模块,用于对每个外部请求进行用户认证,拒绝没有通过认证的请求。The identity authentication and security control module is used to authenticate users for each external request and reject requests that fail authentication.
动态路由:动态的将请求路由到所需要的后端服务集群。限流和容错:就是为每种类型的请求分配容量,当请求数量超过阀值时抛掉外部请求,限制流量,就可以保护后台服务不被大流量冲垮;身份认证和安全性控制:可以对每个外部请求进行用户认证,拒绝没有通过认证的请求;监控:即网关可以收集有意义的数据和统计,为后台服务优化提供数据支持;访问日志:网关可以收集访问日志信息,通过分析日志内容,对后台系统做进一步优化。Dynamic routing: Dynamically route requests to the required backend service cluster. Current limiting and fault tolerance: Allocate capacity for each type of request. When the number of requests exceeds the threshold, external requests are discarded and the traffic is limited. This can protect the background service from being overwhelmed by heavy traffic; Identity authentication and security control: It can User authentication is performed for each external request, and requests that fail to pass authentication are rejected; monitoring: that is, the gateway can collect meaningful data and statistics to provide data support for background service optimization; access log: the gateway can collect access log information and analyze the log content , further optimize the backend system.
在有些实施例中,负载均衡模块包括负载均衡控制模块和安全加密模块;In some embodiments, the load balancing module includes a load balancing control module and a security encryption module;
负载均衡控制模块,用于在多网关中自动分配应用的传入流量;Load balancing control module for automatically distributing an application's incoming traffic across multiple gateways;
安全加密模块,用于保证客户端请求的安全性。Security encryption module, used to ensure the security of client requests.
负载均衡模块顾名思义是为了应对高并发的访问场景,由于gateway(网关)模块是以集群形式部署的,所以需要做到gateway模块访问时的负载均衡。其中负载均衡模块由负载均衡控制模块和安全加密模块两个所构成,负载均衡控制模块,在多个gateway模块中自动分配应用的传入流量,而安全加密模块则用于保证客户端请求的安全性。负载均衡使用ELB模块,安全加密可以采用比较稳妥的SSL加密。As the name suggests, the load balancing module is designed to cope with high-concurrency access scenarios. Since the gateway module is deployed in a cluster, it is necessary to achieve load balancing when accessing the gateway module. The load balancing module consists of a load balancing control module and a security encryption module. The load balancing control module automatically distributes the incoming traffic of the application among multiple gateway modules, while the security encryption module is used to ensure the security of client requests. sex. Load balancing uses the ELB module, and security encryption can use relatively reliable SSL encryption.
使用时,为了应对高并发的访问,服务网关以集群形式部署,这个意思就是需要做负载均衡,可采用虚拟云服务器,做负载均衡,由于虚拟云服务器具有自动配置容量功能,当用户流量达到尖峰,虚拟云服务器可以自动增加更多的容量以维持虚拟主机的性能,而由于负载均衡,可在多个服务网关间自动分配应用的传入流量。When used, in order to cope with high concurrent access, the service gateway is deployed in the form of a cluster. This means that load balancing is required. Virtual cloud servers can be used for load balancing. Since the virtual cloud server has the function of automatically configuring capacity, when user traffic reaches peak , the virtual cloud server can automatically add more capacity to maintain the performance of the virtual host, and due to load balancing, the incoming traffic of the application can be automatically distributed among multiple service gateways.
在有些实施例中,该系统还包括集群服务器,所有的微服务在集群服务器中进行注册,并定时发送健康检查到集群服务器;In some embodiments, the system also includes a cluster server. All microservices are registered in the cluster server and health checks are sent to the cluster server regularly;
集群服务器在接收到微服务的最后一次健康检查后,等待第一时间阈值未接收到微服务的健康检查,在集群服务器自我保护模式关闭的情况下清除该微服务的注册信息。After receiving the last health check of the microservice, the cluster server waits for the first time threshold and clears the registration information of the microservice when the self-protection mode of the cluster server is turned off.
集群服务器在设定时间内丢失超多设定阈值数量的服务时,会进入自我保护模式,在自我保护模式下集群服务器等待第一时间阈值未接收到微服务的健康检查时,集群服务器也不会将其删除。When the cluster server loses more than the set threshold number of services within the set time, it will enter the self-protection mode. In the self-protection mode, the cluster server will not receive the health check of the microservice after waiting for the first time threshold. It will be deleted.
最前端的外部请求模块就是客户端,如pc或者手机等客户终端。The front-end external request module is the client, such as a client terminal such as a PC or a mobile phone.
上面说的服务器注册模块具体由集群服务器模块所构成,由于微服务架构是由一系列职责单一的服务构成的网状结构,服务之间通过轻量机制进行通信,这就引入了服务注册和发现的问题,服务的提供方要注册报告服务地址,服务调用方要能发现目标服务,因此服务网关集群模块和微服务模块的服务访问由集群服务器来实现注册与发现。The server registration module mentioned above is specifically composed of a cluster server module. Since the microservice architecture is a mesh structure composed of a series of services with single responsibilities, the services communicate through lightweight mechanisms, which introduces service registration and discovery. The service provider must register and report the service address, and the service caller must be able to discover the target service. Therefore, the service access of the service gateway cluster module and microservice module is registered and discovered by the cluster server.
具体来说就是:所有的微服务到集群服务器中进行注册,并定时发送健康检查,集群服务器默认配置是20秒发送一次健康检查(此处设置20秒考虑提高检查频率),表明服务仍然处于存活状态,发送健康检查的时间间隔可以通过集群服务器配置参数自行配置,集群服务器在接收到服务实例的最后一次健康检查后,需要等待60秒(默认配置60秒,也可以通过配置参数进行修改)后,才认定服务已经死亡(即连续3次(20x3)没有接收到心跳),在集群服务器自我保护模式关闭的情况下会清除该服务的注册信息。Specifically: all microservices register in the cluster server and send health checks regularly. The default configuration of the cluster server is to send a health check every 20 seconds (set 20 seconds here to consider increasing the check frequency), indicating that the service is still alive. Status, the time interval for sending health checks can be configured by the cluster server configuration parameters. After the cluster server receives the last health check of the service instance, it needs to wait 60 seconds (the default configuration is 60 seconds, which can also be modified through the configuration parameters). , it is determined that the service is dead (that is, no heartbeat is received for 3 consecutive times (20x3)). When the cluster server self-protection mode is turned off, the registration information of the service will be cleared.
这里说的自我保护模式是指:出现网络分区、集群服务器在短时间内丢失过多的服务时,会进入自我保护模式,即一个服务长时间没有发送心跳,集群服务器也不会将其删除。The self-protection mode mentioned here means that when a network partition occurs and the cluster server loses too many services in a short period of time, it will enter the self-protection mode. That is, if a service does not send heartbeats for a long time, the cluster server will not delete it.
在有些实施例中,服务器容错模块,用于当服务异常或者第二设定阈值数量的服务延时时,主动启动熔断,或自动启动熔断模式,且服务隔离设定时间段以后,设置进入半熔断状态,若仍然调用失败,则回到熔断状态,若调用成功,则关闭熔断模式。In some embodiments, the server fault tolerance module is used to actively activate the circuit breaker or automatically activate the circuit breaker mode when the service is abnormal or the service is delayed by a second set threshold number, and after the service isolation set time period, the setting enters half-time. In the fuse state, if the call still fails, it will return to the fuse state. If the call is successful, the fuse mode will be turned off.
服务器容错模块,用于设置不同的服务使用不同的线程池;当服务调用出现异常时,直接抛弃异常;当程序运行超时、熔断启动或线程池已满时启用回退;还用于对服务的并发访问量进行限制,设置单位时间内的并发数,超出限制的请求拒绝并回退。The server fault tolerance module is used to set different services to use different thread pools; when an exception occurs in a service call, the exception is discarded directly; when the program runs out of time, the circuit breaker is started, or the thread pool is full, rollback is enabled; it is also used to configure the service Limit the number of concurrent visits and set the number of concurrencies per unit time. Requests that exceed the limit will be rejected and rolled back.
如图3所示,服务器容错模块包括熔断模式、隔离模式、回退模式和限流模式。As shown in Figure 3, the server fault tolerance module includes circuit breaker mode, isolation mode, fallback mode and current limiting mode.
再说下各个模式:熔断模式:当服务异常或者大量延时,满足熔断条件时,服务调用方会主动启动熔断,执行直接返回,不会继续调用服务进一步拖垮系统,或采用自动熔断模式,当超过阀值将自动启动熔断模式,且服务隔离一段时间以后,熔断器会进入半熔断状态,即允许少量请求进行尝试,如果仍然调用失败,则回到熔断状态,如果调用成功,则关闭熔断模式。Let’s talk about each mode: Circuit breaker mode: When the service is abnormal or has a large delay, and the circuit breaker conditions are met, the service caller will actively initiate the circuit breaker, and the execution will return directly without continuing to call the service to further bring down the system, or use the automatic circuit breaker mode. If the threshold is exceeded, the fuse mode will be automatically activated, and after the service is isolated for a period of time, the fuse will enter the semi-fuse state, which allows a small number of requests to be tried. If the call still fails, it will return to the fuse state. If the call is successful, the fuse mode will be turned off. .
隔离模式:不同的服务使用不同的线程池,彼此之间不受影响,当一个服务出现故障耗尽它的线程池资源,其他的服务正常运行不受影响,达到隔离的效果;Isolation mode: Different services use different thread pools and are not affected by each other. When a service fails and exhausts its thread pool resources, the normal operation of other services is not affected, achieving the isolation effect;
回退:当服务调用出现异常时,可直接抛弃异常,或返回上一步,当出现以下异常情况时,可启用回退情况:程序运行超时、熔断启动和线程池已满;Rollback: When an exception occurs in a service call, you can directly discard the exception or return to the previous step. When the following exceptions occur, rollback can be enabled: program running timeout, circuit breaker startup, and thread pool is full;
限流:限流可对服务的并发访问量进行限制,设置单位时间内的并发数,超出限制的请求拒绝并回退,防止后台服务被冲垮。这里说的容错模块可以由Hystrix组件处理,比较方便。Current limiting: Current limiting can limit the number of concurrent accesses to the service and set the number of concurrencies per unit time. Requests that exceed the limit will be rejected and rolled back to prevent background services from being overwhelmed. The fault tolerance module mentioned here can be handled by Hystrix components, which is more convenient.
微服务架构增加负载均衡,由负载均衡控制模块和安全加密模块所构成,自动分配应用的传入流量,可以起到一个分流的作用,降低高并发访问流量集中于一组会多组服务网关的情况,同时对服务进行加密,保证客户端请求的安全性。服务网关集群模块和微服务模块的服务访问由集群服务器来实现注册与发现,这样通过查询服务注册表就可以发现目标服务进行调用。The microservice architecture adds load balancing, which is composed of a load balancing control module and a security encryption module. It automatically distributes the incoming traffic of the application, which can play a diversion role and reduce the concentration of high concurrent access traffic on one group or multiple groups of service gateways. situation, and at the same time encrypts the service to ensure the security of client requests. The service access of the service gateway cluster module and microservice module is registered and discovered by the cluster server, so that the target service can be discovered and called by querying the service registry.
服务器容错模块包括熔断、隔离、回退和限流模式,使用时,当微服务模块所提供的目标服务产生故障或者延迟时,可通过容错模块对其故障进行隔离和容错,降低服务器由于某个服务产生延迟,导致耗尽系统资源的情况。The server fault tolerance module includes fusing, isolation, fallback and current limiting modes. When used, when the target service provided by the microservice module fails or is delayed, the fault tolerance module can be used to isolate and tolerate the fault, reducing the server's risk of a certain The service is delayed, resulting in exhaustion of system resources.
外部请求模块接收客户端发送的访问请求,负载均衡模块接入客户端的访问请求,并将访问请求按照预定策略发送给一个或多个网关对访问请求中携带的用户登录账号进行身份认证,判断所述登录账号是否有访问权限;在有访问权限时,根据访问请求中携带的请求内容,从服务注册表确定出请求内容对应的目标微服务;从服务器注册模块确定出所述目标微服务的地址,并根据所述访问请求调用所述访问请求对应的所述微服务的服务接口,访问所述目标微服务,调用所述目标微服务响应所述访问请求,具体的,访问请求为获取数据的请求时,目标微服务访问缓存,判断缓存中是否缓存有所述访问请求对应的数据;当缓存有对应的数据时,目标微服务从缓存中获取数据;当缓存中未有对应的数据时,目标微服务从数据库查找并获取对应的数据并将获取数据进行缓存同时将请求对应的数据发送至所述客户端。访问日志记录接收到的各个访问请求,以及对各个请求用户的身份认证的相关信息以及访问请求对应的请求结果。The external request module receives the access request sent by the client, and the load balancing module accesses the client's access request, and sends the access request to one or more gateways according to the predetermined policy to authenticate the user login account carried in the access request and determine whether Whether the above login account has access rights; if there is access rights, according to the request content carried in the access request, determine the target microservice corresponding to the request content from the service registration table; determine the address of the target microservice from the server registration module , and call the service interface of the microservice corresponding to the access request according to the access request, access the target microservice, and call the target microservice to respond to the access request. Specifically, the access request is to obtain data. When requesting, the target microservice accesses the cache and determines whether the data corresponding to the access request is cached in the cache; when the cache has corresponding data, the target microservice obtains the data from the cache; when there is no corresponding data in the cache, The target microservice searches for and obtains the corresponding data from the database, caches the obtained data, and sends the requested data corresponding to the client. The access log records each access request received, as well as information related to the identity authentication of each requesting user and the request result corresponding to the access request.
如图4所示,本发明实施例提供一种基于微服务架构的服务器管理方法,应用于上述实施例所述的系统,所述方法包括如下步骤:As shown in Figure 4, the embodiment of the present invention provides a server management method based on microservice architecture, which is applied to the system described in the above embodiment. The method includes the following steps:
步骤1:接收客户端的高并发、高通量的访问请求;Step 1: Receive high-concurrency and high-throughput access requests from clients;
步骤2:根据客户端的访问请求自动分配应用的传入流量;Step 2: Automatically distribute the application’s incoming traffic based on the client’s access request;
步骤3:对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;Step 3: Parse the access request, query the service registry according to the parsing results, find the target service, and call it;
步骤4:当目标服务产生故障或延迟时,对故障的服务进行隔离和容错。Step 4: When the target service fails or is delayed, isolate and tolerate the failed service.
需要说明的是,该方法还包括:将所有的微服务注册到集群服务器中并生成服务注册表;通过设置微服务定时发送健康检查来进行微服务的管理。It should be noted that this method also includes: registering all microservices into the cluster server and generating a service registry; and managing the microservices by setting the microservices to send health checks regularly.
进一步需要说明的是,通过设置微服务定时发送健康检查来进行微服务的管理的步骤包括:微服务定时发送健康检查到集群服务器;集群服务器在接收到微服务的最后一次健康检查后,等待第一时间阈值未接收到微服务的健康检查;判断集群服务器在设定时间内是否丢失超多设定阈值数量的服务;若是,集群服务器自我保护模式开启;清除该微服务的注册信息;若否,集群服务器自我保护模式关闭;不清除该微服务的注册信息。It should be further explained that the steps for managing microservices by setting up microservices to regularly send health checks include: microservices regularly send health checks to the cluster server; after receiving the last health check of the microservice, the cluster server waits for the The health check of the microservice is not received for a time threshold; determine whether the cluster server has lost more than the set threshold number of services within the set time; if so, the cluster server self-protection mode is turned on; the registration information of the microservice is cleared; if not , the cluster server self-protection mode is turned off; the registration information of the microservice is not cleared.
也就是说,所有的微服务到集群服务器中进行注册,并定时发送健康检查,集群服务器默认配置是20秒发送一次健康检查(此处设置20秒考虑提高检查频率),表明服务仍然处于存活状态,发送健康检查的时间间隔可以通过集群服务器配置参数自行配置,集群服务器在接收到服务实例的最后一次健康检查后,需要等待60秒(默认配置60秒,也可以通过配置参数进行修改)后,才认定服务已经死亡(即连续3次(20x3)没有接收到心跳),在集群服务器自我保护模式关闭的情况下会清除该服务的注册信息。这里说的自我保护模式是指:出现网络分区、集群服务器在短时间内丢失过多的服务时,会进入自我保护模式,即一个服务长时间没有发送心跳,集群服务器也不会将其删除。That is to say, all microservices register with the cluster server and send health checks regularly. The default configuration of the cluster server is to send a health check every 20 seconds (setting 20 seconds here considers increasing the check frequency), indicating that the service is still alive. , the time interval for sending health checks can be configured by the cluster server configuration parameters. After the cluster server receives the last health check of the service instance, it needs to wait 60 seconds (the default configuration is 60 seconds, which can also be modified through the configuration parameters). Only after it is determined that the service is dead (that is, no heartbeats are received for three consecutive times (20x3)), the registration information of the service will be cleared when the self-protection mode of the cluster server is turned off. The self-protection mode mentioned here means that when a network partition occurs and the cluster server loses too many services in a short period of time, it will enter the self-protection mode. That is, if a service does not send heartbeats for a long time, the cluster server will not delete it.
在有些实施例中,对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用的步骤包括:In some embodiments, the steps of parsing the access request, querying the service registry according to the parsing results, discovering the target service and calling it include:
步骤31:对每个外部请求进行用户认证;Step 31: Perform user authentication for each external request;
步骤32:判断是否认证通过;Step 32: Determine whether the authentication is passed;
若是,执行步骤33;若否,执行步骤36;If yes, go to step 33; if not, go to step 36;
步骤33:动态的将访问请求路由到所需要的服务集群;Step 33: Dynamically route the access request to the required service cluster;
步骤34:为每种类型的请求分配容量,当请求数量超过阀值时抛掉外部请求来限制流量;Step 34: Allocate capacity for each type of request, and when the number of requests exceeds the threshold, discard external requests to limit traffic;
步骤35:查询服务注册表发现目标服务进行调用;Step 35: Query the service registry to find the target service and call it;
步骤36:拒绝没有通过认证的请求。Step 36: Reject requests that fail authentication.
在有些实施例中,当目标服务产生故障或延迟时,对故障的服务进行隔离和容错的步骤包括:In some embodiments, when a target service fails or is delayed, the steps of isolating and fault-tolerating the failed service include:
当目标服务异常或者超过第一阈值的目标服务延时,设置主动启动熔断执行直接返回;When the target service is abnormal or the target service delay exceeds the first threshold, set the active circuit breaker to execute and return directly;
或自动启动熔断模式,且服务隔离设定时间段以后,设置进入半熔断状态,若仍然调用失败,则回到熔断状态,若调用成功,则关闭熔断模式;Or automatically start the circuit breaker mode, and after the service isolation set time period, the setting enters the semi circuit breaker state. If the call still fails, it returns to the circuit breaker state. If the call is successful, the circuit breaker mode is turned off;
当目标服务调用出现异常时,判断是否存在程序运行超异常、熔断启动和线程池已满的情况;When an exception occurs in the target service call, determine whether there is a program running abnormally, circuit breaker startup, or the thread pool is full;
若是,启用回退;If so, enable fallback;
若否,直接抛弃异常,或返回上一步。If not, discard the exception directly or return to the previous step.
也就是说,熔断模式:当服务异常或者大量延时,满足熔断条件时,服务调用方会主动启动熔断,执行直接返回,不会继续调用服务进一步拖垮系统,或采用自动熔断模式,当超过阀值将自动启动熔断模式,且服务隔离一段时间以后,熔断器会进入半熔断状态,即允许少量请求进行尝试,如果仍然调用失败,则回到熔断状态,如果调用成功,则关闭熔断模式。That is to say, the circuit breaker mode: when the service is abnormal or has a large delay and the circuit breaker conditions are met, the service caller will actively initiate circuit breaker and return directly without continuing to call the service to further bring down the system, or adopt the automatic circuit breaker mode. The threshold will automatically activate the circuit breaker mode, and after the service is isolated for a period of time, the circuit breaker will enter a semi-circuit state, which allows a small number of requests to be tried. If the call still fails, it will return to the circuit breaker state. If the call is successful, the circuit breaker will turn off the circuit breaker mode.
隔离模式:不同的服务使用不同的线程池,彼此之间不受影响,当一个服务出现故障耗尽它的线程池资源,其他的服务正常运行不受影响,达到隔离的效果;Isolation mode: Different services use different thread pools and are not affected by each other. When a service fails and exhausts its thread pool resources, the normal operation of other services is not affected, achieving the isolation effect;
回退:当服务调用出现异常时,可直接抛弃异常,或返回上一步,当出现以下异常情况时,可启用回退情况:程序运行超时、熔断启动和线程池已满;Rollback: When an exception occurs in a service call, you can directly discard the exception or return to the previous step. When the following exceptions occur, rollback can be enabled: program running timeout, circuit breaker startup, and thread pool is full;
限流:限流可对服务的并发访问量进行限制,设置单位时间内的并发数,超出限制的请求拒绝并回退,防止后台服务被冲垮。Current limiting: Current limiting can limit the number of concurrent accesses to the service and set the number of concurrencies per unit time. Requests that exceed the limit will be rejected and rolled back to prevent background services from being overwhelmed.
如图5所示,本发明实施例还提供一种电子设备,所述电子设备包括:处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信。通信总线可以用于电子设备与传感器之间的信息传输。处理器可以调用存储器中的逻辑指令,以执行如下方法:步骤1:接收客户端的高并发、高通量的访问请求;步骤2:根据客户端的访问请求自动分配应用的传入流量;步骤3:对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;步骤4:当目标服务产生故障或延迟时,对故障的服务进行隔离和容错。As shown in Figure 5, an embodiment of the present invention also provides an electronic device. The electronic device includes: a processor, a communication interface, a memory, and a communication bus. The processor, the communication interface, and the memory complete mutual communication through the communication bus. communication. A communication bus can be used to transmit information between electronic devices and sensors. The processor can call logical instructions in the memory to perform the following methods: Step 1: Receive high-concurrency, high-throughput access requests from the client; Step 2: Automatically distribute the incoming traffic of the application according to the client's access requests; Step 3: Parse the access request, query the service registry according to the parsing results, find the target service, and call it; Step 4: When the target service fails or is delayed, isolate and fault-tolerate the failed service.
此外,上述的存储器中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logical instructions in the memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. .
本发明实施例提供一种非暂态计算机可读存储介质,该非暂态计算机可读存储介质存储计算机指令,该计算机指令使计算机执行上述方法实施例所提供的方法,例如包括:步骤1:接收客户端的高并发、高通量的访问请求;步骤2:根据客户端的访问请求自动分配应用的传入流量;步骤3:对访问请求进行解析,根据解析结果查询服务注册表发现目标服务进行调用;步骤4:当目标服务产生故障或延迟时,对故障的服务进行隔离和容错。Embodiments of the present invention provide a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions. The computer instructions cause the computer to execute the method provided by the above method embodiment, for example, including: Step 1: Receive high-concurrency, high-throughput access requests from clients; Step 2: Automatically allocate the incoming traffic of the application according to the client's access requests; Step 3: Parse the access requests, query the service registry according to the parsing results, discover the target service, and call it ; Step 4: When the target service fails or is delayed, isolate and tolerate the failed service.
作为本发明的基于微服务架构的服务器管理系统、方法、设备及介质是结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。As the server management system, method, device and medium based on the microservice architecture of the present invention, they are the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein, and can be implemented by electronic hardware, computer software or a combination of both. Implementation, in order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered to be beyond the scope of the present invention.
尽管通过参考附图并结合优选实施例的方式对本发明进行了详细描述,但本发明并不限于此。在不脱离本发明的精神和实质的前提下,本领域普通技术人员可以对本发明的实施例进行各种等效的修改或替换,而这些修改或替换都应在本发明的涵盖范围内/任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。Although the present invention has been described in detail with reference to the accompanying drawings in conjunction with preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the invention, those of ordinary skill in the art can make various equivalent modifications or substitutions to the embodiments of the invention, and these modifications or substitutions should be within the scope of the invention/any Those skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention, and they should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310944167.2A CN116886704A (en) | 2023-07-28 | 2023-07-28 | Server management system, method, equipment and medium based on micro-service architecture |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310944167.2A CN116886704A (en) | 2023-07-28 | 2023-07-28 | Server management system, method, equipment and medium based on micro-service architecture |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116886704A true CN116886704A (en) | 2023-10-13 |
Family
ID=88260286
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310944167.2A Pending CN116886704A (en) | 2023-07-28 | 2023-07-28 | Server management system, method, equipment and medium based on micro-service architecture |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116886704A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118694811A (en) * | 2024-08-27 | 2024-09-24 | 国网江苏电动汽车服务有限公司 | A platform management system and method based on microservice architecture |
-
2023
- 2023-07-28 CN CN202310944167.2A patent/CN116886704A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118694811A (en) * | 2024-08-27 | 2024-09-24 | 国网江苏电动汽车服务有限公司 | A platform management system and method based on microservice architecture |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6600373B2 (en) | System and method for active-passive routing and control of traffic in a traffic director environment | |
CN112261172B (en) | Service addressing access method, device, system, equipment and medium | |
CN102571947B (en) | Processing method proxy method, device and system | |
CN106856434A (en) | The method and apparatus of access request conversion | |
CN106911648B (en) | A kind of environment isolation method and equipment | |
CN112202872A (en) | Data forwarding method, API gateway and message service system | |
US10567492B1 (en) | Methods for load balancing in a federated identity environment and devices thereof | |
CN112968965B (en) | Metadata service method, server and storage medium of NFV network node | |
CN113839862A (en) | Method, system, terminal and storage medium for synchronizing ARP information between MCLAG neighbors | |
CN112003721A (en) | A method and device for realizing high availability of a management node of a big data platform | |
CN116886704A (en) | Server management system, method, equipment and medium based on micro-service architecture | |
CN113542373A (en) | Routing service discovery device and method for PAAS platform | |
CN115913583A (en) | Business data access method, device and equipment and computer storage medium | |
US7350065B2 (en) | Method, apparatus and program storage device for providing a remote power reset at a remote server through a network connection | |
WO2024103943A1 (en) | Service processing method and apparatus, storage medium, and device | |
US20230370938A1 (en) | Traffic sending method, apparatus, and system, and storage medium | |
CN114301872B (en) | Domain name based access method and device, electronic equipment and storage medium | |
CN118694651A (en) | Microservice health check method, device, system and computer equipment | |
CN114331445A (en) | API (application programming interface), method, storage medium and electronic equipment for accessing massive users | |
CN104363275A (en) | Method, device and system for processing data by using agencies | |
US9401837B2 (en) | Network management method and network management system | |
CN112433820A (en) | Method and system for acquiring IP (Internet protocol) of virtual machine host | |
CN116743845B (en) | Edge service discovery method, device, node device and readable storage medium | |
CN116866415A (en) | Service management method and system | |
WO2024113776A1 (en) | Data transmission method and related device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |