CN115134400A - Method and device for dynamically adjusting long connection number - Google Patents

Method and device for dynamically adjusting long connection number Download PDF

Info

Publication number
CN115134400A
CN115134400A CN202210750089.8A CN202210750089A CN115134400A CN 115134400 A CN115134400 A CN 115134400A CN 202210750089 A CN202210750089 A CN 202210750089A CN 115134400 A CN115134400 A CN 115134400A
Authority
CN
China
Prior art keywords
connections
long
long connections
started
connection
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.)
Granted
Application number
CN202210750089.8A
Other languages
Chinese (zh)
Other versions
CN115134400B (en
Inventor
何春芳
梁锦华
朱小珍
张榕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210750089.8A priority Critical patent/CN115134400B/en
Publication of CN115134400A publication Critical patent/CN115134400A/en
Application granted granted Critical
Publication of CN115134400B publication Critical patent/CN115134400B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application provides a method and a device for dynamically adjusting a long connection number, which relate to the technical field of computer communication and can be used in the financial field, wherein the method comprises the following steps: acquiring a configuration long connection number according to the connection calling signal; reading a host memory table to obtain the started long connection number, and comparing the started long connection number with the configuration long connection number; in response to the started number of long connections being less than the configured number of long connections, starting a number of new long connections so that the started number of long connections equals the configured number of long connections; in response to the number of enabled long connections being greater than the number of configured long connections, the number of enabled long connections is stopped such that the number of enabled long connections equals the number of configured long connections. The method and the device can adjust the long connection number of the host according to the traffic dynamics, the assembly table does not need to be modified in the adjustment process, the middleware system of the host does not need to be restarted, and the adjustment of the long connection number of the communication can be completed on the premise of not influencing the service continuity. When the service is abnormal, the emergency efficiency can be improved, and the influence on the service during the abnormal period can be reduced.

Description

动态调整长连接数的方法和装置Method and device for dynamically adjusting the number of long connections

技术领域technical field

本申请涉及计算机通信技术领域,可用于金融领域,尤其涉及一种动态调整长连接数的方法和装置。The present application relates to the field of computer communication technologies, which can be used in the financial field, and in particular, to a method and device for dynamically adjusting the number of long connections.

背景技术Background technique

为了提高主机与平台服务器通讯效率,减少主机消耗,主机与平台服务器之间一般采用长连接进行通讯。“长连接”是指客户端与服务端之间只需建立一次连接后,即可进行多次通讯的连接。相对短连接(一次连接只做一次通讯)来说,使用长连接能有效减少主机与其它平台建立连接的时间和次数,节省资源开销,提升通讯效率,但同时也会增加主机的运维成本。In order to improve the communication efficiency between the host and the platform server and reduce the consumption of the host, a long connection is generally used for communication between the host and the platform server. "Long connection" refers to a connection that can be used for multiple communications after only one connection is established between the client and the server. Compared with short connections (only one communication per connection), using long connections can effectively reduce the time and number of connections between the host and other platforms, save resource overhead, and improve communication efficiency, but it will also increase the operation and maintenance costs of the host.

主机作为客户端,其业务交易会同时启动多个通讯长连接进程来和平台服务器进行通讯连接。建立连接后,该业务交易会通过应用程序调用通讯接口来实现与平台服务器之间的通讯。The host as a client, its business transaction will start multiple communication long connection processes at the same time to communicate with the platform server. After the connection is established, the business transaction will communicate with the platform server through the application calling the communication interface.

主机通讯长连接数是提前预设到主机汇编表中的,在主机中间件系统启动时,系统会自动将汇编表预设值加载到内存表中,并按照内存表中的值启动相应数量的长连接,后续在主机中间件系统正常运行过程中,总的长连接数不会发生变化。The number of long host communication connections is preset in the host assembly table in advance. When the host middleware system starts, the system will automatically load the preset value of the assembly table into the memory table, and start the corresponding number according to the value in the memory table. For long connections, the total number of long connections will not change during the normal operation of the host middleware system.

在主机中间件系统中,启动一个长连接就是启动一个长交易,每个交易都会占用一定的系统资源,因此在实际应用中,需要根据业务量合理评估长连接数。当业务量急速增长时,通讯长连接数也需要响应调整,以支撑业务量的增长。按照现有的技术方案,修改长连接数需要修改汇编表后,重新启动主机中间件系统才能生效,在重启期间无法对外提供服务,因而会影响业务交易的连续性。In the host middleware system, starting a long connection is to start a long transaction, and each transaction will occupy a certain amount of system resources. Therefore, in practical applications, it is necessary to reasonably evaluate the number of long connections according to the business volume. When the business volume grows rapidly, the number of long communication connections also needs to be adjusted to support the growth of the business volume. According to the existing technical solution, modifying the number of long connections needs to modify the assembly table and then restart the host middleware system to take effect. During the restart, external services cannot be provided, thus affecting the continuity of business transactions.

发明内容SUMMARY OF THE INVENTION

有鉴于此,本发明提供一种动态调整长连接数的方法和装置,以解决上述提及的至少一个问题。In view of this, the present invention provides a method and apparatus for dynamically adjusting the number of long connections to solve at least one of the problems mentioned above.

为了实现上述目的,本发明采用了以下方案:In order to achieve the above object, the present invention adopts the following scheme:

根据本发明的第一方面,提供一种动态调整长连接数的方法,所述方法包括:根据连接调用信号获取配置长连接数;读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数;响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数;响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。According to a first aspect of the present invention, there is provided a method for dynamically adjusting the number of long connections, the method comprising: obtaining the number of configured long connections according to a connection call signal; reading the host memory table to obtain the number of started long connections, and comparing all the number of the started long connections and the configured number of long connections; in response to the number of the started long connections being less than the configured number of long connections, start several new long connections so that the number of started long connections is equal to the number of the configured long connections; In response to the number of activated persistent connections being greater than the configured number of persistent connections, a number of activated persistent connections are stopped so that the number of activated persistent connections is equal to the configured number of persistent connections.

根据本发明的第二方面,提供一种动态调整长连接数的装置,所述装置包括:配置获取单元,用于根据连接调用信号获取配置长连接数;内存读取单元,用于读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数;连接启动单元,用于响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数;连接停止单元,用于响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。According to a second aspect of the present invention, there is provided an apparatus for dynamically adjusting the number of long connections, the apparatus comprising: a configuration acquisition unit for acquiring the number of long connections configured according to a connection call signal; a memory reading unit for reading a host The memory table obtains the number of started long connections, and compares the number of started long connections with the number of configured long connections; the connection initiation unit is configured to respond that the number of started long connections is less than the number of configured long connections, Start a number of new long connections so that the number of started long connections is equal to the configured number of long connections; a connection stop unit is configured to stop several started long connections in response to the number of started long connections being greater than the configured number of long connections. The number of activated persistent connections is equal to the configured number of persistent connections.

根据本发明的第三方面,提供一种电子设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上所述动态调整长连接数的方法的步骤。According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the computer program to achieve The steps of the method for dynamically adjusting the number of long connections are described above.

根据本发明的第四方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上所述动态调整长连接数的方法的步骤。According to a fourth aspect of the present invention, there is provided a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the method for dynamically adjusting the number of persistent connections as described above.

根据本发明的第五方面,提供一种计算机程序产品,包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现如上所述动态调整长连接数的方法的步骤。According to a fifth aspect of the present invention, a computer program product is provided, comprising computer programs/instructions, when the computer program/instructions are executed by a processor, the steps of the above-mentioned method for dynamically adjusting the number of persistent connections are implemented.

如上所述,本申请可以根据业务量动态对主机长连接数进行调整,调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。As mentioned above, the present application can dynamically adjust the number of long-term connections of the host according to the traffic volume. The adjustment process does not need to modify the compilation table or restart the middleware system of the host. The number of long-term communication connections can be adjusted without affecting business continuity. Adjustment. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。在附图中:In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts. In the attached image:

图1是本申请实施例提供的一种动态调整长连接数的方法的流程示意图;1 is a schematic flowchart of a method for dynamically adjusting the number of long connections provided by an embodiment of the present application;

图2是本申请实施例提供的一种停止长连接的流程示意图;FIG. 2 is a schematic flow chart of stopping a long connection provided by an embodiment of the present application;

图3是本申请另一实施例提供的一种动态调整长连接数的方法的流程示意图;3 is a schematic flowchart of a method for dynamically adjusting the number of long connections provided by another embodiment of the present application;

图4是本申请实施例提供的一种动态调整长连接数的装置的结构示意图;4 is a schematic structural diagram of a device for dynamically adjusting the number of long connections provided by an embodiment of the present application;

图5是本申请另一实施例提供的电子设备的系统构成的示意框图。FIG. 5 is a schematic block diagram of a system configuration of an electronic device provided by another embodiment of the present application.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚明白,下面结合附图对本发明实施例做进一步详细说明。在此,本发明的示意性实施例及其说明用于解释本发明,但并不作为对本发明的限定。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention more clearly understood, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but not to limit the present invention.

需要说明的是,本申请公开的一种动态调整长连接数的方法和装置可用于金融领域,也可用于除金融领域之外的任意领域,本申请对公开的一种动态调整长连接数的方法和装置的应用领域不做限定。It should be noted that the method and device for dynamically adjusting the number of long connections disclosed in this application can be used in the financial field, and can also be used in any field except the financial field. The application field of the method and apparatus is not limited.

如图1所示为本申请实施例提供的一种动态调整长连接数的方法的流程示意图,本实施例是从主机侧对本申请进行的描述,该主机比如可以为智能手机、平板电子设备、网络机顶盒、便携式计算机、台式电脑、个人数字助理(PDA)、车载设备、智能穿戴设备等,该方法包括如下步骤:FIG. 1 is a schematic flowchart of a method for dynamically adjusting the number of long connections provided in an embodiment of the present application. This embodiment describes the present application from a host side, and the host may be, for example, a smart phone, a tablet electronic device, a A network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc., the method includes the following steps:

步骤S101:根据连接调用信号获取配置长连接数。Step S101: Acquire the number of configured long connections according to the connection invocation signal.

在本实施例中,配置长连接数是指根据业务量需求,需要在该主机中配置的长连接总数,其是根据业务需求动态进行调整的参数,具体来说,该参数可以由人工进行配置,也可以由软件自动进行调整配置,比如通过监控业务量由人工智能模型计算得到。该连接调用信号可以是由一定时器发出的,即每间隔一段时间对配置长连接数进行获取一次,当然本实施例中该连接调用信号也可以是程序监控业务量,当业务量发生突变时发出的,本实施例对此并不加以限定。In this embodiment, configuring the number of persistent connections refers to the total number of persistent connections that need to be configured in the host according to business volume requirements, which is a parameter that is dynamically adjusted according to business requirements. Specifically, this parameter can be manually configured , and can also be automatically adjusted and configured by the software, for example, calculated by the artificial intelligence model by monitoring the business volume. The connection invocation signal may be sent by a timer, that is, the number of configured long connections is acquired at regular intervals. Of course, in this embodiment, the connection invocation signal may also be a program monitoring traffic volume. When the traffic volume changes abruptly issued, this embodiment does not limit it.

优选的,该配置长连接数可以放置到数据库表中,通过人工执行SQL语句更新数据库来实现配置长连接数的更新,本步骤进一步可以具体为:根据连接调用定时信号查询数据库表以获取配置长连接数。Preferably, the configuration long connection number can be placed in a database table, and the database is updated by manually executing SQL statements to realize the update of the configuration long connection number. number of connections.

优选的,为方便生产运维管理,本实施例的配置长连接数可以放置到配置中心,由配置中心对该参数进行管理,并由配置中心提供应用程序编程接口(ApplicationProgramming Interface,API)动态刷新该配置长连接数。本步骤S101可以进一步具体为:根据连接调用定时信号调用配置中心API接口,查询到配置中心的配置长连接数,并将该配置长连接数导入到主机内存中。在本实施例中,通过把配置长连接数放置到配置中心,并由应用系统导入到内存中,即可实现不影响数据库性能的情况下方便快速获取到配置长连接数,又可以满足动态刷新的需求。Preferably, in order to facilitate production operation and maintenance management, the number of long connections configured in this embodiment can be placed in the configuration center, the configuration center manages the parameter, and the configuration center provides an application programming interface (Application Programming Interface, API) to dynamically refresh This configures the number of long connections. This step S101 may be further specific as follows: calling the API interface of the configuration center according to the connection call timing signal, inquiring the number of configuration long-term connections of the configuration center, and importing the number of configured long-term connections into the host memory. In this embodiment, by placing the configured persistent connection number in the configuration center and importing it into the memory by the application system, the configuration persistent connection number can be easily and quickly obtained without affecting the performance of the database, and dynamic refresh can be satisfied. demand.

步骤S102:读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数。Step S102: Read the host memory table to obtain the number of started long-term connections, and compare the number of started long-term connections with the configured number of long-term connections.

在通过步骤S101获取到配置长连接数后,可以通过读取主机内存表来获得当前已经启动的长连接数,并将已经启动的长连接数和配置长连接数进行比对,以判断当前已启动的长连接数是否满足需求或者是否超过了需求,然后根据判断结果执行后续相应的操作。After the number of configured long-term connections is obtained through step S101, the number of currently started long-term connections can be obtained by reading the host memory table, and the number of long-term connections that have been started and the number of configured long-term connections can be compared to determine the current number of long-term connections. Whether the number of long connections started meets the requirements or whether it exceeds the requirements, and then perform subsequent corresponding operations according to the judgment results.

步骤S103:响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数。Step S103: In response to the number of activated long-term connections being less than the number of configured long-term connections, start several new long-term connections so that the number of activated long-term connections is equal to the number of configured long-term connections.

当根据步骤S102的结果显示已启动长连接数小于配置长连接数时,则表明需要扩充长连接数来满足业务需求,因此需要启动若干新长连接,使得已启动长连接数等于配置长连接数。When the result of step S102 shows that the number of started long connections is less than the configured number of long connections, it indicates that the number of long connections needs to be expanded to meet business requirements, so it is necessary to start several new long connections, so that the number of started long connections is equal to the number of configured long connections .

优选的,可以根据比对得到需要新启动的长连接数,然后逐个启动新长连接,并依次将新启动的长连接信息保存至内存表中,直至已启动长连接数等于所述配置长连接数。在本实施例中该长连接信息可以包括连接标识、连接开关状态和空闲繁忙状态等。Preferably, the number of long connections that need to be newly started can be obtained according to the comparison, and then new long connections are started one by one, and the information of the newly started long connections is stored in the memory table in turn, until the number of started long connections is equal to the configured long connection. number. In this embodiment, the long connection information may include a connection identifier, a connection switch state, an idle busy state, and the like.

步骤S104:响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。Step S104 : in response to the number of activated persistent connections being greater than the configured number of persistent connections, stop several activated persistent connections so that the number of activated persistent connections is equal to the configured number of persistent connections.

当根据步骤S102的结果显示已启动长连接数大于配置长连接数时,说明对于目前业务量来说长连接数过剩,因此需要停止若干已启动长连接使已启动长连接数等于所述配置长连接数,使得主机系统资源得以释放,降低主机负荷。When the result of step S102 shows that the number of started long connections is greater than the configured number of long connections, it means that the number of long connections is excessive for the current traffic, so it is necessary to stop several started long connections so that the number of started long connections is equal to the configured number of long connections The number of connections can release host system resources and reduce host load.

优选的,如图2所示,该步骤S104可以进一步包括如下子步骤:Preferably, as shown in FIG. 2 , this step S104 may further include the following sub-steps:

步骤S1041:从主机内存表中找到最后一个已启动的长连接。Step S1041: Find the last activated persistent connection from the host memory table.

步骤S1042:关闭所述最后一个已启动的长连接的连接开关。Step S1042: Turn off the connection switch of the last activated persistent connection.

步骤S1043:通过POST通知指令唤醒所述最后一个已启动的长连接的阻塞状态,使最后一个已启动的长连接进程自动结束。Step S1043: Wake up the blocking state of the last activated persistent connection through a POST notification instruction, so that the last activated persistent connection process ends automatically.

步骤S1044:判断已启动长连接数是否等于所述配置长连接数,若是,则结束操作并进入休眠状态,若否,则返回步骤S1041。Step S1044: Determine whether the number of activated persistent connections is equal to the configured number of persistent connections, if so, end the operation and enter the sleep state, if not, return to step S1041.

另外如果步骤S102的比对结果为已启动长连接数正好等于所述配置长连接数,则无需进行后续操作,直接进入休眠状态,等待下一次的连接调用信号到来。In addition, if the comparison result in step S102 is that the number of activated long-term connections is exactly equal to the configured number of long-term connections, no subsequent operation is required, and the dormant state is directly entered, waiting for the next connection call signal to arrive.

如上所述,本申请可以根据业务量动态对主机长连接数进行调整,新增的长连接信息直接存入内存表,整个调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。As mentioned above, the application can dynamically adjust the number of long-term connections to the host according to the traffic volume, and the newly added long-connection information is directly stored in the memory table. The entire adjustment process does not need to modify the assembly table, and does not need to restart the host middleware system. On the premise of business continuity, complete the adjustment of the number of long communication connections. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

下面以配置长连接参数设置于配置中心为例对本申请进行进一步详细描述,如图3所示为本申请另一实施例提供的一种动态调整长连接数的方法的流程示意图,本实施例的实施主体为主机中一长连接动态调整装置,该方法包括如下步骤:The present application will be described in further detail below by taking the configuration long connection parameters set in the configuration center as an example. FIG. 3 is a schematic flowchart of a method for dynamically adjusting the number of long connections provided by another embodiment of the present application. The implementation body is a long-connection dynamic adjustment device in the host, and the method includes the following steps:

步骤S301:根据定时器的定时信号向配置中心发起查询配置长连接数的请求,配置中心在收到请求后将配置长连接数返回给长连接动态调整装置。Step S301 : according to the timing signal of the timer, initiate a request to the configuration center for querying the number of configured persistent connections, and the configuration center returns the configured persistent connection number to the persistent connection dynamic adjustment device after receiving the request.

步骤S302:查询主机内存表,获取目前已经启动的所有长连接信息,该长连接信息可以包括启动的长连接总数、每个长连接的连接开关状态等。Step S302: Query the host memory table to obtain all the persistent connection information that has been started so far, and the persistent connection information may include the total number of activated persistent connections, the connection switch status of each persistent connection, and the like.

步骤S303:判断已启动的长连接数是否等于配置长连接数,若等于,则进入步骤S304,若不等于则进入步骤S305。Step S303: Determine whether the number of activated long-term connections is equal to the number of configured long-term connections, if so, proceed to step S304, and if not, proceed to step S305.

步骤S304:长连接动态调整装置进入休眠状态,该休眠时间可以由定时器进行设定,当定时器发出工作信号后,长连接动态调整装置即可以继续步骤S301进行工作。Step S304: The persistent connection dynamic adjustment device enters a dormant state, and the dormancy time can be set by a timer. After the timer sends a working signal, the persistent connection dynamic adjustment device can continue to work in step S301.

步骤S305:判断已启动的长连接数是否小于配置长连接数,若是,则进入步骤S306,若否,则进入步骤S307。Step S305: Determine whether the number of activated long-term connections is less than the number of configured long-term connections, if so, go to step S306, if not, go to step S307.

步骤S306:启动一个新长连接,并将该新长连接信息在内存表中更新,然后返回步骤S302。Step S306: Start a new persistent connection, update the new persistent connection information in the memory table, and then return to step S302.

步骤S307:从主机内存表中找到最后一个已启动的长连接,把对应连接开关关闭,然后更新内存表,并进入步骤S308。Step S307: Find the last activated long connection from the host memory table, turn off the corresponding connection switch, then update the memory table, and go to step S308.

步骤S308:通过POST通知唤醒长连接的阻塞状态并返回步骤S302,当长连接连接开关处于关闭状态,且处于阻塞状态时,该长连接进程会自动结束。Step S308 : wake up the blocking state of the persistent connection through the POST notification and return to step S302 , when the persistent connection switch is in the off state and in the blocking state, the persistent connection process will automatically end.

如上所述,本申请可以根据业务量动态对主机长连接数进行调整,新增的长连接信息直接存入内存表,整个调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。As mentioned above, the application can dynamically adjust the number of long-term connections to the host according to the traffic volume, and the newly added long-connection information is directly stored in the memory table. The entire adjustment process does not need to modify the assembly table, and does not need to restart the host middleware system. On the premise of business continuity, complete the adjustment of the number of long communication connections. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

如图4所示为本申请实施例提供的一种动态调整长连接数的装置的结构示意图,该装置包括:配置获取单元410、内存读取单元420、连接启动单元430和连接停止单元440,其中内存读取单元420分别和配置获取单元410、连接启动单元430及连接停止单元440相连。FIG. 4 is a schematic structural diagram of an apparatus for dynamically adjusting the number of long connections provided by an embodiment of the present application. The apparatus includes: a configuration obtaining unit 410, a memory reading unit 420, a connection starting unit 430, and a connection stopping unit 440, The memory reading unit 420 is respectively connected with the configuration obtaining unit 410 , the connection starting unit 430 and the connection stopping unit 440 .

配置获取单元410用于根据连接调用信号获取配置长连接数。The configuration obtaining unit 410 is configured to obtain the number of configuration long connections according to the connection invocation signal.

优选的,本实施例的配置长连接数可设置于配置中心内,相应的配置获取单元410具体可用于:根据连接调用定时信号调用配置中心API接口,查询到配置中心的配置长连接数。Preferably, the configuration persistent connection number in this embodiment can be set in the configuration center, and the corresponding configuration acquisition unit 410 can be specifically configured to: call the configuration center API interface according to the connection call timing signal, and query the configuration persistent connection number of the configuration center.

优选的,本实施例的配置长连接数也可设置于数据库表中,相应的配置获取单元410具体可用于:根据连接调用定时信号查询数据库表以获取配置长连接数。Preferably, the number of configured persistent connections in this embodiment may also be set in a database table, and the corresponding configuration acquisition unit 410 may be specifically configured to: query the database table according to the connection call timing signal to acquire the configured persistent number of connections.

内存读取单元420用于读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数。The memory reading unit 420 is configured to read the host memory table to obtain the number of started long-term connections, and compare the number of started long-term connections with the configured number of long-term connections.

连接启动单元430用于响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数。The connection initiation unit 430 is configured to initiate a number of new persistent connections so that the number of initiated persistent connections is equal to the configured number of persistent connections in response to the number of initiated persistent connections being less than the configured number of persistent connections.

优选的,连接启动单元430具体可用于:逐个启动新长连接,并依次将新启动的长连接信息保存至所述内存表中,直至已启动长连接数等于所述配置长连接数。该长连接信息可以包括:连接标识、连接开关状态和空闲繁忙状态。Preferably, the connection initiation unit 430 may be specifically configured to: start new persistent connections one by one, and sequentially save the newly started persistent connection information in the memory table until the number of started persistent connections equals the configured number of persistent connections. The long connection information may include: connection identification, connection switch state and idle busy state.

连接停止单元440用于响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。The connection stopping unit 440 is configured to, in response to the number of started long-term connections being greater than the configured number of long-term connections, stop several started long-term connections so that the number of started long-term connections is equal to the configured number of long-term connections.

优选的,连接停止单元440具体可用于执行如下步骤:Preferably, the connection stop unit 440 can be specifically configured to perform the following steps:

步骤a,从所述内存表中找到最后一个已启动的长连接;Step a, find the last started long connection from the memory table;

步骤b,关闭所述最后一个已启动的长连接的连接开关;Step b, closing the connection switch of the last activated long connection;

步骤c,通过POST通知指令唤醒所述最后一个已启动的长连接的阻塞状态,使所述最后一个已启动的长连接进程自动结束;Step c, wake up the blocking state of the last started long connection through the POST notification instruction, so that the last started long connection process automatically ends;

重复步骤a至步骤c直至已启动长连接数等于所述配置长连接数。Steps a to c are repeated until the number of activated long-term connections is equal to the configured number of long-term connections.

关于上述单元的详细描述可以参见图1对应方法实施例中的描述,在此不再进行赘述。For a detailed description of the above units, reference may be made to the description in the method embodiment corresponding to FIG. 1 , and details are not repeated here.

如上所述,本申请提供的动态调整长连接数的装置可以根据业务量动态对主机长连接数进行调整,新增的长连接信息直接存入内存表,整个调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。As mentioned above, the device for dynamically adjusting the number of long connections provided by the present application can dynamically adjust the number of long connections of the host according to the traffic volume, and the newly added long connection information is directly stored in the memory table, and the entire adjustment process does not need to modify the compilation table, and does not need to restart The host middleware system can adjust the number of long communication connections without affecting business continuity. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

图5为本发明另一实施例提供的电子设备1100的系统构成的示意框图。如图5所示,该电子设备1100可以包括中央处理器1110和存储器1120;存储器1120耦合到中央处理器1110。值得注意的是,该图5是示例性的;还可以使用其他类型的结构,来补充或代替该结构,以实现电信功能或其他功能。FIG. 5 is a schematic block diagram of a system configuration of an electronic device 1100 according to another embodiment of the present invention. As shown in FIG. 5 , the electronic device 1100 may include a central processing unit 1110 and a memory 1120 ; the memory 1120 is coupled to the central processing unit 1110 . Notably, this FIG. 5 is exemplary; other types of structures may be used in addition to or in place of this structure to implement telecommunication functions or other functions.

一实施例中,动态调整长连接数的方法功能可以被集成到中央处理器1110中。In one embodiment, the method function of dynamically adjusting the number of long connections may be integrated into the central processing unit 1110 .

其中,中央处理器1110可以被配置为进行如下控制:Among them, the central processing unit 1110 can be configured to perform the following controls:

步骤S101:根据连接调用信号获取配置长连接数。Step S101: Acquire the number of configured long connections according to the connection invocation signal.

步骤S102:读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数。Step S102: Read the host memory table to obtain the number of started long-term connections, and compare the number of started long-term connections with the configured number of long-term connections.

步骤S103:响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数。Step S103: In response to the number of activated long-term connections being less than the number of configured long-term connections, start several new long-term connections so that the number of activated long-term connections is equal to the number of configured long-term connections.

步骤S104:响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。Step S104 : in response to the number of activated persistent connections being greater than the configured number of persistent connections, stop several activated persistent connections so that the number of activated persistent connections is equal to the configured number of persistent connections.

在另一个实施方式中,动态调整长连接数的装置可以与中央处理器1110分开配置,例如可以将动态调整长连接数的装置配置为与中央处理器1110连接的芯片,通过中央处理器的控制来实现上述动态调整长连接数的方法功能。In another embodiment, the device for dynamically adjusting the number of long connections can be configured separately from the central processing unit 1110. For example, the device for dynamically adjusting the number of long connections can be configured as a chip connected to the central processing unit 1110, through the control of the central processing unit. To realize the above method and function of dynamically adjusting the number of long connections.

如图5所示,该电子设备1100还可以包括:通信模块1130、输入单元1140、音频处理器1150、显示器1160、电源1170。值得注意的是,电子设备1100也并不是必须要包括图5中所示的所有部件;此外,电子设备1100还可以包括图5中没有示出的部件,可以参考现有技术。As shown in FIG. 5 , the electronic device 1100 may further include: a communication module 1130 , an input unit 1140 , an audio processor 1150 , a display 1160 , and a power supply 1170 . It is worth noting that the electronic device 1100 does not necessarily include all the components shown in FIG. 5 ; in addition, the electronic device 1100 may also include components not shown in FIG. 5 , and reference may be made to the prior art.

如图5所示,中央处理器1110有时也称为控制器或操作控件,可以包括微处理器或其他处理器装置和/或逻辑装置,中央处理器1110接收输入并控制电子设备1100的各个部件的操作。As shown in FIG. 5, the central processing unit 1110, also sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, the central processing unit 1110 receives input and controls the various components of the electronic device 1100 operation.

其中,存储器1120,例如可以是缓存器、闪存、硬驱、可移动介质、易失性存储器、非易失性存储器或其它合适装置中的一种或更多种。可储存上述动态调整长连接数方法有关的信息,此外还可存储执行有关信息的程序。并且中央处理器1110可执行该存储器1120存储的该程序,以实现信息存储或处理等。The memory 1120 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. Information related to the above-mentioned method of dynamically adjusting the number of persistent connections can be stored, and a program that executes the information can also be stored. And the central processing unit 1110 can execute the program stored in the memory 1120 to realize information storage or processing.

输入单元1140向中央处理器1110提供输入。该输入单元1140例如为按键或触摸输入装置。电源1170用于向电子设备1100提供电力。显示器1160用于进行图像和文字等显示对象的显示。该显示器例如可为LCD显示器,但并不限于此。The input unit 1140 provides input to the central processing unit 1110 . The input unit 1140 is, for example, a key or a touch input device. The power supply 1170 is used to provide power to the electronic device 1100 . The display 1160 is used for displaying display objects such as images and characters. The display can be, for example, but not limited to, an LCD display.

该存储器1120可以是固态存储器,例如,只读存储器(ROM)、随机存取存储器(RAM)、SIM卡等。还可以是这样的存储器,其即使在断电时也保存信息,可被选择性地擦除且设有更多数据,该存储器的示例有时被称为EPROM等。存储器1120还可以是某种其它类型的装置。存储器1120包括缓冲存储器1121(有时被称为缓冲器)。存储器1120可以包括应用/功能存储部1122,该应用/功能存储部1122用于存储应用程序和功能程序或用于通过中央处理器1110执行电子设备1100的操作的流程。The memory 1120 may be solid state memory, eg, read only memory (ROM), random access memory (RAM), SIM card, and the like. There may also be memories that retain information even when powered off, selectively erased and provided with more data, examples of which are sometimes referred to as EPROMs or the like. Memory 1120 may also be some other type of device. Memory 1120 includes buffer memory 1121 (sometimes referred to as a buffer). The memory 1120 may include an application/function storage part 1122 for storing application programs and function programs or for performing operations of the electronic device 1100 through the central processing unit 1110 .

存储器1120还可以包括数据存储部1123,该数据存储部1123用于存储数据,例如联系人、数字数据、图片、声音和/或任何其他由电子设备使用的数据。存储器1120的驱动程序存储部1124可以包括电子设备的用于通信功能和/或用于执行电子设备的其他功能(如消息传送应用、通讯录应用等)的各种驱动程序。Memory 1120 may also include data storage 1123 for storing data such as contacts, digital data, pictures, sounds, and/or any other data used by the electronic device. The driver storage section 1124 of the memory 1120 may include various drivers of the electronic device for communication functions and/or for executing other functions of the electronic device (eg, a messaging application, a contact book application, etc.).

通信模块1130即为经由天线1131发送和接收信号的发送机/接收机1130。通信模块(发送机/接收机)1130耦合到中央处理器1110,以提供输入信号和接收输出信号,这可以和常规移动通信终端的情况相同。The communication module 1130 is the transmitter/receiver 1130 that transmits and receives signals via the antenna 1131 . A communication module (transmitter/receiver) 1130 is coupled to the central processor 1110 to provide input signals and receive output signals, as may be the case with conventional mobile communication terminals.

基于不同的通信技术,在同一电子设备中,可以设置有多个通信模块1130,如蜂窝网络模块、蓝牙模块和/或无线局域网模块等。通信模块(发送机/接收机)1130还经由音频处理器1150耦合到扬声器1151和麦克风1152,以经由扬声器1151提供音频输出,并接收来自麦克风1152的音频输入,从而实现通常的电信功能。音频处理器1150可以包括任何合适的缓冲器、解码器、放大器等。另外,音频处理器1150还耦合到中央处理器1110,从而使得可以通过麦克风1152能够在本机上录音,且使得可以通过扬声器1151来播放本机上存储的声音。Based on different communication technologies, multiple communication modules 1130 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module, and/or a wireless local area network module. The communication module (transmitter/receiver) 1130 is also coupled to the speaker 1151 and the microphone 1152 via the audio processor 1150 to provide audio output via the speaker 1151 and to receive audio input from the microphone 1152 for general telecommunication functions. Audio processor 1150 may include any suitable buffers, decoders, amplifiers, and the like. In addition, the audio processor 1150 is also coupled to the central processing unit 1110 , thereby enabling recording on the local unit through the microphone 1152 , and enabling playback of the sound stored on the local unit through the speaker 1151 .

本申请的实施例还提供能够实现上述实施例中的执行主体为客户端的动态调整长连接数的方法中全部步骤的一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述实施例中的执行主体为客户端的动态调整长连接数的方法的全部步骤,例如,所述处理器执行所述计算机程序时实现下述步骤:The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps in the method for dynamically adjusting the number of persistent connections in the above-mentioned embodiments in which the execution subject is a client, and a computer program is stored on the computer-readable storage medium , when the computer program is executed by the processor, it implements all the steps of the method for dynamically adjusting the number of long connections in the above-mentioned embodiment where the execution subject is the client. For example, when the processor executes the computer program, the following steps are implemented:

步骤S101:根据连接调用信号获取配置长连接数。Step S101: Acquire the number of configured long connections according to the connection invocation signal.

步骤S102:读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数。Step S102: Read the host memory table to obtain the number of started long-term connections, and compare the number of started long-term connections with the configured number of long-term connections.

步骤S103:响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数。Step S103: In response to the number of activated long-term connections being less than the number of configured long-term connections, start several new long-term connections so that the number of activated long-term connections is equal to the number of configured long-term connections.

步骤S104:响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。Step S104 : in response to the number of activated persistent connections being greater than the configured number of persistent connections, stop several activated persistent connections so that the number of activated persistent connections is equal to the configured number of persistent connections.

从上述描述可知,本申请实施例提供的计算机可读存储介质,可以根据业务量动态对主机长连接数进行调整,新增的长连接信息直接存入内存表,整个调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。It can be seen from the above description that the computer-readable storage medium provided by the embodiment of the present application can dynamically adjust the number of long-term connections of the host according to the traffic volume, and the newly-added long-connection information is directly stored in the memory table, and the compilation table does not need to be modified in the whole adjustment process. There is no need to restart the host middleware system, and the adjustment of the number of long communication connections can be completed without affecting business continuity. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

本申请的实施例还提供能够实现上述实施例中的执行主体为客户端的动态调整长连接数的方法中全部步骤的一种计算机程序产品,该计算机程序/指令被处理器执行时实现所述的动态调整长连接数的方法的步骤,例如,所述计算机程序/指令实现下述步骤:The embodiments of the present application also provide a computer program product capable of implementing all the steps in the method for dynamically adjusting the number of persistent connections in the above-mentioned embodiments, in which the execution subject is the client. The steps of the method for dynamically adjusting the number of long connections, for example, the computer program/instruction implements the following steps:

步骤S101:根据连接调用信号获取配置长连接数。Step S101: Acquire the number of configured long connections according to the connection invocation signal.

步骤S102:读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数。Step S102: Read the host memory table to obtain the number of started long-term connections, and compare the number of started long-term connections with the configured number of long-term connections.

步骤S103:响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数。Step S103: In response to the number of activated long-term connections being less than the number of configured long-term connections, start several new long-term connections so that the number of activated long-term connections is equal to the number of configured long-term connections.

步骤S104:响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。Step S104 : in response to the number of activated persistent connections being greater than the configured number of persistent connections, stop several activated persistent connections so that the number of activated persistent connections is equal to the configured number of persistent connections.

从上述描述可知,本申请实施例提供的计算机程序产品,可以根据业务量动态对主机长连接数进行调整,新增的长连接信息直接存入内存表,整个调整过程无需修改汇编表,无需重启主机中间件系统,可以在不影响业务连续性的前提下,完成通讯长连接数的调整。当业务出现异常情况下,可以提升应急效率,大大减少异常期间对业务的影响。It can be seen from the above description that the computer program product provided by the embodiment of the present application can dynamically adjust the number of long-term connections of the host according to the traffic volume, and the newly-added long-term connection information is directly stored in the memory table, and the entire adjustment process does not need to modify the assembly table or restart. The host middleware system can adjust the number of long communication connections without affecting business continuity. When an abnormal situation occurs in the business, the emergency response efficiency can be improved, and the impact on the business during the abnormal period can be greatly reduced.

在本说明书的描述中,参考术语“一个实施例”、“一个具体实施例”、“一些实施例”、“例如”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。各实施例中涉及的步骤顺序用于示意性说明本发明的实施,其中的步骤顺序不作限定,可根据需要作适当调整。In the description of this specification, reference to the terms "one embodiment", "one specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples", etc. Indicates that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in each embodiment is used to schematically illustrate the implementation of the present invention, and the sequence of steps therein is not limited, and can be appropriately adjusted as required.

本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

以上所述的具体实施例,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施例而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above-mentioned specific embodiments are only specific embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims (10)

1.一种动态调整长连接数的方法,其特征在于,所述方法包括:1. a method for dynamically adjusting the number of long connections, characterized in that the method comprises: 根据连接调用信号获取配置长连接数;Obtain and configure the number of long connections according to the connection call signal; 读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数;Read the host memory table to obtain the number of started long connections, and compare the number of started long connections with the number of configured long connections; 响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数;In response to the number of started long connections being less than the configured number of long connections, start several new long connections so that the number of started long connections is equal to the configured number of long connections; 响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。In response to the number of activated persistent connections being greater than the configured number of persistent connections, a number of activated persistent connections are stopped so that the number of activated persistent connections is equal to the configured number of persistent connections. 2.如权利要求1所述的动态调整长连接数的方法,其特征在于,所述根据连接调用信号获取配置长连接数包括:2. The method for dynamically adjusting the number of long connections as claimed in claim 1, wherein the obtaining and configuring the number of long connections according to the connection call signal comprises: 根据连接调用定时信号调用配置中心API接口,查询到配置中心的配置长连接数。Call the configuration center API interface according to the connection call timing signal to query the number of configuration long connections to the configuration center. 3.如权利要求1所述的动态调整长连接数的方法,其特征在于,所述根据连接调用信号获取配置长连接数包括:3. The method for dynamically adjusting the number of long connections as claimed in claim 1, wherein the obtaining and configuring the number of long connections according to the connection call signal comprises: 根据连接调用定时信号查询数据库表以获取配置长连接数。Query the database table according to the connection call timing signal to obtain the configured number of long connections. 4.如权利要求1所述的动态调整长连接数的方法,其特征在于,所述启动若干新长连接使已启动长连接数等于所述配置长连接数包括:4. The method for dynamically adjusting the number of long connections according to claim 1, wherein said starting several new long connections so that the number of started long connections is equal to the number of configured long connections comprises: 逐个启动新长连接,并依次将新启动的长连接信息保存至所述主机内存表中,直至已启动长连接数等于所述配置长连接数。New persistent connections are started one by one, and information of newly started persistent connections is sequentially stored in the host memory table, until the number of started persistent connections is equal to the configured number of persistent connections. 5.如权利要求4所述的动态调整长连接数的方法,其特征在于,所述长连接信息包括:连接标识、连接开关状态和空闲繁忙状态。5 . The method for dynamically adjusting the number of long connections according to claim 4 , wherein the long connection information comprises: a connection identifier, a connection switch state, and an idle busy state. 6 . 6.如权利要求1所述的动态调整长连接数的方法,其特征在于,所述停止若干已启动长连接使已启动长连接数等于所述配置长连接数包括:6. The method for dynamically adjusting the number of long connections according to claim 1, wherein the stopping several started long connections so that the number of started long connections is equal to the number of configured long connections comprises: 步骤a,从所述主机内存表中找到最后一个已启动的长连接;Step a, find the last started long connection from the host memory table; 步骤b,关闭所述最后一个已启动的长连接的连接开关;Step b, closing the connection switch of the last activated long connection; 步骤c,通过POST通知指令唤醒所述最后一个已启动的长连接的阻塞状态,使所述最后一个已启动的长连接进程自动结束;Step c, wake up the blocking state of the last started long connection through the POST notification instruction, so that the last started long connection process automatically ends; 重复步骤a至步骤c直至已启动长连接数等于所述配置长连接数。Steps a to c are repeated until the number of activated long-term connections is equal to the configured number of long-term connections. 7.一种动态调整长连接数的装置,其特征在于,所述装置包括:7. A device for dynamically adjusting the number of long connections, wherein the device comprises: 配置获取单元,用于根据连接调用信号获取配置长连接数;The configuration obtaining unit is used to obtain the number of configuration long connections according to the connection call signal; 内存读取单元,用于读取主机内存表获得已启动长连接数,并比对所述已启动长连接数和所述配置长连接数;a memory reading unit, configured to read the host memory table to obtain the number of long connections started, and compare the number of long connections started with the number of configured long connections; 连接启动单元,用于响应于所述已启动长连接数小于所述配置长连接数,启动若干新长连接使已启动长连接数等于所述配置长连接数;a connection initiation unit, configured to initiate a number of new long connections so that the number of started long connections is equal to the configured number of long connections in response to the number of started long connections being less than the number of configured long connections; 连接停止单元,用于响应于所述已启动长连接数大于所述配置长连接数,停止若干已启动长连接使已启动长连接数等于所述配置长连接数。A connection stopping unit, configured to stop a number of started long connections so that the number of started long connections is equal to the configured number of long connections in response to the number of started long connections being greater than the configured number of long connections. 8.一种电子设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现权利要求1至6任一项所述动态调整长连接数的方法的步骤。8. An electronic device comprising a memory, a processor and a computer program stored on the memory and running on the processor, wherein the processor implements claim 1 when executing the computer program Steps of the method for dynamically adjusting the number of long connections described in any one of to 6. 9.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至6任一项所述动态调整长连接数的方法的步骤。9. A computer-readable storage medium on which a computer program is stored, wherein the computer program realizes the steps of the method for dynamically adjusting the number of long connections described in any one of claims 1 to 6 when the computer program is executed by the processor . 10.一种计算机程序产品,包括计算机程序/指令,其特征在于,所述计算机程序/指令被处理器执行时实现权利要求1至6任一项所述动态调整长连接数的方法的步骤。10. A computer program product, comprising a computer program/instruction, characterized in that, when the computer program/instruction is executed by a processor, the steps of the method for dynamically adjusting the number of long connections according to any one of claims 1 to 6 are implemented.
CN202210750089.8A 2022-06-29 2022-06-29 Method and device for dynamically adjusting the number of long connections Active CN115134400B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210750089.8A CN115134400B (en) 2022-06-29 2022-06-29 Method and device for dynamically adjusting the number of long connections

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210750089.8A CN115134400B (en) 2022-06-29 2022-06-29 Method and device for dynamically adjusting the number of long connections

Publications (2)

Publication Number Publication Date
CN115134400A true CN115134400A (en) 2022-09-30
CN115134400B CN115134400B (en) 2024-11-19

Family

ID=83379068

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210750089.8A Active CN115134400B (en) 2022-06-29 2022-06-29 Method and device for dynamically adjusting the number of long connections

Country Status (1)

Country Link
CN (1) CN115134400B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199666A (en) * 2014-09-09 2014-12-10 北京京东尚科信息技术有限公司 Dynamic configuration method and device for application program
CN106250500A (en) * 2016-07-29 2016-12-21 广州唯品会信息科技有限公司 The dynamic management approach of database connection pool and system
CN107135279A (en) * 2017-07-07 2017-09-05 网宿科技股份有限公司 It is a kind of to handle the method and apparatus that request is set up in long connection
CN107154922A (en) * 2016-03-04 2017-09-12 北京京东尚科信息技术有限公司 Configuration management system and configuring management method
CN107980128A (en) * 2016-11-07 2018-05-01 深圳中兴力维技术有限公司 Data docking dynamic management method and device
CN109660584A (en) * 2017-10-12 2019-04-19 阿里巴巴集团控股有限公司 A kind of method and communication means and communication system of client and the long connection of server foundation
CN111586140A (en) * 2020-04-30 2020-08-25 深圳市优必选科技股份有限公司 Data interaction method and server
CN113242149A (en) * 2021-05-21 2021-08-10 中国农业银行股份有限公司 Long connection configuration method, device, equipment, storage medium and program product

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104199666A (en) * 2014-09-09 2014-12-10 北京京东尚科信息技术有限公司 Dynamic configuration method and device for application program
CN107154922A (en) * 2016-03-04 2017-09-12 北京京东尚科信息技术有限公司 Configuration management system and configuring management method
CN106250500A (en) * 2016-07-29 2016-12-21 广州唯品会信息科技有限公司 The dynamic management approach of database connection pool and system
CN107980128A (en) * 2016-11-07 2018-05-01 深圳中兴力维技术有限公司 Data docking dynamic management method and device
CN107135279A (en) * 2017-07-07 2017-09-05 网宿科技股份有限公司 It is a kind of to handle the method and apparatus that request is set up in long connection
CN109660584A (en) * 2017-10-12 2019-04-19 阿里巴巴集团控股有限公司 A kind of method and communication means and communication system of client and the long connection of server foundation
CN111586140A (en) * 2020-04-30 2020-08-25 深圳市优必选科技股份有限公司 Data interaction method and server
CN113242149A (en) * 2021-05-21 2021-08-10 中国农业银行股份有限公司 Long connection configuration method, device, equipment, storage medium and program product

Also Published As

Publication number Publication date
CN115134400B (en) 2024-11-19

Similar Documents

Publication Publication Date Title
US8595529B2 (en) Efficient power management and optimized event notification in multi-processor computing devices
US11243595B2 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
JP6785332B2 (en) Bluetooth speaker Data processing method, device and bluetooth speaker
CN104322006B (en) Wireless wake-up device for cell module
CN107844341B (en) Process starting control method and device, storage medium and mobile terminal
CN114237896A (en) Distributed node resource dynamic scheduling method and device
CN110928586B (en) APP background keep-alive method and device
WO2024067803A1 (en) Data processing method, data processing apparatus, and electronic device and readable storage medium
US11366688B2 (en) Do-not-disturb processing method and apparatus, and storage medium
CN107231605A (en) Solve the method with Bluetooth communication compatibility between flash memory IoT equipment and Android device
CN115134400A (en) Method and device for dynamically adjusting long connection number
CN112445574B (en) Application container multi-cluster migration method and device
CN116028207A (en) Scheduling policy determination method, device, equipment and storage medium
CN113515509A (en) HBase data cleaning method and device
TW201347578A (en) Information transmission method and system, and device with sleeping function
CN114153449B (en) Business configuration method and system
CN116541149A (en) Service processing method and device based on self-adaptive thread pool
CN111782366A (en) Distributed task scheduling method and device
CN111737299A (en) Cached data processing method and device
WO2016110011A1 (en) Terminal, power saving method thereof, storage medium
CN114637587A (en) Task batch processing method and device under cluster architecture deployment
CN112218359B (en) A method and device for setting the duration of a timer
WO2024109290A1 (en) Application startup method and apparatus, device, and storage medium
CN117130765A (en) Configuration method of computing resources and electronic equipment
EP3989215A1 (en) Synchronous display blinking

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
GR01 Patent grant
GR01 Patent grant