CN114844897B - Method and device for distributed dynamic adjustment of long connection service based on Internet of things - Google Patents

Method and device for distributed dynamic adjustment of long connection service based on Internet of things Download PDF

Info

Publication number
CN114844897B
CN114844897B CN202210786504.5A CN202210786504A CN114844897B CN 114844897 B CN114844897 B CN 114844897B CN 202210786504 A CN202210786504 A CN 202210786504A CN 114844897 B CN114844897 B CN 114844897B
Authority
CN
China
Prior art keywords
service
connection
gateway server
server
long 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.)
Active
Application number
CN202210786504.5A
Other languages
Chinese (zh)
Other versions
CN114844897A (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.)
Shenzhen Aichangdian Technology Co ltd
Original Assignee
Shenzhen Aichangdian Technology Co ltd
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 Shenzhen Aichangdian Technology Co ltd filed Critical Shenzhen Aichangdian Technology Co ltd
Priority to CN202210786504.5A priority Critical patent/CN114844897B/en
Publication of CN114844897A publication Critical patent/CN114844897A/en
Application granted granted Critical
Publication of CN114844897B publication Critical patent/CN114844897B/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
    • H04L67/141Setup of application sessions

Abstract

The invention provides a distributed dynamic long connection service adjusting method based on the Internet of things, which comprises the following steps: a protoc protocol is defined by a user side, a corresponding user side code is generated according to the protoc protocol, and after the user side sends the user side code to the Nginx server side through the Internet of things, the user side obtains a long connection address related to the Nginx server side; the proxy forwarding configuration of the gateway server is realized by the Nginx server through the long connection address; the gateway server performs policy management related to service connection allocation on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration; and the gateway server allocates a plurality of service connection modes through a distributed dynamic adjustment long connection service mode by combining with corresponding policy management so as to realize policy management of the connection number of the gateway server to the plurality of service connection modes. The method provided by the invention can dynamically configure the load strategy of the service, and realizes the flexible configurable efficacy by combining the load balancing strategy.

Description

Method and device for distributed dynamic adjustment of long connection service based on Internet of things
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for distributed dynamic adjustment of long connection service based on the Internet of things.
Background
Generally, in order to solve the technical problem that load balancing needs to be partially performed manually in an internet of things (IOT) system, most internet of things systems rely on java development, a huge dependency package of java on system traffic and high load on system memory and cpu. The operating environment of the distributed system has the following heterogeneity (namely, diversity and difference exist): network, computer hardware, operating systems, programming languages, software implementations performed by different developers. The middleware is a way to solve the heterogeneity, and the middleware refers to a software layer, which provides a programming abstraction and shields the heterogeneity of an underlying network, computer hardware, an operating system and a programming language. The distributed system can effectively and efficiently operate on different scales, most of the services of the Internet of things are realized by manually adjusting the load through operation and maintenance personnel, namely, after the service performance does not meet the production requirement, a new node service is started to support normal operation of services, and the current market mostly adopts java spring closed whole barrel to realize a load balancing and dynamic capacity expansion strategy.
And (3) load balancing strategy:
(1)Random:
weighting randomly, and setting random probability according to weight;
the probability of collision on one section is high, but the larger the call quantity is, the more uniform the distribution is, and the weight is used according to the probability and then is more uniform, thereby being beneficial to dynamically adjusting the weight of a provider;
the disadvantages are as follows: there is a problem with slow provider accumulation of requests, e.g., the second machine is slow but not hanging, getting stuck when the request is tuned to the second machine, and all requests get stuck on the second machine over time.
(2)RoundRobin:
Weighted polling, setting a polling ratio according to the weight after the convention, and circularly calling nodes;
the disadvantages are that: there is also the problem of slow provider accumulation requests.
For this, consul is optimized by using a smooth weighted polling algorithm of nginnx, and the calling process can be abstracted as the following table 1:
TABLE 1
Pre-wheel sum weight The winner in this round Aggregate weight Weight after round (winner minus aggregate weight)
Starting wheel \ \ A(0), B(0), C(0)
A(3), B(2), C(1) A 6 A(-3), B(2), C(1)
A(0), B(4), C(2) B 6 A(0), B(-2), C(2)
A(3), B(0), C(3) A 6 A(-3), B(0), C(3)
A(0), B(2), C(4) C 6 A(0), B(2), C(-2)
A(3), B(4), C(-1) B 6 A(3), B(-2), C(-1)
A(6), B(0), C(0) A 6 A(0), B(0), C(0)
It is found that after the turn of the summation weight (3 +2+ 1), the loop returns to the starting point, the node flow is smooth in the whole process, and even in a short time period, the probability is distributed as expected.
This algorithm may be used with confidence if the user has a need for weighted polling.
(3)LeastActive:
The least weighted active call is preferred, the lower the active number is, the more preferred the call is, and the weighted random operation is carried out on the same active number. The active number refers to the counting difference before and after calling (aiming at a specific provider, namely the request sending number-response returning number), and represents the task accumulation amount of the specific provider, and the lower the active number is, the stronger the processing capacity of the provider is;
having slower providers receive fewer requests because the slower providers will have a greater difference in count before and after invocation; in contrast, the more powerful the node, the more requests it processes.
It should be particularly noted that consul supports the raft algorithm, enabling a smooth implementation of a highly available registry.
The GRPC (Google Remote Procedure Call) advantages are as follows:
HTTP/2 provides mechanisms for connection multiplexing, bi-directional streaming, server push, request priority, header compression, etc. Bandwidth can be saved, TCP link times can be reduced, a CPU can be saved, the mobile device can be helped to prolong the service life of a battery, and the like. The protocol design of the GRPC uses the existing semantics of HTTP2, the data of the request and the response are sent by using HTTP Body, and other control information is represented by Header.
GRPC defines services using ProtoBuf, a data serialization protocol developed by Google (similar to XML, JSON, hessian). The ProtoBuf can serialize data and can be widely applied to the aspects of data storage, communication protocols and the like. The compression and transmission efficiency is high, the grammar is simple, and the expressive force is strong.
GRPC supports multiple languages (C, C + +, python, PHP, nodejs, C #, objective-C, golang, java), and can automatically generate client and server function libraries based on languages. Versions of other languages, among which GRPC supports C, C + +, node. Js, python, ruby, objective-C, PHP, and C #, are actively under development, GRPC-Java has been provided.
The proto file generates the target code, and data transmission is compressed, so that bandwidth pressure is effectively saved. Serialization and deserialization are carried out on the data classes directly in the application program, and formats such as xml and json do not need to be analyzed and mapped.
Disclosure of Invention
In view of the above problems, the invention provides a method and a device for dynamically adjusting a long connection service in a distributed manner based on the internet of things, which can effectively solve the problem of dynamically adjusting service connection after the internet of things does not meet the production requirement.
In order to achieve the purpose, the invention adopts the following technical scheme:
in a first aspect, the present invention provides a method for distributed dynamic adjustment of long connection services based on the internet of things, where the method includes:
defining a protoc protocol by a user side, generating a corresponding user side code according to the protoc protocol, and after the user side sends the user side code to a Nginx server side through the Internet of things, the user side acquires a long connection address related to the Nginx server side;
the Nginx server side realizes proxy forwarding configuration on the gateway server side through the long connection address;
the gateway server performs policy management associated with service connection allocation on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration;
and the gateway server distributes a plurality of service connection modes through a distributed dynamic adjustment long connection service mode by combining with the corresponding policy management so as to realize the policy management of the connection number of the gateway server to the plurality of service connection modes.
In an embodiment, after the gateway server allocates, in combination with the corresponding policy management, a plurality of service connection modes by a distributed dynamic adjustment long connection service manner to implement the policy management on the number of connections of the gateway server to the plurality of service connection modes, the method includes:
the gateway server side performs the strategy management of starting and closing in a distributed dynamic adjustment long connection service mode through a threshold value obtained by a driving code of a docker application engine in the gateway server side according to the connection number of the plurality of service connection modes;
and when the connection number of the service connection modes does not reach the preset range from the threshold value, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode.
In an embodiment, after the gateway server allocates, in combination with the corresponding policy management, a plurality of service connection modes by a distributed dynamic adjustment long connection service manner to implement the policy management on the number of connections of the gateway server to the plurality of service connection modes, the method includes:
when the connection number of the service connection modes reaches a preset range of a distance threshold value, performing the strategy management of starting and closing through the distributed dynamic adjustment long connection service mode;
the strategy management executed by the gateway server is to close the prior business service information and start a new business service code to be sent to the business server;
and the service server side sends the new service code to a service registration center of the consul cluster side for registration.
In an embodiment, in performing policy management associated with service connection allocation on a service server by the gateway server through a service registry of a consul cluster terminal, the method includes:
the user side and/or the gateway server side modify the policy management associated with load balancing in a configurable manner.
In an embodiment, in the policy management that the gateway server allocates a plurality of service connection modes by a distributed dynamic adjustment of a long connection service manner in combination with the corresponding policy management to implement the number of connections of the gateway server to the plurality of service connection modes, the method includes:
and after the gateway server sets the connection quantity of the plurality of service connection modes through the service server, acquiring the connection quantity associated with any one of the plurality of service connection modes and transmitting the connection quantity to a Redis storage end for storage.
In a second aspect, the present invention provides an apparatus for distributed dynamic adjustment of long connection service based on internet of things, the apparatus comprising:
the system comprises a definition module, a service module and a management module, wherein the definition module is used for defining a protoc protocol for a user terminal, generating a corresponding user terminal code according to the protoc protocol, and after the user terminal sends the user terminal code to an Nginx service terminal through the Internet of things, the user terminal acquires a long connection address related to the Nginx service terminal;
the processing module is used for realizing proxy forwarding configuration of the gateway server to the Nginx server through the long connection address;
the calculation module is used for carrying out strategy management related to service connection distribution on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration;
and the adjusting module is used for allocating a plurality of service connection modes to the gateway server in a distributed dynamic adjustment long connection service mode in combination with the corresponding policy management so as to realize the policy management of the connection number of the gateway server to the plurality of service connection modes.
In one embodiment, the apparatus further comprises:
the driving module is used for performing the strategy management of starting and closing by the distributed dynamic adjustment long connection service mode on a threshold value obtained by a driving code of a docker application engine of the gateway server through the driving module according to the connection number of the plurality of service connection modes;
and when the connection number of the service connection modes does not reach the preset range from the threshold value, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode.
In one embodiment, the apparatus further comprises:
the preset module is used for carrying out the strategy management of starting and closing by the distributed dynamic adjustment long connection service mode when the connection number of the service connection modes reaches a preset range of a distance threshold value;
the strategy management executed by the gateway server side is to close the previous business service information and start a new business service code to be sent to the business server side;
and the service server sends the new service code to a service registration center of the consul cluster terminal for registration.
In one embodiment, the apparatus further comprises:
the modification module is configured to modify the policy management associated with load balancing in a configurable manner for the user side and/or the gateway server side.
In one embodiment, the apparatus further comprises:
and the storage module is used for acquiring the connection quantity related to any one of the service connection modes after the gateway server side sets the connection quantity of the service connection modes through the service server side respectively, and transmitting the connection quantity to a Redis storage side for storage.
The invention provides a method for dynamically adjusting long connection service in a distributed manner based on the Internet of things, which comprises the following steps: a protoc protocol is defined by a user side, a corresponding user side code is generated according to the protoc protocol, and after the user side sends the user side code to an Nginx server side through the Internet of things, the user side obtains a long connection address related to the Nginx server side; the proxy forwarding configuration of the gateway server is realized by the Nginx server through the long connection address; the gateway server performs policy management related to service connection allocation on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration; and the gateway server allocates a plurality of service connection modes through a distributed dynamic adjustment long connection service mode by combining with corresponding policy management so as to realize policy management of the connection number of the gateway server to the plurality of service connection modes.
The method provided by the invention can dynamically configure the load strategy of the service, realizes the configuration by combining the strategy of load balancing, is flexible and convenient to apply, can adopt the dynamic updating modes such as gray level release and the like to meet the high availability requirement of the service, and adopts the architecture design mode of separating the configuration from the logic to realize the high availability of the product. It should be noted that the method and the device for dynamically adjusting the long connection service in a distributed manner based on the internet of things are not limited to the application scenarios or specific electronic devices, and have strong universality. In addition, the invention solves the problem of equipment overload by using the technical innovation of nodejs + grpc + consul, realizes the technical means of automatic Internet of things service (IOT) starting and dynamic loading, breaks through the monopoly of java on the Internet of things right development language, fills the technical blank of nodejs on the Internet of things, reduces the technical difficulty and the operation and maintenance difficulty, can bear more users, and realizes high-availability and high-reliability light Internet of things service.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required in the embodiments will be briefly described below, and it should be understood that the following drawings only illustrate some embodiments of the present invention, and therefore should not be considered as limiting the scope of the present invention.
Fig. 1 is a flowchart of a method for a distributed dynamic adjustment of long connection services based on the internet of things.
Fig. 2 is a flowchart of another method of the distributed dynamic adjustment of long connection services based on the internet of things according to the present invention.
Fig. 3 is a flowchart of another method of the method for dynamically adjusting a long connection service in a distributed manner based on the internet of things.
Fig. 4 is a specific architecture diagram of a distributed dynamic adjustment long connection service based on the internet of things provided by the present invention.
Fig. 5 is a specific service timing diagram of a distributed dynamic adjustment long connection service based on the internet of things according to the present invention.
Fig. 6 is a schematic block diagram of an apparatus for distributed dynamic adjustment of long connection service based on the internet of things provided by the invention.
Detailed Description
Reference will now be made in detail to the embodiments of the present invention, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout.
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a method for dynamically adjusting a long connection service in a distributed manner based on the internet of things according to the present invention.
A method for distributed dynamic adjustment of long connection services based on the internet of things, the method comprising:
s1: a protoc protocol is defined by a user side, a corresponding user side code is generated according to the protoc protocol, and after the user side sends the user side code to a Nginx server side through the Internet of things, the user side obtains a long connection address related to the Nginx server side.
In one embodiment, the user terminal may be a user server. First, a protoc protocol is defined by a user end, for example, a rule, a standard or a convention established by the protoc protocol for data exchange in a network (which may be regarded as an internet of things). The protocol is used for communication between entities in software in different systems, servers or various electronic devices. When two entities are to communicate, the protocols must be composed of the same language, and for the communication content (which can be regarded as client code), how to communicate, the object communication and when to communicate, certain regulations must be adhered to, and these regulations are the protocols. Or simply a set of rules that control the exchange of data between more than two entities. In an electronic communication connection, each of the different layers has a specific protocol. Data exchange at both the hardware device level and the application level has its own protocol. In the Open System Interconnection (OSI) standard model, each layer may include one to two protocols, and both terminals of the electronic device that communicate must be able to recognize and comply with the protocols. Additionally, protocols are often described in terms of industry or international standards. The Nginx server can be implemented by software or a server, wherein Nginx is a high-performance HTTP and reverse proxy web server and also provides IMAP/POP3/SMTP service. And the user side acquires the long connection address related to the Nginx server side according to the user side code. Regarding the address applied to the long connection, the HTTP long connection means that after a TCP (Transmission Control Protocol) connection is established, the transport layer connection is not released any more, and the application layer is repeatedly used.
S2: and the Nginx server side realizes proxy forwarding configuration on the gateway server side through the long connection address.
In an embodiment, after the nginnx server receives the client code generated by the client through the defined protocol, the nginnx server further performs proxy forwarding configuration on the gateway server from the client code.
S3: and the gateway server performs policy management related to service connection allocation on the service server through a service registration center of the consul cluster terminal according to the proxy forwarding configuration.
In an embodiment, the Consul cluster is an open source tool for implementing Service discovery and configuration of the distributed system, and isolation between a Service provider (which may be regarded as a Service server) and a Service consumer (which may be regarded as a client) can be implemented, for example, the Service provider (Goods Service) registers itself in a Service registry of the Consul cluster, and registration information is ServiceName + ip/port, so that the Service consumer only needs to know the ServiceName to know the ip + port of the corresponding Service, thereby performing access and/or registration. For example, the policy management of service connection allocation may be regarded as a policy management that diversifies the way in which multiple services are connected to multiple intelligent appliances, so as to increase flexibility, and it is not possible that one of the multiple intelligent appliances loses network connection, and then other intelligent appliances also lose network connection.
S4: and the gateway server distributes a plurality of service connection modes through a distributed dynamic adjustment long connection service mode by combining with the corresponding policy management so as to realize the policy management of the connection number of the gateway server to the plurality of service connection modes.
In an embodiment, a gateway service end combines corresponding policy management, and allocates a plurality of service connection modes (for example, electronic devices 1, 3, and 5 in a first group are connected or electronic devices 2, 4, 6, and 8 in a second group are connected) by a policy management method according to a plurality of variable factors (which may be considered as variable factors for connecting networks according to different electronic devices or at different times) of the policy management, so as to implement policy management of the number of connections of the gateway service end to the plurality of service connection modes, for example, the number of connections of the electronic devices in the first group is 3 by policy management, the number of connections of the electronic devices in the second group is 4 by policy management, and the number of connections of the plurality of service connection modes managed by policy is not limited by a specific number of connections. The invention is flexible and convenient in application through a plurality of service connection modes managed by strategies, can adopt dynamic real-time updating modes such as gray level release and the like, and meets the requirements of high availability of services and high difficulty in finishing complex services.
Referring to fig. 1 and fig. 2, fig. 1 is a flowchart illustrating another method for dynamically adjusting a long connection service in a distributed manner based on the internet of things according to the present invention. Please refer to fig. 1 for S1-4, which are not repeated herein.
After the S4 allocating, by the gateway server, a plurality of service connection modes through a distributed dynamic adjustment long connection service manner in combination with the corresponding policy management to implement the policy management of the number of connections of the gateway server to the plurality of service connection modes, the method includes:
s5: the gateway server side performs the strategy management of starting and closing in a distributed dynamic adjustment long connection service mode through a threshold value obtained by a driving code of a docker application engine in the gateway server side according to the connection number of the plurality of service connection modes;
and when the connection number of the service connection modes does not reach a preset range from the threshold, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode.
In an embodiment, the docker application engine may enable developers to package their applications and dependencies into a portable image, and then distribute the portable image to any electronic device of the popular Linux or Windows operating system to implement virtualization through driver code, and further calculate a threshold value for obtaining the connection number of the multiple service connection modes, for example, the threshold value for obtaining the connection number of the first service connection mode is (for example, 10). When the connection number (for example, 7) of the first service connection mode does not reach the preset range (for example, 8) of the distance threshold, the policy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode, in other words, the connection number of the first service connection mode still has a space for adding other connectable electronic devices, so the policy management of the distributed dynamic adjustment long connection service mode is not performed.
After the S4 allocating, by the gateway server, a plurality of service connection modes through a distributed dynamic adjustment long connection service mode in combination with the corresponding policy management to implement the policy management of the number of connections of the gateway server to the plurality of service connection modes, the method includes:
when the connection number of the service connection modes reaches a preset range from the threshold value, performing the strategy management of starting and closing through the distributed dynamic adjustment long connection service mode;
the strategy management executed by the gateway server is to close the prior business service information and start a new business service code to be sent to the business server;
s6: and the service server side sends the new service code to a service registration center of the consul cluster side for registration.
In one embodiment, for example, the threshold for the acquisition of the number of connections for the second service connection mode is (e.g., 12). When the connection number (for example, 10) of the second service connection mode reaches a preset range (for example, 10) of the distance threshold, the policy management of starting and closing is performed by the distributed dynamic adjustment long connection service mode, in other words, the connection number of the second service connection mode does not have a space into which other electronic devices can be connected, so that the policy management of the distributed dynamic adjustment long connection service mode is performed. And the updated strategy management executed by the gateway server side is to further start a new service code after closing the previous service information and send the new service code to the service server side. And the service server side sends the new service code to a service registration center of the consul cluster side for registration through the updated policy management.
Referring to fig. 1, fig. 2 and fig. 3, fig. 1 is a flowchart of another method for dynamically adjusting a long connection service in a distributed manner based on the internet of things according to the present invention. Please refer to the embodiment description of fig. 1-2 for S1-2 and S5-6, which will not be described herein.
In S3, the gateway server performs policy management associated with service connection allocation to the service server through a service registry of the consul cluster, where the method includes:
s31: the client and/or the gateway server modify the policy management associated with load balancing in a configurable manner.
In one embodiment, the load balancing proposed by the present invention provides an inexpensive, effective and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capability, and improve the flexibility and availability of the network. And when the number of connections in the service connection mode reaches the preset range of the distance threshold, the ue and/or the gateway server modify the policy management associated with load balancing in a configurable manner, in other words, the ue may modify the policy management associated with load balancing in a manual or automatic manner, and the gateway server may modify the policy management associated with load balancing in a manual or automatic manner.
In S4, the gateway server allocates a plurality of service connection modes by a distributed dynamic adjustment of a long connection service manner in combination with the corresponding policy management, so as to implement the policy management of the number of connections of the gateway server to the plurality of service connection modes, where the method includes:
s41: and after the gateway server sets the connection quantity of the plurality of service connection modes through the service server, acquiring the connection quantity associated with any one of the plurality of service connection modes and transmitting the connection quantity to a Redis storage end for storage.
In an embodiment, the gateway server sets the connection number of a plurality of service connection modes (e.g., a first service connection mode and a second service connection mode) through the service server, respectively (e.g., the first service connection mode is 7, and the second service connection mode is 10). And after acquiring the connection quantity related to any one of the first service connection mode and the second service connection mode, respectively transmitting the connection quantity of the first service connection mode and the second service connection mode to a Redis storage terminal for storage. The invention develops a set of long-chain connection services with the dynamic scheduling load balance of the Internet of things based on nodejs completely and autonomously, improves the availability of the services and reduces the purchase cost of the server (which can be regarded as each server).
Referring to fig. 1-2 and fig. 4-5, fig. 4 is a specific architecture diagram of a distributed dynamic adjustment long connection service based on the internet of things according to the present invention, and fig. 5 is a specific service timing diagram of the distributed dynamic adjustment long connection service based on the internet of things according to the present invention. In fig. 4, the user side sends the user side code to the Nginx server side through the internet of things, the Nginx server side implements proxy forwarding configuration for the gateway server side through the long connection address, and the gateway server side performs policy management associated with service connection allocation for the service server side through a service registration center (GRPS) of the consul cluster side according to the proxy forwarding configuration. For example, the principle of GRPS (Google Remote Procedure Call), SAP (System Applications and Products in Data Processing) System RPC Call is simple, there are some C/S (Client/Server) systems similar to a three-layer architecture, and a Client program of a third party calls standard or custom functions inside the SAP through an interface, and obtains Data returned by the functions to process and display or print the Data. The dynamic long-link scheduling method based on nodejs + grpc + consul makes up for the technical weakness of nodejs in the direction of the Internet of things by using the nodejs light development language, improves the availability of services, and reduces the purchase cost of a server (which can be regarded as a server).
In fig. 5, S1 defines a protoc protocol for the user side, generates a corresponding user side code according to the protoc protocol, and after the user side sends the user side code to the Nginx server side through the internet of things, the user side obtains a long connection address associated with the Nginx server side; s2, the proxy forwarding configuration of the gateway server is realized by the Nginx server through a long connection address; s3, the gateway server performs policy management related to service connection allocation on the service server through a service registration center of a consul cluster terminal according to proxy forwarding configuration; s4, distributing a plurality of service connection modes by combining the gateway server with corresponding policy management through a distributed dynamic adjustment long connection service mode so as to realize policy management of the connection number of the gateway server to the plurality of service connection modes; s5, the gateway server performs strategy management of starting and closing by a distributed dynamic regulation long connection service mode through a driving code of a docker application engine in the gateway server according to a threshold value of the connection number of a plurality of service connection modes; and S6, the service server sends the new service code to a service registration center of the consul cluster end for registration.
Referring to fig. 6, fig. 6 is a schematic block diagram of an apparatus for distributed dynamic adjustment of long connection service based on the internet of things according to the present invention.
An apparatus for distributed dynamic adjustment of long connection services based on the internet of things, the apparatus 600 comprising:
a defining module 610, where the defining module 610 is configured to define a protoc protocol for a user end, generate a corresponding user end code according to the protoc protocol, and after the user end sends the user end code to an Nginx server end through an internet of things, the user end obtains a long connection address associated with the Nginx server end;
a processing module 620, where the processing module 620 is configured to implement proxy forwarding configuration on a gateway server for the nginnx server through the long connection address;
a calculating module 630, wherein the calculating module 630 performs policy management associated with service connection allocation on the service server by the service registration center of the consul cluster end according to the proxy forwarding configuration;
the adjusting module 640 allocates a plurality of service connection modes to the gateway server in a distributed dynamic adjustment long connection service manner in combination with the corresponding policy management, so as to implement the policy management of the number of connections of the gateway server to the plurality of service connection modes.
In one embodiment, the apparatus 600 further comprises:
a driving module 650, where the driving module 650 is configured to perform the policy management of starting and closing by using the distributed dynamic adjustment long connection service manner for a driving code of a docker application engine of the gateway server through the gateway server according to a threshold of the connection number of the multiple service connection modes;
and when the connection number of the service connection modes does not reach a preset range from the threshold, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode.
In one embodiment, the apparatus 600 further comprises:
a preset module 660, where the preset module 660 is configured to perform the policy management of starting and closing by using the distributed dynamic adjustment long connection service mode when the connection number of the multiple service connection modes reaches a preset range from the threshold;
the strategy management executed by the gateway server is to close the prior business service information and start a new business service code to be sent to the business server;
and the service server sends the new service code to a service registration center of the consul cluster terminal for registration.
In one embodiment, the apparatus 600 further comprises:
the modifying module 670, the modifying module 670 is configured to modify the policy management associated with load balancing in a configurable manner for the user side and/or the gateway server side.
In one embodiment, the apparatus 600 further comprises:
a storage module 680, where the storage module 680 is configured to obtain a connection number associated with any one of the multiple service connection modes after the gateway server sets the connection numbers of the multiple service connection modes through the service server, and transmit the connection number to a Redis storage. The defining module 610, the processing module 620, the calculating module 630, the adjusting module 640, the driving module 650, the presetting module 660, the modifying module 670 and the storing module 680 are electrically connected with each other and can be implemented by adaptive functional circuits and/or software.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described above with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are a part of the embodiments of the present invention, but not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the above detailed description of the embodiments of the invention presented in the drawings is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Claims (6)

1. A method for distributed dynamic adjustment of long connection service based on the Internet of things is characterized by comprising the following steps:
defining a protoc protocol by a user side, generating a corresponding user side code according to the protoc protocol, and after the user side sends the user side code to a Nginx server side through the Internet of things, the user side acquires a long connection address related to the Nginx server side;
the Nginx server side realizes proxy forwarding configuration on the gateway server side through the long connection address;
the gateway server performs policy management associated with service connection allocation on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration;
distributing a plurality of service connection modes by the gateway server in a distributed dynamic adjustment long connection service mode in combination with the corresponding policy management so as to realize the policy management of the connection number of the gateway server to the plurality of service connection modes;
the gateway server side performs the strategy management of starting and closing in a distributed dynamic adjustment long connection service mode through a threshold value obtained by a driving code of a docker application engine in the gateway server side according to the connection number of the plurality of service connection modes;
when the connection number of the service connection modes does not reach a preset range from the threshold value, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode;
when the connection number of the service connection modes reaches a preset range of a distance threshold, carrying out the strategy management of starting and closing by the distributed dynamic adjustment long connection service mode;
the strategy management executed by the gateway server is to close the prior business service information and start a new business service code to be sent to the business server;
and the service server side sends the new service code to a service registration center of the consul cluster side for registration.
2. The method for distributed dynamic regulation of long connection service based on internet of things according to claim 1, wherein in the policy management associated with service connection allocation of the service server by the gateway server through a service registry of a consul cluster end, the method comprises:
the client and/or the gateway server modify the policy management associated with load balancing in a configurable manner.
3. The method for distributed dynamic adjustment of long connection service based on internet of things according to claim 1, wherein in the policy management of allocating, by the gateway server, a plurality of service connection modes by a distributed dynamic adjustment of long connection service manner in combination with the corresponding policy management to achieve the number of connections of the gateway server to the plurality of service connection modes, the method comprises:
and after the gateway server sets the connection quantity of the plurality of service connection modes through the service server, acquiring the connection quantity associated with any one of the plurality of service connection modes and transmitting the connection quantity to a Redis storage end for storage.
4. An apparatus for distributed dynamic adjustment of long connection service based on internet of things, the apparatus comprising:
the system comprises a definition module, a service module and a management module, wherein the definition module is used for defining a protoc protocol for a user terminal, generating a corresponding user terminal code according to the protoc protocol, and after the user terminal sends the user terminal code to an Nginx service terminal through the Internet of things, the user terminal acquires a long connection address related to the Nginx service terminal;
the processing module is used for realizing proxy forwarding configuration of the gateway server to the Nginx server through the long connection address;
the calculation module is used for carrying out strategy management related to service connection distribution on the service server through a service registration center of a consul cluster terminal according to the proxy forwarding configuration;
the adjusting module is used for allocating a plurality of service connection modes to the gateway server in a distributed dynamic adjustment long connection service mode in combination with the corresponding policy management so as to realize the policy management of the connection number of the gateway server to the plurality of service connection modes;
the driving module is used for carrying out the strategy management of starting and closing by the distributed dynamic adjustment long connection service mode on a threshold value obtained by a driving code of a docker application engine of the gateway server through the driving module according to the connection number of the plurality of service connection modes;
when the connection number of the service connection modes does not reach a preset range from the threshold value, the strategy management of starting and closing is not performed through the distributed dynamic adjustment long connection service mode;
the preset module is used for carrying out the strategy management of starting and closing by the distributed dynamic adjustment long connection service mode when the connection number of the service connection modes reaches a preset range of a distance threshold value;
the strategy management executed by the gateway server side is to close the previous business service information and start a new business service code to be sent to the business server side;
and the service server sends the new service code to a service registration center of the consul cluster terminal for registration.
5. The apparatus for distributed dynamic regulation of long connection services based on the internet of things of claim 4, wherein the apparatus further comprises:
a modification module for modifying the policy management associated with load balancing in a configurable manner for the user side and/or the gateway server side.
6. The apparatus for distributed dynamic regulation of long connection services based on the internet of things of claim 4, wherein the apparatus further comprises:
and the storage module is used for acquiring the connection quantity related to any one of the service connection modes after the gateway server side sets the connection quantity of the service connection modes through the service server side respectively, and transmitting the connection quantity to a Redis storage side for storage.
CN202210786504.5A 2022-07-06 2022-07-06 Method and device for distributed dynamic adjustment of long connection service based on Internet of things Active CN114844897B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210786504.5A CN114844897B (en) 2022-07-06 2022-07-06 Method and device for distributed dynamic adjustment of long connection service based on Internet of things

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210786504.5A CN114844897B (en) 2022-07-06 2022-07-06 Method and device for distributed dynamic adjustment of long connection service based on Internet of things

Publications (2)

Publication Number Publication Date
CN114844897A CN114844897A (en) 2022-08-02
CN114844897B true CN114844897B (en) 2022-11-04

Family

ID=82575331

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210786504.5A Active CN114844897B (en) 2022-07-06 2022-07-06 Method and device for distributed dynamic adjustment of long connection service based on Internet of things

Country Status (1)

Country Link
CN (1) CN114844897B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109308221A (en) * 2018-08-02 2019-02-05 南京邮电大学 A kind of Nginx dynamic load balancing method based on WebSocket long connection

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8201219B2 (en) * 2007-09-24 2012-06-12 Bridgewater Systems Corp. Systems and methods for server load balancing using authentication, authorization, and accounting protocols
US9705800B2 (en) * 2012-09-25 2017-07-11 A10 Networks, Inc. Load distribution in data networks
CN102932444B (en) * 2012-10-29 2015-11-25 上海银商资讯有限公司 Load balancing module in finance real-time transaction system
US10135914B2 (en) * 2013-04-16 2018-11-20 Amazon Technologies, Inc. Connection publishing in a distributed load balancer
CN110099035B (en) * 2018-01-31 2022-04-12 上海甚术网络科技有限公司 Network advertisement data high-concurrency access service method
CN110417842B (en) * 2018-04-28 2022-04-12 北京京东尚科信息技术有限公司 Fault processing method and device for gateway server
CN109660466A (en) * 2019-02-26 2019-04-19 浪潮软件集团有限公司 A kind of more live load balance realizing methods towards cloud data center tenant
CN111447185B (en) * 2020-03-10 2023-07-28 平安科技(深圳)有限公司 Push information processing method and related equipment
CN111787066B (en) * 2020-06-06 2023-07-28 王科特 Internet of things data platform based on big data and AI

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109308221A (en) * 2018-08-02 2019-02-05 南京邮电大学 A kind of Nginx dynamic load balancing method based on WebSocket long connection

Also Published As

Publication number Publication date
CN114844897A (en) 2022-08-02

Similar Documents

Publication Publication Date Title
CN110602254B (en) Method, device and system for realizing load balance
US10757176B1 (en) Systems, methods, devices and arrangements for server load distribution
CN110557357B (en) Remote procedure call protocol self-adaption method, related device and server
CN113810438B (en) Service computing resource scheduling and requesting method, node equipment and terminal
CN110958281B (en) Data transmission method and communication device based on Internet of things
JP2015130199A (en) Enterprise client-server system and methods for providing web application support through distributed emulation of websocket communications
EP3032899B1 (en) Method and apparatus of allocating resources for terminal in wireless communication system
US11689646B2 (en) Network packet processing method and apparatus and network server
KR20170060118A (en) Managing classified network streams
CN114844897B (en) Method and device for distributed dynamic adjustment of long connection service based on Internet of things
CN115665162A (en) Intelligent shunting engine for gray scale release
US11595449B2 (en) Methods and apparatus for efficient load balancing among microservices and/or processing entities
CN110971639B (en) Message distribution method, message management system, server, and computer storage medium
CN117461303A (en) Improvements in and relating to multi-access edge computation
CN109995838A (en) Virtual content dispatching method, device, equipment and computer readable storage medium
CN114168312A (en) Distributed cluster load balancing method and device and storage medium
Dreibholz et al. Load distribution performance of the reliable server pooling framework
CN107483424B (en) Processing method and device of remote procedure call protocol
CN107196819B (en) Network connection method and system and computer readable storage medium
CN114268615B (en) Service processing method and system based on TCP connection
CN112272081B (en) Full-duplex stateful communication protocol method for communication between robot and server
CN112654021B (en) Method for communication between devices, related device and system
KR100868323B1 (en) Event Filtering System and Method Thereof
US20220060567A1 (en) Remote Procedure Call Between Entities in a Service Bus Communication System
CN114584566A (en) Data processing method, device and equipment based on message queue and storage medium

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