CN106412016A - Connection control method and device for server - Google Patents
Connection control method and device for server Download PDFInfo
- Publication number
- CN106412016A CN106412016A CN201610786461.5A CN201610786461A CN106412016A CN 106412016 A CN106412016 A CN 106412016A CN 201610786461 A CN201610786461 A CN 201610786461A CN 106412016 A CN106412016 A CN 106412016A
- Authority
- CN
- China
- Prior art keywords
- service instance
- request
- service
- link information
- forwarding
- 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
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/14—Session management
- H04L67/143—Termination or inactivation of sessions, e.g. event-controlled end of session
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0823—Errors, e.g. transmission errors
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/16—Threshold monitoring
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Environmental & Geological Engineering (AREA)
- Computer And Data Communications (AREA)
Abstract
本发明公开了一种服务器的连接控制方法,包括步骤:在停止转发服务请求至服务实例后,将预设数量的请求访问转发至所述服务实例上;在所述服务实例正确响应转发的请求时,恢复转发服务请求至所述服务实例上;在所述服务实例未响应转发的请求时,保持停止转发服务请求至所述服务实例上。本发明还公开了一种服务器的连接控制装置。本发明充分利用资源,提高业务体验。
The invention discloses a connection control method of a server, comprising the steps of: after stopping forwarding of service requests to service instances, forwarding a preset number of access requests to the service instances; after the service instances correctly respond to the forwarded requests , resume forwarding the service request to the service instance; when the service instance does not respond to the forwarded request, keep stopping forwarding the service request to the service instance. The invention also discloses a server connection control device. The present invention makes full use of resources and improves service experience.
Description
技术领域technical field
本发明涉及服务器技术领域,尤其涉及服务器的连接控制方法及装置。The invention relates to the technical field of servers, in particular to a server connection control method and device.
背景技术Background technique
随着业务的发展与多样化,客户端发起的业务请求也随之变多。当业务服务依赖的资源出现问题,某些服务实例出现慢响应、假死甚至无响应的情况。而目前对于上述问题,会继续将业务请求转发至该服务实例上,直至该服务实例宕机。因此,目前客户端与服务端的连接建立因无法及时解决服务实例响应慢,导致业务请求响应不及时,使得业务体验差。With the development and diversification of services, the number of service requests initiated by clients also increases. When there is a problem with the resources that the business service depends on, some service instances respond slowly, freeze or even fail to respond. Currently, for the above problems, business requests will continue to be forwarded to the service instance until the service instance goes down. Therefore, the current connection establishment between the client and the server cannot solve the slow response of the service instance in time, resulting in the untimely response to the business request, resulting in poor business experience.
上述内容仅用于辅助理解本发明的技术方案,并不代表承认上述内容是现有技术。The above content is only used to assist in understanding the technical solution of the present invention, and does not mean that the above content is admitted as prior art.
发明内容Contents of the invention
本发明的主要目的在于提供一种服务器的连接控制方法及装置,旨在解决目前客户端与服务端的连接建立因无法及时解决服务实例响应慢,导致业务请求响应不及时,使得业务体验差的问题。The main purpose of the present invention is to provide a server connection control method and device, aiming at solving the problem that the connection establishment between the client and the server cannot solve the slow response of the service instance in time, resulting in untimely response to business requests and poor business experience .
为实现上述目的,本发明提供的一种服务器的连接控制方法,包括步骤:In order to achieve the above object, the present invention provides a server connection control method, comprising steps:
在停止转发服务请求至服务实例后,将预设数量的请求访问转发至所述服务实例上;After stopping forwarding the service request to the service instance, forwarding a preset number of request accesses to the service instance;
在所述服务实例正确响应转发的请求时,恢复转发服务请求至所述服务实例上;When the service instance correctly responds to the forwarded request, resume forwarding the service request to the service instance;
在所述服务实例未响应转发的请求时,保持停止转发服务请求至所述服务实例上。When the service instance does not respond to the forwarded request, keep stopping forwarding the service request to the service instance.
优选地,所述将预设数量的请求访问转发至所述服务实例上之后,还包括:Preferably, after forwarding the preset number of access requests to the service instance, it further includes:
确定响应的请求的数量;Determine the number of requests to respond to;
计算确定的数量在预设数量中所占的比例;Calculate the ratio of the determined quantity to the preset quantity;
在计算的比例大于预设比例阈值时,判定所述服务实例能正确响应转发的请求。When the calculated ratio is greater than the preset ratio threshold, it is determined that the service instance can correctly respond to the forwarded request.
优选地,所述方法还包括:Preferably, the method also includes:
获取服务实例在一个检测周期内的链接信息;Obtain link information of a service instance within a detection cycle;
判断所述链接信息是否满足预设的断开条件;judging whether the link information satisfies a preset disconnection condition;
在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。Stop forwarding the service request to the service instance after the link information satisfies the preset disconnection condition.
优选地,所述判断所述链接信息是否满足预设的断开条件包括:Preferably, the judging whether the link information satisfies a preset disconnection condition includes:
从所述连接信息中提取发生链接错误请求的数量;Extracting the number of connection error requests from the connection information;
在所述链接错误的数量大于预设的第一数量阈值时,判定所述链接信息是否满足预设的断开条件。When the number of link errors is greater than a preset first number threshold, it is determined whether the link information satisfies a preset disconnection condition.
优选地,所述判断所述链接信息是否满足预设的断开条件包括:Preferably, the judging whether the link information satisfies a preset disconnection condition includes:
从所述链接信息中提取发生链接超时请求的数量;Extracting the number of connection timeout requests from the connection information;
在所述链接超时的数量大于预设的第二数量阈值时,判定所述链接信息是否满足预设的断开条件。When the number of link timeouts is greater than a preset second number threshold, it is determined whether the link information satisfies a preset disconnection condition.
此外,为实现上述目的,本发明还提供一种服务器的连接控制装置,包括:In addition, in order to achieve the above object, the present invention also provides a server connection control device, including:
控制模块,用于在停止转发服务请求至服务实例后,将预设数量的请求访问转发至所述服务实例上;A control module, configured to forward a preset number of access requests to the service instance after stopping forwarding the service request to the service instance;
恢复模块,用于在所述服务实例正确响应转发的请求时,恢复转发服务请求至所述服务实例上;A recovery module, configured to recover and forward the service request to the service instance when the service instance correctly responds to the forwarded request;
所述控制模块,还用于在所述服务实例未响应转发的请求时,保持停止转发服务请求至所述服务实例上。The control module is further configured to stop forwarding the service request to the service instance when the service instance does not respond to the forwarded request.
优选地,所述装置还包括:Preferably, the device also includes:
确定模块,用于确定响应的请求的数量;A determining module, configured to determine the number of requests to respond to;
计算模块,用于计算确定的数量在预设数量中所占的比例;A calculation module, used to calculate the proportion of the determined quantity in the preset quantity;
判断模块,用于在计算的比例大于预设比例阈值时,判定所述服务实例能正确响应转发的请求。A judging module, configured to judge that the service instance can correctly respond to the forwarded request when the calculated ratio is greater than a preset ratio threshold.
优选地,装置还包括:Preferably, the device also includes:
获取模块,用于获取服务实例在一个检测周期内的链接信息;An acquisition module, configured to acquire link information of a service instance within a detection cycle;
判断模块,用于判断所述链接信息是否满足预设的断开条件;A judging module, configured to judge whether the link information satisfies a preset disconnection condition;
所述控制模块,还用于在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。The control module is further configured to stop forwarding the service request to the service instance after the link information satisfies a preset disconnection condition.
优选地,所述判断模块,包括:Preferably, the judging module includes:
判断单元,用于从所述连接信息中提取发生链接错误请求的数量;A judging unit, configured to extract the number of connection error requests from the connection information;
判定单元,用于在所述链接错误的数量大于预设的第一数量阈值时,判定所述链接信息是否满足预设的断开条件。A judging unit, configured to judge whether the link information satisfies a preset disconnection condition when the number of link errors is greater than a preset first number threshold.
优选地,所述判断单元,还用于从所述链接信息中提取发生链接超时请求的数量;Preferably, the judging unit is further configured to extract the number of link timeout requests from the link information;
所述判定单元,还用于在所述链接超时的数量大于预设的第二数量阈值时,判定所述链接信息是否满足预设的断开条件。The determining unit is further configured to determine whether the link information satisfies a preset disconnection condition when the number of link timeouts is greater than a preset second number threshold.
本发明通过对断开后的服务实例进行测试,在服务实例正确响应转发的请求后,快速的恢复转发服务请求至所述服务实例上,充分利用资源,提高业务体验。The present invention tests the disconnected service instance, and quickly recovers and forwards the service request to the service instance after the service instance correctly responds to the forwarded request, fully utilizes resources, and improves service experience.
附图说明Description of drawings
图1为本发明服务器的连接控制方法的第一实施例的流程示意图;FIG. 1 is a schematic flowchart of a first embodiment of a server connection control method according to the present invention;
图2为本发明一实施例中判断服务实例是否正确响应请求的流程示意图;Fig. 2 is a schematic flow diagram of judging whether a service instance correctly responds to a request in an embodiment of the present invention;
图3为本发明服务器的连接控制方法的第二实施例的流程示意图;FIG. 3 is a schematic flowchart of a second embodiment of a server connection control method according to the present invention;
图4为本发明一实施例中判断所述链接信息是否满足预设的断开条件的流程示意图;FIG. 4 is a schematic flowchart of judging whether the link information meets a preset disconnection condition in an embodiment of the present invention;
图5为本发明另一实施例中判断所述链接信息是否满足预设的断开条件的流程示意图;FIG. 5 is a schematic flow diagram of judging whether the link information meets a preset disconnection condition in another embodiment of the present invention;
图6为本发明一实施例中断开计算的示意图;Fig. 6 is a schematic diagram of disconnection calculation in an embodiment of the present invention;
图7为本发明服务器的连接控制方法的第三实施例的流程示意图;7 is a schematic flowchart of a third embodiment of a server connection control method according to the present invention;
图8为本发明一实施例中客户端与服务端业务请求的架构示意图;FIG. 8 is a schematic diagram of the architecture of the client and server service requests in an embodiment of the present invention;
图9为本发明一实施例中服务实例断开的示意图;FIG. 9 is a schematic diagram of service instance disconnection in an embodiment of the present invention;
图10为本发明服务器的连接控制装置的第一实施例的功能模块示意图;FIG. 10 is a schematic diagram of functional modules of the first embodiment of the connection control device of the server of the present invention;
图11为本发明服务器的连接控制装置的第二实施例的功能模块示意图;FIG. 11 is a schematic diagram of functional modules of the second embodiment of the connection control device of the server of the present invention;
图12为图10中判断模块一实施例的细化功能模块示意图。FIG. 12 is a schematic diagram of a detailed functional module of an embodiment of the judging module in FIG. 10 .
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
参照图1,图1为本发明服务器的连接控制方法的第一实施例的流程示意图。Referring to FIG. 1 , FIG. 1 is a schematic flowchart of a first embodiment of a server connection control method according to the present invention.
在一实施例中,所述服务器的连接控制方法包括:In an embodiment, the connection control method of the server includes:
步骤S10,在停止转发服务请求至服务实例后,将预设数量的请求访问转发至所述服务实例上;在服务实例满足断开条件断开后,需要对该服务实例的断开状态实时监控,以尽快利用该服务实例进行业务服务。所述设定时间可以是2分钟或3分钟等。在间隔设定时间后,将预设数量的请求访问转发至所述服务实例上,即,将少量的请求访问转发至所述服务实例上用以测试该服务实例是否正常,能够及时响应服务请求。所述预设数量为80条或50条等,根据服务实例的性能设置。Step S10, after stopping forwarding the service request to the service instance, forward a preset number of requested accesses to the service instance; after the service instance meets the disconnection condition and disconnects, the disconnection status of the service instance needs to be monitored in real time , to use the service instance for business services as soon as possible. The set time can be 2 minutes or 3 minutes, etc. After the interval is set, forward a preset number of request visits to the service instance, that is, forward a small number of request visits to the service instance to test whether the service instance is normal and can respond to service requests in a timely manner . The preset number is 80 or 50, etc., which are set according to the performance of the service instance.
步骤S20,在所述服务实例正确响应转发的请求时,恢复转发服务请求至所述服务实例上;在所述服务实例正确响应转发的请求时,正常向所述服务实例转发服务请求,恢复所述服务实例的使用。Step S20, when the service instance correctly responds to the forwarded request, resume forwarding the service request to the service instance; when the service instance correctly responds to the forwarded request, normally forward the service request to the service instance, and restore the use of the service instance described above.
具体的,参考图2,判断服务实例正确响应转发的请求的过程包括:Specifically, referring to Figure 2, the process of judging that the service instance correctly responds to the forwarded request includes:
步骤S11,确定响应的请求的数量;在将预设数量的请求转发至该服务实例上后,监测正确转发的请求的数量,即,确定响应的请求的数量。Step S11 , determining the number of responded requests; after forwarding the preset number of requests to the service instance, monitoring the number of correctly forwarded requests, that is, determining the number of responded requests.
步骤S12,计算确定的数量在预设数量中所占的比例;计算正确转发的请求的数量和占比。Step S12, calculating the proportion of the determined quantity in the preset quantity; calculating the quantity and proportion of correctly forwarded requests.
步骤S13,在计算的比例大于预设比例阈值时,判定所述服务实例能正确响应转发的请求。所述预设比例阈值可以是80%或60%等。在能正确转发的请求占预设数量的比例达到所述预设比例阈值时,判定所述服务实例能正确响应转发的请求。在本发明其他实施例中,也还可以是根据正确转发的请求的数量来判定所述服务实例能正确响应转发的请求。所述预设数量的请求不是一次性转发至服务实例,而是间隔或者持续的转发至服务实例,且计算的周期不限定,只要响应的请求达到条件(比例或数量)后,判定所述服务实例能正确响应转发的请求。Step S13, when the calculated ratio is greater than the preset ratio threshold, it is determined that the service instance can correctly respond to the forwarded request. The preset ratio threshold may be 80% or 60% or the like. When the ratio of the preset number of requests that can be correctly forwarded reaches the preset ratio threshold, it is determined that the service instance can correctly respond to the forwarded request. In other embodiments of the present invention, it may also be determined according to the number of correctly forwarded requests that the service instance can correctly respond to the forwarded requests. The preset number of requests is not forwarded to the service instance at one time, but is forwarded to the service instance at intervals or continuously, and the calculation period is not limited, as long as the response request meets the condition (proportion or quantity), the service is determined The instance correctly responds to forwarded requests.
步骤S30,在所述服务实例未响应转发的请求时,保持停止转发服务请求至所述服务实例上。在所述服务实例未响应转发的请求时,继续停止转发服务请求至所述服务实例上,直至测试成功后,才正常向服务实例转发请求,在间隔一定时间(5分钟或10分钟等)后,提示服务实例故障,需进行检修。本实施例通过对断开后的服务实例进行测试,在服务实例正确响应转发的请求后,快速的恢复转发服务请求至所述服务实例上,充分利用资源,提高业务体验。Step S30, when the service instance does not respond to the forwarded request, keep stopping forwarding the service request to the service instance. When the service instance does not respond to the forwarded request, continue to stop forwarding the service request to the service instance until the test is successful, then forward the request to the service instance normally, after a certain period of time (5 minutes or 10 minutes, etc.) , indicating that the service instance is faulty and needs to be repaired. In this embodiment, by testing the disconnected service instance, after the service instance correctly responds to the forwarded request, the service request is quickly resumed and forwarded to the service instance, making full use of resources and improving service experience.
进一步地,参考图3,本发明方法还包括:Further, referring to Fig. 3, the method of the present invention also includes:
步骤S40,获取服务实例在一个检测周期内的链接信息;Step S40, obtaining the link information of the service instance within a detection period;
在本实施例中,预设一个检测周期,该检测周期可以是50s或60s等,为了节省系统资源,所述检测周期可以是3分钟或5分钟,为了提高检测频率,及时发现问题,所述检测周期可以设置为20s或30s,客户端向服务器端发起业务请求,获取服务实例在一个检测周期内的链接信息,该链接信息包括链接成功信息和链接失败信息,所述链接失败信息包括链接超时和链接错误。在每触发检测时,获取服务实例在一个检测周期内的链接信息。每个检测周期间可以根据性能需求和业务需求进行时间间隔的设置,例如,为5分钟或8分钟等。每间隔该时间间隔进行一个周期的检测。In this embodiment, a detection cycle is preset, and the detection cycle can be 50s or 60s. In order to save system resources, the detection cycle can be 3 minutes or 5 minutes. In order to improve the detection frequency and find problems in time, the The detection period can be set to 20s or 30s. The client initiates a business request to the server to obtain the link information of the service instance within a test period. The link information includes link success information and link failure information. The link failure information includes link timeout and link errors. When detection is triggered every time, link information of service instance in a detection cycle is obtained. A time interval can be set according to performance requirements and business requirements during each detection cycle, for example, 5 minutes or 8 minutes. A period of detection is performed at this time interval.
步骤S50,判断所述链接信息是否满足预设的断开条件;Step S50, judging whether the link information satisfies a preset disconnection condition;
在获取到一个检测周期内的链接信息后,判断所述链接信息是否满足预设的断开条件。具体的,在本发明一较佳实施例中,参考图4,判断所述链接信息是否满足预设的断开条件的包括:After the link information within a detection period is acquired, it is judged whether the link information satisfies a preset disconnection condition. Specifically, in a preferred embodiment of the present invention, referring to FIG. 4, judging whether the link information satisfies a preset disconnection condition includes:
步骤S51,从所述连接信息中提取发生链接错误请求的数量;所述链接信息包括但不限于链接错误信息和链接超时以及链接成功等信息。在获取到链接信息后,从所述连接信息中提取发生链接错误请求的数量,即,提取有多少请求发生了链接错误,将所述链接错误的数量与预设的第一数量阈值比对,所述预设的第一数量阈值为提前设置,例如,为20条或200条,根据该检测周期内发起的业务请求数量设置,例如,请求数量为200条,则第一数量阈值设置为40条或50条,例如,请求数量为500条,则第一数量阈值设置为100或120条。Step S51, extracting the number of link error requests from the connection information; the link information includes but not limited to link error information, link timeout, link success and other information. After obtaining the link information, extract the number of requests with link errors from the connection information, that is, extract how many requests have link errors, compare the number of link errors with a preset first number threshold, The preset first quantity threshold is set in advance, for example, 20 or 200, and is set according to the quantity of service requests initiated within the detection period, for example, if the number of requests is 200, then the first quantity threshold is set to 40 or 50, for example, if the requested quantity is 500, then the first quantity threshold is set to 100 or 120.
步骤S52,在所述链接错误的数量大于预设的第一数量阈值时,判定所述链接信息满足预设的断开条件。该检测周期内链接错误的数量大于预设的第一数量阈值时,判定所述链接信息是否满足预设的断开条件。在本发明其他实施例中,也可以是计算链接错误所占的比例,在链接错误的比例达到预设比例值(20%或25%等)时,判定所述链接信息满足预设的断开条件。Step S52, when the number of link errors is greater than a preset first number threshold, it is determined that the link information satisfies a preset disconnection condition. When the number of link errors within the detection period is greater than a preset first number threshold, it is determined whether the link information satisfies a preset disconnection condition. In other embodiments of the present invention, it is also possible to calculate the proportion of link errors, and when the proportion of link errors reaches a preset proportion value (20% or 25%, etc.), it is determined that the link information meets the preset disconnection condition.
在本发明一较佳实施例中,参考图5,判断所述链接信息是否满足预设的断开条件的还可以是:In a preferred embodiment of the present invention, referring to FIG. 5, it is also possible to determine whether the link information meets the preset disconnection condition:
步骤S53,从所述链接信息中提取发生链接超时请求的数量;在获取到链接信息后,从所述连接信息中提取发生链接超时请求的数量,即,提取有多少请求发生了链接超时,将所述链接超时的数量与预设的第二数量阈值比对,所述预设的第二数量阈值为提前设置,例如,为30条或300条,根据该检测周期内发起的业务请求数量设置,例如,请求数量为200条,则第二数量阈值设置为60条或70条,例如,请求数量为400条,则第二数量阈值设置为120或140条。Step S53, extracting the number of link timeout requests from the link information; after obtaining the link information, extracting the number of link timeout requests from the connection information, that is, extracting how many requests have link timeouts, and The number of link timeouts is compared with a preset second number threshold, and the preset second number threshold is set in advance, for example, 30 or 300, set according to the number of service requests initiated within the detection period For example, if the number of requests is 200, then the second quantity threshold is set to 60 or 70; for example, if the number of requests is 400, then the second quantity threshold is set to 120 or 140.
步骤S54,在所述链接超时的数量大于预设的第二数量阈值时,判定所述链接信息满足预设的断开条件。该检测周期内链接超时的数量大于预设的第二数量阈值时,判定所述链接信息满足预设的断开条件。在本发明其他实施例中,也可以是计算链接错误所占的比例,在链接错误的比例达到预设比例值(20%或25%等)时,判定所述链接信息满足预设的断开条件。Step S54, when the number of link timeouts is greater than a preset second number threshold, it is determined that the link information satisfies a preset disconnection condition. When the number of link timeouts within the detection period is greater than a preset second number threshold, it is determined that the link information satisfies a preset disconnection condition. In other embodiments of the present invention, it is also possible to calculate the proportion of link errors, and when the proportion of link errors reaches a preset proportion value (20% or 25%, etc.), it is determined that the link information meets the preset disconnection condition.
在本发明其他实施例中,可以是将从链接信息中提取发生链接错误和链接超时的总数量,在总数量大于一个阈值(总请求为100条,阈值为60条;或总请求为300条,阈值为200条,根据需求和服务实例性能设置)时,判定所述链接信息满足预设的断开条件。同样也可以从比例考虑,在比例超过25%或30%甚至20%时,判定所述链接信息满足预设的断开条件。在断开判断过程中,本实施例采用的算法为,每次请求对应的时间点(Ticker)设置为1,在计算单位时间内的counter计数的话,如图6,想计算某个时间段的计数,只需要当前时间和前面时间的Ticker,去掉不在这个Ticker范围的数据,做个计数即可,这样的计算没有任何锁,性能非常高,例如,运用在链接信息的计算和counter。In other embodiments of the present invention, the total number of link errors and link timeouts may be extracted from the link information, and when the total number is greater than a threshold (the total request is 100, the threshold is 60; or the total request is 300 , the threshold is 200, which is set according to the requirements and performance of the service instance), it is determined that the link information meets the preset disconnection condition. Likewise, the ratio can also be considered, and when the ratio exceeds 25% or 30% or even 20%, it is determined that the link information satisfies the preset disconnection condition. In the disconnection judgment process, the algorithm adopted in this embodiment is that the time point (Ticker) corresponding to each request is set to 1, and if the counter counts in the calculation unit time, as shown in Figure 6, if you want to calculate the ticker for a certain period of time For counting, you only need the ticker of the current time and the previous time, remove the data that is not in the range of this ticker, and do a count. This kind of calculation does not have any locks, and the performance is very high. For example, it is used in the calculation and counter of link information.
步骤S60,在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。Step S60, stop forwarding the service request to the service instance after the link information satisfies the preset disconnection condition.
在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上,即,断开所述服务实例,所述服务实例不再接收服务转发。本实施例通过对服务实例的链接信息进行监控,根据所述链接信息判断是否满足预设的断开条件,在满足时,断开该服务实例,停止转发服务请求至所述服务实例上。通过对服务实例及时进行断开,避免目前客户端与服务端的连接建立因无法及时解决服务实例响应慢,导致业务请求响应不及时,使得业务体验差的问题,使得业务请求及时响应,提高业务体验。After the link information satisfies the preset disconnection condition, stop forwarding the service request to the service instance, that is, disconnect the service instance, and the service instance no longer receives service forwarding. In this embodiment, by monitoring the link information of the service instance, it is judged whether the preset disconnection condition is satisfied according to the link information, and when it is satisfied, the service instance is disconnected, and the forwarding of the service request to the service instance is stopped. By disconnecting the service instance in time, avoid the problem that the current connection between the client and the server cannot be solved in time due to the slow response of the service instance, resulting in untimely response to business requests, resulting in poor business experience, making timely response to business requests, and improving business experience. .
为了保证服务请求得到及时响应,且避免资源的浪费,在本发明一较佳实施例中,参考图7,所述方法还包括:In order to ensure a timely response to service requests and avoid waste of resources, in a preferred embodiment of the present invention, referring to FIG. 7, the method further includes:
步骤S70,确定所述服务实例在一个检测周期内触发的请求转发次数;在进入检测周期时,确定所述服务实例在这个检测周期内触发的请求次数,该触发的请求包括失败和成功的请求,即,所有转发至所述服务实例的请求。Step S70, determine the number of request forwardings triggered by the service instance within a detection cycle; when entering the detection cycle, determine the number of requests triggered by the service instance within this detection cycle, the triggered requests include failed and successful requests , that is, all requests forwarded to the service instance.
步骤S80,在所触发的转发次数小于预设转发次数阈值时,进入下一检测周期请求转发次数的确定;所述预设转发次数阈值根据服务实例性能和用户需求设置,例如,可以是200条或2000条等。在确定触发的请求转发次数后,将所触发的转发次数小于预设转发次数阈值比对。Step S80, when the triggered number of forwarding times is less than the preset forwarding times threshold, enter the next detection cycle to request the determination of the forwarding times; the preset forwarding times threshold is set according to the service instance performance and user requirements, for example, it can be 200 or 2000 pieces etc. After determining the triggered forwarding times of the request, it is compared that the triggered forwarding times are smaller than the preset forwarding times threshold.
步骤S40,在所触发的转发次数大于或等于预设转发次数阈值时,获取服务实例在一个检测周期内的链接信息;Step S40, when the triggered forwarding times is greater than or equal to the preset forwarding times threshold, obtain the link information of the service instance within one detection period;
步骤S50,判断所述链接信息是否满足预设的断开条件;Step S50, judging whether the link information satisfies a preset disconnection condition;
步骤S60,在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。在所触发的转发次数大于或等于预设转发次数阈值时,才获取服务实例在一个检测周期内的链接信息;在所触发的转发次数小于预设转发次数阈值时,不执行获取服务实例在一个检测周期内的链接信息。在本发明一实施例中,预设一时间,例如,为1分钟或30s等,在该时间内,判断触发该服务实例的请求次数是否达到一定值,例如,为200或300条,在达到时,进入检测周期,获取服务实例在一个检测周期内的链接信息。优选地,设定检测的服务类别,只对该服务类别的链接信息进行监控和记录,而对该设定的服务类别之外的其他类别不计入检测周期内的链接信息。Step S60, stop forwarding the service request to the service instance after the link information satisfies the preset disconnection condition. When the triggered forwarding times are greater than or equal to the preset forwarding times threshold, the connection information of the service instance in a detection cycle is obtained; when the triggered forwarding times are less than the preset forwarding times threshold, the service instance is not obtained Link information during detection cycle. In one embodiment of the present invention, a time is preset, for example, 1 minute or 30s, etc., and within this time, it is judged whether the number of requests triggering the service instance reaches a certain value, for example, 200 or 300. , enter the detection cycle, and obtain the connection information of the service instance in a detection cycle. Preferably, the detected service category is set, and only the link information of the service category is monitored and recorded, while other categories other than the set service category are not included in the link information within the detection period.
为了更好的描述本发明实施例,参考图8,为客户端与服务端业务请求架构,在检测周期内,如果服务实例的链接错误或者服务实例超时达到预定的阀值,则OSP Proxy(OSP代理)将触发熔断机制,后续OSP Proxy特定时间内将不在转发请求到该服务实例将上OSPProxy在服务熔断后,每隔一定的恢复时长后,OSP Proxy将允许小量的请求访问被熔断的服务。如果服务实例又正确响应,则OSP Proxy恢复服务的正常访问,如果服务实例依然无法正确响应,则OSP Proxy再间隔特定的时间内不在转发请求到该服务实例将上。熔断机制控制在服务的访问接口上;熔断机制默认是关闭的,如需使用则必须在配置中心配置相关的参数,这些参数都是可以动态改变,OSP Proxy无需重启;配置中心的配置参数是基于服务级别,多个服务实例共享,多个接口共享;OSP Proxy需要上报针对服务实例的熔断状态,Mercury路由可以在查看服务的时候获知相关的OSP Proxy的熔断情况In order to better describe the embodiment of the present invention, refer to FIG. 8, which is the client and server service request architecture. During the detection period, if the connection error of the service instance or the timeout of the service instance reaches a predetermined threshold, the OSP Proxy (OSP Proxy) will trigger the fusing mechanism, and subsequent OSP Proxy will not forward requests to the service instance within a certain period of time. After the service fusing, OSP Proxy will allow a small amount of requests to access the fusing service after a certain recovery period. . If the service instance responds correctly again, the OSP Proxy resumes the normal access of the service. If the service instance still cannot respond correctly, the OSP Proxy will not forward the request to the service instance within a specific time interval. The fuse mechanism is controlled on the access interface of the service; the fuse mechanism is disabled by default, and if it needs to be used, you must configure relevant parameters in the configuration center. These parameters can be changed dynamically, and OSP Proxy does not need to be restarted; the configuration parameters of the configuration center are based on Service level, shared by multiple service instances, shared by multiple interfaces; OSP Proxy needs to report the fusing status of the service instance, and Mercury routing can know the fusing status of the relevant OSP Proxy when viewing the service
若从Available Instances可用服务实例选择的instance服务实例错误率达到熔断的策略,则把该Instance移到CircuitBreak Instances熔断实例里面;系统后端对每个CircuitBreak Instance都有一个Scheduler调度程序触发把它移到Half-Open Instance半断开实例里面;若Half-Open状态的Instance成功调用,则放回Available Instance里面。在Half-Open状态的Service Instances处理过程中,需要考虑并发问题,比如并发调用的时候,一个调用成功,一个调用失败。具体的,参考图9,当ServiceB服务器B的instance3服务实例3发生较大错误率,达到熔断需要,则把instance3熔断,不影响Client客户端的调用。在熔断了Instance3后,由于ServiceB只剩下Instance1服务实例1,Instance2服务实例2,则压力会增加,此时需要进行告警,以免发生雪崩效应;若以后引入Docker应用引擎容器化后,可以动态的增加Instace4服务实例4来缓解压力,同时隔离Instance3以便查问题。If the error rate of the instance service instance selected from Available Instances reaches the fuse policy, then move the Instance to the CircuitBreak Instances fuse instance; the system backend has a Scheduler scheduler for each CircuitBreak Instance to trigger it to be moved to In the Half-Open Instance half-disconnected instance; if the Instance in the Half-Open state is successfully called, it will be placed back in the Available Instance. During the processing of Service Instances in the Half-Open state, concurrency issues need to be considered. For example, when calling concurrently, one call succeeds and one call fails. Specifically, referring to Figure 9, when the instance3 service instance 3 of the ServiceB server B has a large error rate and meets the need for fusing, then instance3 will be fusing without affecting the invocation of the Client. After Instance3 is fused, because ServiceB only has Instance1 serving Instance 1 and Instance2 serving Instance 2, the pressure will increase. At this time, an alarm needs to be issued to avoid an avalanche effect; if the Docker application engine is introduced in the future, it can be dynamically Add Instace4 service instance 4 to relieve the pressure, and isolate Instance3 to check the problem.
本发明进一步提供一种服务器的连接控制装置。The present invention further provides a server connection control device.
参照图10,图10为本发明服务器的连接控制装置的第一实施例的功能模块示意图。Referring to FIG. 10 , FIG. 10 is a schematic diagram of functional modules of a first embodiment of a connection control device for a server according to the present invention.
在一实施例中,所述服务器的连接控制装置包括:控制模块10、恢复模块20、确定模块30、计算模块40和判断模块50。In an embodiment, the connection control device of the server includes: a control module 10 , a recovery module 20 , a determination module 30 , a calculation module 40 and a judgment module 50 .
所述控制模块10,用于在停止转发服务请求至服务实例后,将预设数量的请求访问转发至所述服务实例上;在服务实例满足断开条件断开后,需要对该服务实例的断开状态实时监控,以尽快利用该服务实例进行业务服务。所述设定时间可以是2分钟或3分钟等。在间隔设定时间后,将预设数量的请求访问转发至所述服务实例上,即,将少量的请求访问转发至所述服务实例上用以测试该服务实例是否正常,能够及时响应服务请求。所述预设数量为80条或50条等,根据服务实例的性能设置。The control module 10 is configured to forward a preset number of request visits to the service instance after stopping forwarding the service request to the service instance; The disconnection status is monitored in real time, so that the service instance can be used for business services as soon as possible. The set time can be 2 minutes or 3 minutes, etc. After the interval is set, forward a preset number of request visits to the service instance, that is, forward a small number of request visits to the service instance to test whether the service instance is normal and can respond to service requests in a timely manner . The preset number is 80 or 50, etc., which are set according to the performance of the service instance.
所述恢复模块20,用于在所述服务实例正确响应转发的请求时,恢复转发服务请求至所述服务实例上;在所述服务实例正确响应转发的请求时,正常向所述服务实例转发服务请求,恢复所述服务实例的使用。The restoration module 20 is configured to restore and forward the service request to the service instance when the service instance correctly responds to the forwarded request; and normally forward the service request to the service instance when the service instance correctly responds to the forwarded request A service request to resume usage of the service instance.
所述确定模块30,用于确定响应的请求的数量;在将预设数量的请求转发至该服务实例上后,监测正确转发的请求的数量,即,确定响应的请求的数量。The determining module 30 is configured to determine the number of requests to respond to; after forwarding the preset number of requests to the service instance, monitor the number of correctly forwarded requests, that is, to determine the number of requests to respond to.
所述计算模块40,用于计算确定的数量在预设数量中所占的比例;计算正确转发的请求的数量和占比。The calculation module 40 is used to calculate the proportion of the determined quantity in the preset quantity; calculate the quantity and proportion of correctly forwarded requests.
所述判断模块50,用于在计算的比例大于预设比例阈值时,判定所述服务实例能正确响应转发的请求。所述预设比例阈值可以是80%或60%等。在能正确转发的请求占预设数量的比例达到所述预设比例阈值时,判定所述服务实例能正确响应转发的请求。在本发明其他实施例中,也还可以是根据正确转发的请求的数量来判定所述服务实例能正确响应转发的请求。所述预设数量的请求不是一次性转发至服务实例,而是间隔或者持续的转发至服务实例,且计算的周期不限定,只要响应的请求达到条件(比例或数量)后,判定所述服务实例能正确响应转发的请求。The judging module 50 is configured to judge that the service instance can correctly respond to the forwarded request when the calculated ratio is greater than a preset ratio threshold. The preset ratio threshold may be 80% or 60% or the like. When the ratio of the preset number of requests that can be correctly forwarded reaches the preset ratio threshold, it is determined that the service instance can correctly respond to the forwarded request. In other embodiments of the present invention, it may also be determined according to the number of correctly forwarded requests that the service instance can correctly respond to the forwarded requests. The preset number of requests is not forwarded to the service instance at one time, but is forwarded to the service instance at intervals or continuously, and the calculation period is not limited, as long as the response request meets the condition (proportion or quantity), the service is determined The instance correctly responds to forwarded requests.
所述控制模块10,还用于在所述服务实例未响应转发的请求时,保持停止转发服务请求至所述服务实例上。在所述服务实例未响应转发的请求时,继续停止转发服务请求至所述服务实例上,直至测试成功后,才正常向服务实例转发请求,在间隔一定时间(5分钟或10分钟等)后,提示服务实例故障,需进行检修。本实施例通过对断开后的服务实例进行测试,在服务实例正确响应转发的请求后,快速的恢复转发服务请求至所述服务实例上,充分利用资源,提高业务体验。The control module 10 is further configured to stop forwarding the service request to the service instance when the service instance does not respond to the forwarded request. When the service instance does not respond to the forwarded request, continue to stop forwarding the service request to the service instance until the test is successful, then forward the request to the service instance normally, after a certain period of time (5 minutes or 10 minutes, etc.) , indicating that the service instance is faulty and needs to be repaired. In this embodiment, by testing the disconnected service instance, after the service instance correctly responds to the forwarded request, the service request is quickly resumed and forwarded to the service instance, making full use of resources and improving service experience.
参考图11,所述装置还包括:获取模块60,Referring to FIG. 11, the device further includes: an acquisition module 60,
所述获取模块60,用于获取服务实例在一个检测周期内的链接信息;The acquiring module 60 is configured to acquire link information of a service instance within a detection period;
在本实施例中,预设一个检测周期,该检测周期可以是50s或60s等,为了节省系统资源,所述检测周期可以是3分钟或5分钟,为了提高检测频率,及时发现问题,所述检测周期可以设置为20s或30s,客户端向服务器端发起业务请求,获取服务实例在一个检测周期内的链接信息,该链接信息包括链接成功信息和链接失败信息,所述链接失败信息包括链接超时和链接错误。在每触发检测时,获取服务实例在一个检测周期内的链接信息。每个检测周期间可以根据性能需求和业务需求进行时间间隔的设置,例如,为5分钟或8分钟等。每间隔该时间间隔进行一个周期的检测。In this embodiment, a detection cycle is preset, and the detection cycle can be 50s or 60s. In order to save system resources, the detection cycle can be 3 minutes or 5 minutes. In order to improve the detection frequency and find problems in time, the The detection period can be set to 20s or 30s. The client initiates a business request to the server to obtain the link information of the service instance within a test period. The link information includes link success information and link failure information. The link failure information includes link timeout and link errors. When detection is triggered every time, link information of service instance in a detection cycle is obtained. A time interval can be set according to performance requirements and business requirements during each detection cycle, for example, 5 minutes or 8 minutes. A period of detection is performed at this time interval.
所述判断模块50,用于判断所述链接信息是否满足预设的断开条件;The judging module 50 is configured to judge whether the link information satisfies a preset disconnection condition;
在获取到一个检测周期内的链接信息后,判断所述链接信息是否满足预设的断开条件。具体的,在本发明一较佳实施例中,参考图12,所述判断模块50包括:判断单元51和判定单元52,After the link information within a detection period is acquired, it is judged whether the link information satisfies a preset disconnection condition. Specifically, in a preferred embodiment of the present invention, referring to FIG. 12 , the judging module 50 includes: a judging unit 51 and a judging unit 52,
所述判断单元51,用于从所述连接信息中提取发生链接错误请求的数量;所述链接信息包括但不限于链接错误信息和链接超时以及链接成功等信息。在获取到链接信息后,从所述连接信息中提取发生链接错误请求的数量,即,提取有多少请求发生了链接错误,将所述链接错误的数量与预设的第一数量阈值比对,所述预设的第一数量阈值为提前设置,例如,为20条或200条,根据该检测周期内发起的业务请求数量设置,例如,请求数量为200条,则第一数量阈值设置为40条或50条,例如,请求数量为500条,则第一数量阈值设置为100或120条。The judging unit 51 is configured to extract the number of link error requests from the connection information; the link information includes but not limited to link error information, link timeout, link success and other information. After obtaining the link information, extract the number of requests with link errors from the connection information, that is, extract how many requests have link errors, compare the number of link errors with a preset first number threshold, The preset first quantity threshold is set in advance, for example, 20 or 200, and is set according to the quantity of service requests initiated within the detection period, for example, if the number of requests is 200, then the first quantity threshold is set to 40 or 50, for example, if the requested quantity is 500, then the first quantity threshold is set to 100 or 120.
所述判定单元52,用于在所述链接错误的数量大于预设的第一数量阈值时,判定所述链接信息满足预设的断开条件。该检测周期内链接错误的数量大于预设的第一数量阈值时,判定所述链接信息是否满足预设的断开条件。在本发明其他实施例中,也可以是计算链接错误所占的比例,在链接错误的比例达到预设比例值(20%或25%等)时,判定所述链接信息满足预设的断开条件。The determining unit 52 is configured to determine that the link information satisfies a preset disconnection condition when the number of link errors is greater than a preset first number threshold. When the number of link errors within the detection period is greater than a preset first number threshold, it is determined whether the link information satisfies a preset disconnection condition. In other embodiments of the present invention, it is also possible to calculate the proportion of link errors, and when the proportion of link errors reaches a preset proportion value (20% or 25%, etc.), it is determined that the link information meets the preset disconnection condition.
进一步地,所述判断单元51,还用于从所述链接信息中提取发生链接超时请求的数量;在获取到链接信息后,从所述连接信息中提取发生链接超时请求的数量,即,提取有多少请求发生了链接超时,将所述链接超时的数量与预设的第二数量阈值比对,所述预设的第二数量阈值为提前设置,例如,为30条或300条,根据该检测周期内发起的业务请求数量设置,例如,请求数量为200条,则第二数量阈值设置为60条或70条,例如,请求数量为400条,则第二数量阈值设置为120或140条。Further, the judging unit 51 is further configured to extract the number of link timeout requests from the link information; after obtaining the link information, extract the number of link timeout requests from the connection information, that is, extract How many requests have link timeouts, and compare the number of link timeouts with a preset second number threshold, the preset second number threshold is set in advance, for example, 30 or 300, according to the Set the number of business requests initiated during the detection period. For example, if the number of requests is 200, the second number threshold is set to 60 or 70. For example, if the number of requests is 400, the second number threshold is set to 120 or 140. .
所述判定单元52,还用于在所述链接超时的数量大于预设的第二数量阈值时,判定所述链接信息满足预设的断开条件。该检测周期内链接超时的数量大于预设的第二数量阈值时,判定所述链接信息满足预设的断开条件。在本发明其他实施例中,也可以是计算链接错误所占的比例,在链接错误的比例达到预设比例值(20%或25%等)时,判定所述链接信息满足预设的断开条件。The determining unit 52 is further configured to determine that the link information satisfies a preset disconnection condition when the number of link timeouts is greater than a preset second number threshold. When the number of link timeouts within the detection period is greater than a preset second number threshold, it is determined that the link information satisfies a preset disconnection condition. In other embodiments of the present invention, it is also possible to calculate the proportion of link errors, and when the proportion of link errors reaches a preset proportion value (20% or 25%, etc.), it is determined that the link information meets the preset disconnection condition.
在本发明其他实施例中,可以是将从链接信息中提取发生链接错误和链接超时的总数量,在总数量大于一个阈值(总请求为100条,阈值为60条;或总请求为300条,阈值为200条,根据需求和服务实例性能设置)时,判定所述链接信息满足预设的断开条件。同样也可以从比例考虑,在比例超过25%或30%甚至20%时,判定所述链接信息满足预设的断开条件。在断开判断过程中,本实施例采用的算法为,每次请求对应的时间点(Ticker)设置为1,在计算单位时间内的counter计数的话,如图6,想计算某个时间段的计数,只需要当前时间和前面时间的Ticker,去掉不在这个Ticker范围的数据,做个计数即可,这样的计算没有任何锁,性能非常高,例如,运用在链接信息的计算和counter。In other embodiments of the present invention, the total number of link errors and link timeouts may be extracted from the link information, and when the total number is greater than a threshold (the total request is 100, the threshold is 60; or the total request is 300 , the threshold is 200, which is set according to the requirements and performance of the service instance), it is determined that the link information meets the preset disconnection condition. Likewise, the ratio can also be considered, and when the ratio exceeds 25% or 30% or even 20%, it is determined that the link information satisfies the preset disconnection condition. In the disconnection judgment process, the algorithm adopted in this embodiment is that the time point (Ticker) corresponding to each request is set to 1, and if the counter counts in the calculation unit time, as shown in Figure 6, if you want to calculate the ticker for a certain period of time For counting, you only need the ticker of the current time and the previous time, remove the data that is not in the range of this ticker, and do a count. This kind of calculation does not have any locks, and the performance is very high. For example, it is used in the calculation and counter of link information.
所述控制模块20,还用于在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。The control module 20 is further configured to stop forwarding the service request to the service instance after the link information satisfies a preset disconnection condition.
在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上,即,断开所述服务实例,所述服务实例不再接收服务转发。本实施例通过对服务实例的链接信息进行监控,根据所述链接信息判断是否满足预设的断开条件,在满足时,断开该服务实例,停止转发服务请求至所述服务实例上。通过对服务实例及时进行断开,避免目前客户端与服务端的连接建立因无法及时解决服务实例响应慢,导致业务请求响应不及时,使得业务体验差的问题,使得业务请求及时响应,提高业务体验。After the link information satisfies the preset disconnection condition, stop forwarding the service request to the service instance, that is, disconnect the service instance, and the service instance no longer receives service forwarding. In this embodiment, by monitoring the link information of the service instance, it is judged whether the preset disconnection condition is satisfied according to the link information, and when it is satisfied, the service instance is disconnected, and the forwarding of the service request to the service instance is stopped. By disconnecting the service instance in time, avoid the problem that the current connection between the client and the server cannot be solved in time due to the slow response of the service instance, resulting in untimely response to business requests, resulting in poor business experience, making timely response to business requests, and improving business experience. .
为了保证服务请求得到及时响应,且避免资源的浪费,在本发明一较佳实施例中,In order to ensure timely response to service requests and avoid waste of resources, in a preferred embodiment of the present invention,
所述确定模块30,还用于确定所述服务实例在一个检测周期内触发的请求转发次数;在进入检测周期时,确定所述服务实例在这个检测周期内触发的请求次数,该触发的请求包括失败和成功的请求,即,所有转发至所述服务实例的请求。The determination module 30 is also used to determine the number of request forwardings triggered by the service instance within a detection cycle; when entering the detection cycle, determine the number of requests triggered by the service instance within this detection cycle, the triggered request Includes failed and successful requests, ie all requests forwarded to the service instance.
所述确定模块30,还用于在所触发的转发次数小于预设转发次数阈值时,进入下一检测周期请求转发次数的确定;所述预设转发次数阈值根据服务实例性能和用户需求设置,例如,可以是200条或2000条等。在确定触发的请求转发次数后,将所触发的转发次数小于预设转发次数阈值比对。The determining module 30 is further configured to enter the next detection cycle to request the determination of the forwarding times when the triggered forwarding times is less than the preset forwarding times threshold; the preset forwarding times threshold is set according to service instance performance and user requirements, For example, it may be 200 or 2000. After determining the triggered forwarding times of the request, it is compared that the triggered forwarding times are smaller than the preset forwarding times threshold.
获取模块60在所触发的转发次数大于或等于预设转发次数阈值时,获取服务实例在一个检测周期内的链接信息;判断模块50判断所述链接信息是否满足预设的断开条件;控制模块20在所述链接信息满足预设的断开条件后,停止转发服务请求至所述服务实例上。在所触发的转发次数大于或等于预设转发次数阈值时,才获取服务实例在一个检测周期内的链接信息;在所触发的转发次数小于预设转发次数阈值时,不执行获取服务实例在一个检测周期内的链接信息。在本发明一实施例中,预设一时间,例如,为1分钟或30s等,在该时间内,判断触发该服务实例的请求次数是否达到一定值,例如,为200或300条,在达到时,进入检测周期,获取服务实例在一个检测周期内的链接信息。优选地,设定检测的服务类别,只对该服务类别的链接信息进行监控和记录,而对该设定的服务类别之外的其他类别不计入检测周期内的链接信息。The obtaining module 60 obtains the link information of the service instance within a detection period when the triggered forwarding times is greater than or equal to the preset forwarding times threshold; the judging module 50 judges whether the link information meets the preset disconnection conditions; the control module 20 After the link information satisfies a preset disconnection condition, stop forwarding the service request to the service instance. When the triggered forwarding times are greater than or equal to the preset forwarding times threshold, the connection information of the service instance in a detection cycle is obtained; when the triggered forwarding times are less than the preset forwarding times threshold, the service instance is not obtained Link information during detection cycle. In one embodiment of the present invention, a time is preset, for example, 1 minute or 30s, etc., and within this time, it is judged whether the number of requests triggering the service instance reaches a certain value, for example, 200 or 300. , enter the detection cycle, and obtain the connection information of the service instance in a detection cycle. Preferably, the detected service category is set, and only the link information of the service category is monitored and recorded, while other categories other than the set service category are not included in the link information within the detection period.
为了更好的描述本发明实施例,参考图8,为客户端与服务端业务请求架构,在检测周期内,如果服务实例的链接错误或者服务实例超时达到预定的阀值,则OSP Proxy(OSP代理)将触发熔断机制,后续OSP Proxy特定时间内将不在转发请求到该服务实例将上OSPProxy在服务熔断后,每隔一定的恢复时长后,OSP Proxy将允许小量的请求访问被熔断的服务。如果服务实例又正确响应,则OSP Proxy恢复服务的正常访问,如果服务实例依然无法正确响应,则OSP Proxy再间隔特定的时间内不在转发请求到该服务实例将上。熔断机制控制在服务的访问接口上;熔断机制默认是关闭的,如需使用则必须在配置中心配置相关的参数,这些参数都是可以动态改变,OSP Proxy无需重启;配置中心的配置参数是基于服务级别,多个服务实例共享,多个接口共享;OSP Proxy需要上报针对服务实例的熔断状态,Mercury路由可以在查看服务的时候获知相关的OSP Proxy的熔断情况In order to better describe the embodiment of the present invention, refer to FIG. 8, which is the client and server service request architecture. During the detection period, if the connection error of the service instance or the timeout of the service instance reaches a predetermined threshold, the OSP Proxy (OSP Proxy) will trigger the fusing mechanism, and subsequent OSP Proxy will not forward requests to the service instance within a certain period of time. After the service fusing, OSP Proxy will allow a small amount of requests to access the fusing service after a certain recovery period. . If the service instance responds correctly again, the OSP Proxy resumes the normal access of the service. If the service instance still cannot respond correctly, the OSP Proxy will not forward the request to the service instance within a specific time interval. The fuse mechanism is controlled on the access interface of the service; the fuse mechanism is disabled by default, and if it needs to be used, you must configure relevant parameters in the configuration center. These parameters can be changed dynamically, and OSP Proxy does not need to be restarted; the configuration parameters of the configuration center are based on Service level, shared by multiple service instances, shared by multiple interfaces; OSP Proxy needs to report the fusing status of the service instance, and Mercury routing can know the fusing status of the relevant OSP Proxy when viewing the service
若从Available Instances可用服务实例选择的instance服务实例错误率达到熔断的策略,则把该Instance移到CircuitBreak Instances熔断实例里面;系统后端对每个CircuitBreak Instance都有一个Scheduler调度程序触发把它移到Half-Open Instance半断开实例里面;若Half-Open状态的Instance成功调用,则放回Available Instance里面。在Half-Open状态的Service Instances处理过程中,需要考虑并发问题,比如并发调用的时候,一个调用成功,一个调用失败。具体的,参考图9,当ServiceB服务器B的instance3服务实例3发生较大错误率,达到熔断需要,则把instance3熔断,不影响Client客户端的调用。在熔断了Instance3后,由于ServiceB只剩下Instance1服务实例1,Instance2服务实例2,则压力会增加,此时需要进行告警,以免发生雪崩效应;若以后引入Docker应用引擎容器化后,可以动态的增加Instace4服务实例4来缓解压力,同时隔离Instance3以便查问题。If the error rate of the instance service instance selected from Available Instances reaches the fuse policy, then move the Instance to the CircuitBreak Instances fuse instance; the system backend has a Scheduler scheduler for each CircuitBreak Instance to trigger it to be moved to In the Half-Open Instance half-disconnected instance; if the Instance in the Half-Open state is successfully called, it will be placed back in the Available Instance. During the processing of Service Instances in the Half-Open state, concurrency issues need to be considered. For example, when calling concurrently, one call succeeds and one call fails. Specifically, referring to Figure 9, when the instance3 service instance 3 of the ServiceB server B has a large error rate and meets the need for fusing, then instance3 will be fusing without affecting the invocation of the Client. After Instance3 is fused, because ServiceB only has Instance1 serving Instance 1 and Instance2 serving Instance 2, the pressure will increase. At this time, an alarm needs to be issued to avoid an avalanche effect; if the Docker application engine is introduced in the future, it can be dynamically Add Instace4 service instance 4 to relieve the pressure, and isolate Instance3 to check the problem.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process conversion made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610786461.5A CN106412016A (en) | 2016-08-31 | 2016-08-31 | Connection control method and device for server |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610786461.5A CN106412016A (en) | 2016-08-31 | 2016-08-31 | Connection control method and device for server |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN106412016A true CN106412016A (en) | 2017-02-15 |
Family
ID=58002126
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201610786461.5A Pending CN106412016A (en) | 2016-08-31 | 2016-08-31 | Connection control method and device for server |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN106412016A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2018171287A1 (en) * | 2017-03-22 | 2018-09-27 | 武汉斗鱼网络科技有限公司 | Remote invoking method and remote invoking apparatus |
| CN109240765A (en) * | 2018-08-28 | 2019-01-18 | 中国联合网络通信集团有限公司 | Blowout method, device, equipment and the computer readable storage medium of Service Source |
| WO2021063109A1 (en) * | 2019-09-30 | 2021-04-08 | 中兴通讯股份有限公司 | Uplink authorization request control method, device, terminal and storage medium |
| CN116048829A (en) * | 2022-07-01 | 2023-05-02 | 荣耀终端有限公司 | Interface calling methods, devices and storage media |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101383734A (en) * | 2008-10-20 | 2009-03-11 | 华为技术有限公司 | A state detection method, system and device |
| CN102075380A (en) * | 2010-12-16 | 2011-05-25 | 中兴通讯股份有限公司 | Method and device for detecting server state |
| CN102801581A (en) * | 2012-07-16 | 2012-11-28 | 重庆大学 | Method for predicting WEB service connection success rate |
| CN102930346A (en) * | 2012-10-15 | 2013-02-13 | 夏云霓 | MTTF (Mean time to failure) forecasting method of SOA (Service Oriented Architecture) service |
| CN103283180A (en) * | 2011-12-02 | 2013-09-04 | 华为技术有限公司 | A fault detection method, gateway, user equipment and communication system |
-
2016
- 2016-08-31 CN CN201610786461.5A patent/CN106412016A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101383734A (en) * | 2008-10-20 | 2009-03-11 | 华为技术有限公司 | A state detection method, system and device |
| CN102075380A (en) * | 2010-12-16 | 2011-05-25 | 中兴通讯股份有限公司 | Method and device for detecting server state |
| CN103283180A (en) * | 2011-12-02 | 2013-09-04 | 华为技术有限公司 | A fault detection method, gateway, user equipment and communication system |
| CN102801581A (en) * | 2012-07-16 | 2012-11-28 | 重庆大学 | Method for predicting WEB service connection success rate |
| CN102930346A (en) * | 2012-10-15 | 2013-02-13 | 夏云霓 | MTTF (Mean time to failure) forecasting method of SOA (Service Oriented Architecture) service |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2018171287A1 (en) * | 2017-03-22 | 2018-09-27 | 武汉斗鱼网络科技有限公司 | Remote invoking method and remote invoking apparatus |
| CN109240765A (en) * | 2018-08-28 | 2019-01-18 | 中国联合网络通信集团有限公司 | Blowout method, device, equipment and the computer readable storage medium of Service Source |
| WO2021063109A1 (en) * | 2019-09-30 | 2021-04-08 | 中兴通讯股份有限公司 | Uplink authorization request control method, device, terminal and storage medium |
| CN116048829A (en) * | 2022-07-01 | 2023-05-02 | 荣耀终端有限公司 | Interface calling methods, devices and storage media |
| CN116048829B (en) * | 2022-07-01 | 2023-10-10 | 荣耀终端有限公司 | Interface calling methods, equipment and storage media |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106375150A (en) | Server disconnection control method and device | |
| Panda et al. | {IASO}: A {Fail-Slow} Detection and Mitigation Framework for Distributed Storage Services | |
| CN105187249B (en) | A kind of fault recovery method and device | |
| CN108173911B (en) | Microservice fault detection and processing method and device | |
| CN101800675B (en) | Failure monitoring method, monitoring equipment and communication system | |
| CN104506392B (en) | A kind of delay machine detection method and equipment | |
| CN106533805B (en) | Micro-service request processing method, micro-service controller and micro-service architecture | |
| CN110162424B (en) | Fault processing method, system, device and storage medium | |
| JP2011154483A (en) | Failure detection device, program, and failure detection method | |
| CN107659431A (en) | Interface processing method, apparatus, storage medium and processor | |
| Sotoma et al. | Adaptation-algorithms to adaptive fault monitoring and their implementation on CORBA | |
| CN109218407B (en) | Code control method and terminal device based on log monitoring technology | |
| CN106412016A (en) | Connection control method and device for server | |
| CN104618161A (en) | Application cluster monitoring device and method | |
| CN103731315A (en) | Server failure detecting method | |
| WO2023083079A1 (en) | System, method and apparatus for monitoring third-party system, and device and storage medium | |
| CN106911519A (en) | A kind of data acquisition monitoring method and device | |
| CN108964947B (en) | Background service quality detection method and device and computer equipment | |
| CN100359865C (en) | a detection method | |
| CN106982141A (en) | Weblogic examples monitoring method and device | |
| CN113238893B (en) | Disaster recovery system, method, computer equipment and medium for multiple data centers | |
| CN107612755A (en) | The management method and its device of a kind of cloud resource | |
| CN107896176A (en) | A kind of processing method of calculate node, intelligent terminal and storage medium | |
| CN118733316A (en) | SOA adaptive fusing method, system and terminal | |
| CN113920698B (en) | An early warning method, device, equipment and medium for interface abnormal call |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| TA01 | Transfer of patent application right |
Effective date of registration: 20171207 Address after: 510000 Guangzhou City, Guangzhou, Guangdong, Fangcun Avenue, one of the 314 self compiled Applicant after: Guangzhou Pinwei Software Co., Ltd. Address before: Liwan District Fangcun Huahai street Guangzhou city Guangdong province 510000 No. 20 self 1-5 building (only for office use) Applicant before: Guangzhou VIPSHOP Information and Technology Co., Ltd. |
|
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170215 |