A method, device, equipment and medium for service deployment and inter-service communication
By separating business logic and communication logic in IoT security devices and combining service status for service deployment and path determination, the problems of resource waste and communication delay in microservice architecture are solved, and efficient resource utilization and communication optimization are achieved.
Patent Information
- Application Number
- CN202310346029.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2023-02-20
- Filing Date
- 2023-03-29
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2043-03-29
AI Technical Summary
In IoT security devices, the resource waste and communication delay problems caused by microservice architectures still occupy more resources and inefficient communications, especially when the traffic volume is low.
Separate the business logic and communication logic of cloud platform services, extract independent business layer and communication layer, deploy business services according to business conditions through the service layer, and determine the target sending path based on the current operating mode through the communication layer for data transmission.
It effectively avoids resource waste, improves communication efficiency, reduces costs, and optimizes resource consumption and communication delay.
Smart Images

Figure CN116389559B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security technology, and in particular to a service deployment and inter-service communication method, device, equipment and storage medium. Background Art
[0002] With the rapid development of IoT security devices and the explosive growth in device connections, the volume of security cloud platforms has also skyrocketed, significantly increasing the scale and cost of cloud platform deployments. One existing technology employs a microservices architecture, where each cloud platform service is independently developed and deployed. The system consists of multiple independently running microservices, with one service deployed per host or container. This approach can still consume significant resources even when platform traffic is low. Furthermore, since services interact entirely through call protocols, the call relationships and patterns must be carefully considered at the outset of service design to select the appropriate call protocol. Currently, the main microservice call protocols include synchronous protocols such as HTTP (Hypertext Transfer Protocol) and RPC (Remote Procedure Call), as well as asynchronous protocols such as AMQP (Advanced Message Queuing Protocol) and STOMP (Streaming Text Oriented Message Protocol). This results in significant communication latency, impacting the efficiency of inter-service communication. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a service deployment and inter-service communication method, apparatus, device, and storage medium that can effectively avoid the resource waste caused by occupying a large number of resources to deploy services even when the business volume is low when the cloud platform adopts a microservice architecture to deploy services, and improve communication efficiency. The specific solution is as follows:
[0004] In a first aspect, the present application provides a service deployment and inter-service communication method, which is applied to a security IoT cloud platform, including:
[0005] Separate the business logic and communication logic of cloud platform services and extract independent business and communication layers;
[0006] The cloud platform service is divided into several business services according to different business logics through the business layer, and the several business services are deployed accordingly based on the service operation mode combination corresponding to the current business status; the business services include registration center services;
[0007] When deployed business services communicate with each other, the communication layer determines the target sending path based on the preset path determination rule corresponding to the current operating mode of the first business service as the sending end, and uses the target sending path to send the target data to be sent in the first business service to the second business service as the receiving end.
[0008] Optionally, after deploying the plurality of business services based on the service operation mode combination corresponding to the current business status, the method further includes:
[0009] The deployed business service is started, and then a preset configuration file is read through the deployed business service to initialize itself using the read preset configuration file to obtain an initialized business service, and the initialized business service is registered with the registration center service.
[0010] Optionally, the deploying the plurality of business services based on a combination of service operation modes corresponding to the current business status includes:
[0011] If the current business status meets the first preset business stage condition, the plurality of business services are deployed based on the corresponding first service operation mode combination; the first service operation mode combination includes a multi-threaded mode;
[0012] If the current business status meets the second preset business stage condition, the plurality of business services are deployed based on the corresponding second service operation mode combination; the second service operation mode combination includes a multi-thread mode and a multi-process mode;
[0013] If the current business situation meets the third preset business stage condition, the several business services are deployed based on the corresponding third service operation mode combination; the third service operation mode combination includes multi-threaded mode, multi-process mode and multi-host / multi-container mode.
[0014] Optionally, determining the target sending path through the communication layer based on a preset path determination rule corresponding to the current operation mode of the first business service as the sending end includes:
[0015] The communication layer determines the current deployment location of the second business service based on a preset path determination rule corresponding to the current operation mode of the first business service as the sending end, and determines the target sending path according to the current deployment location.
[0016] Optionally, determining the current deployment location of the second business service based on a preset path determination rule corresponding to the current operation mode of the first business service as the sending end through the communication layer includes:
[0017] The communication layer sequentially searches, based on a first preset path determination rule corresponding to the current thread mode of the first business service as the sending end, whether the second business service is deployed in a global service list, whether it is deployed on the same host as the first business service, and whether it is deployed on the same local area network as the first business service, so as to determine the current deployment location of the second business service;
[0018] The global service list is a list for storing business services running in thread mode.
[0019] Optionally, sending the target data to be sent in the first business service to a second business service serving as a receiving end includes:
[0020] When the second business service is deployed in the global service list, sending the target data to be sent in the first business service to the cache queue of the second business service;
[0021] When the second business service and the first business service are deployed on the same host, sending the target data to be sent to the host listening address of the second business service;
[0022] When the second business service and the first business service are deployed in the same local area network, sending the target data to be sent to the local area network listening address of the second business service;
[0023] When the second business service is not deployed in the global service list and is not deployed on the same host and the same local area network as the first business service, the target data to be sent is sent to the public network listening address of the second business service.
[0024] Optionally, determining the current deployment location of the second business service based on a preset path determination rule corresponding to the current operation mode of the first business service as the sending end through the communication layer includes:
[0025] The communication layer determines the second business service based on a second preset path rule corresponding to the current process mode or host / container mode of the first business service as the sender, and sequentially searches whether the second business service is deployed on the same host as the first business service and whether it is deployed on the same local area network as the first business service to determine the current deployment location of the second business service.
[0026] In a second aspect, the present application provides a service deployment and inter-service communication device, which is applied to a security IoT cloud platform, including:
[0027] The logical layering module is used to separate the business logic and communication logic of cloud platform services and extract independent business layers and communication layers;
[0028] A service deployment module, configured to divide the cloud platform service into a plurality of business services according to different business logics through the business layer, and to deploy the plurality of business services accordingly based on a combination of service operation modes corresponding to the current business status; the business services include a registration center service;
[0029] The service communication module is used to determine the target sending path through the communication layer based on the preset path determination rules corresponding to the current operating mode of the first business service as the sending end when communicating between deployed business services, and use the target sending path to send the target data to be sent in the first business service to the second business service as the receiving end.
[0030] In a third aspect, the present application provides an electronic device, comprising:
[0031] Memory, used to store computer programs;
[0032] The processor is used to execute the computer program to implement the steps of the aforementioned service deployment and inter-service communication method.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the steps of the aforementioned service deployment and inter-service communication method.
[0034] It can be seen that in this application, the business logic and communication logic of the cloud platform service are separated, and independent business layers and communication layers are extracted; the cloud platform service is divided into several business services according to different business logics through the business layer, and corresponding service deployment is performed on the several business services based on the service operation mode combination corresponding to the current business status; the business service includes a registration center service; when the deployed business services communicate with each other, the target sending path is determined through the communication layer based on the preset path determination rule corresponding to the current operation mode of the first business service as the sending end, and the target data to be sent in the first business service is sent to the second business service as the receiving end using the target sending path. This application extracts the business layer and the communication layer from the platform service, and deploys several business services through the business layer based on the service operation mode combination corresponding to the current business status. In this way, it can effectively avoid the waste of resources caused by occupying more resources to deploy services when the business volume is low when the cloud platform adopts a microservice architecture. The communication layer determines the target sending path based on the preset path determination rules corresponding to the current operating mode of the first business service as the sending end, and sends the target data to be sent to the second business service as the receiving end. This effectively avoids the communication delay caused by the interaction between services only through calling protocols when the cloud platform adopts a microservice architecture, thereby improving communication efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0036] Figure 1 A flow chart of a service deployment and inter-service communication method provided in this application;
[0037] Figure 2 A schematic diagram of the internal architecture of a service provided for this application;
[0038] Figure 3 A diagram showing the relationship between a registration center service and various business services provided for this application;
[0039] Figure 4 A schematic diagram of service deployment and inter-service communication - multi-threaded mode provided for this application;
[0040] Figure 5 A schematic diagram of service deployment and inter-service communication - multi-process mode provided for this application;
[0041] Figure 6 A schematic diagram of service deployment and inter-service communication in multi-host / multi-container mode provided for this application;
[0042] Figure 7 A flow chart of a specific service deployment and inter-service communication method provided for this application;
[0043] Figure 8 A flow chart of inter-service communication provided for this application;
[0044] Figure 9 A flow chart of inter-service communication provided for this application;
[0045] Figure 10 A schematic diagram of the structure of a service deployment and inter-service communication device provided in this application;
[0046] Figure 11 This is a structural diagram of an electronic device provided in this application.
[0047] Specific implementation mode
[0048] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0049] When the existing technology adopts a microservice architecture, the system is composed of multiple independently running microservices, and one service is deployed on each host or container. In this way, even when the platform's business volume is low, more resources will still be occupied to deploy services. In addition, at the beginning of service design, it is necessary to consider the calling relationship and calling mode and select the appropriate calling protocol. Currently, microservices mainly interact with each other through calling protocols, which leads to a large delay in communication and affects the efficiency of communication between services. To this end, this application provides a service deployment and inter-service communication solution that can effectively avoid the waste of resources caused by the large amount of resources still occupied to deploy services when the cloud platform adopts a microservice architecture to deploy services even when the business volume is low, and improve communication efficiency.
[0050] See also Figure 1 As shown, an embodiment of the present invention discloses a service deployment and inter-service communication method, which is applied to a security Internet of Things cloud platform, including:
[0051] Step S11: Separate the business logic and communication logic of the cloud platform service, and extract independent business layers and communication layers.
[0052] Step S12: Divide the cloud platform service into several business services according to different business logics through the business layer, and perform corresponding service deployment on the several business services based on the service operation mode combination corresponding to the current business status; the business service includes a registration center service.
[0053] In this embodiment, after the cloud platform service is divided into several independent business services according to different business logics through the business layer, the corresponding service operation mode combination is determined in combination with the current business status, and the corresponding service deployment is performed based on the determined service operation mode combination. Figure 2 As shown, each of the business services includes two parts: the corresponding business logic and the communication logic. The communication logic includes the corresponding cache queue, TCP Socket (Transmission Control Protocol Socket), and UCP Socket (User Datagram Protocol Socket). The communication logic can be deployed independently with a single business service or deployed with multiple business services. Accordingly, based on the deployment situation, it can communicate with one or more business services. Among them, the registration center service is a special service among business services, such as Figure 3 As shown, the Registry Service receives information from all business services. Furthermore, when a business service terminates, the Registry Service is notified immediately. If the Registry Service detects an abnormality in a business service, it broadcasts the abnormality information and promptly removes the abnormal service, preventing other business services from communicating with it.
[0054] Furthermore, in this embodiment, the service deployment of the multiple business services based on a service operation mode combination corresponding to the current business status includes: if the current business status meets a first preset business stage condition, deploying the multiple business services based on a corresponding first service operation mode combination; the first service operation mode combination includes a multi-threaded mode; if the current business status meets a second preset business stage condition, deploying the multiple business services based on a corresponding second service operation mode combination; the second service operation mode combination includes a multi-threaded mode and a multi-process mode; if the current business status meets a third preset business stage condition, deploying the multiple business services based on a corresponding third service operation mode combination; the third service operation mode combination includes a multi-threaded mode, a multi-process mode, and a multi-host / multi-container mode. Each process has independent code and data space, a process contains multiple threads, each thread has an independent runtime stack and program counter, and thread switching overhead is low. Containers are a technology used to bundle an application and all its necessary files into a runtime environment. As a unit, a container can be easily moved and run on any operating system in any environment.
[0055] Combine Figure 4 、 Figure 5 、 Figure 6As shown, business services A and B, deployed in multi-threaded mode on host A, communicate via a cache queue. In this case, only a single host is required for deployment. Business services C and D, deployed in multi-process mode on host B, communicate via TCP / UDP sockets, resulting in low resource usage, high communication efficiency, and no bandwidth costs. Business services E and F, deployed in multi-host / container mode on hosts C and D, respectively, communicate via TCP / UDP sockets. In this embodiment, the aforementioned multiple service deployment methods achieve low resource usage and high communication efficiency. Hosts A, B, C, and D can be considered different hosts. In the early stages of a project, when business volume and load are low, services can be deployed on a minimal number of hosts using multi-threaded mode. Furthermore, when services must be deployed over the public network, different services communicate using a private TCP / UDP socket protocol. The cloud hosting service provider can improve inter-service communication efficiency and reduce bandwidth costs by setting up dedicated lines. During initialization, business services deployed in multi-threaded mode register themselves with the maintained global service list. As business volume and load increase, services can be split and run on multiple hosts as independent processes, hosts, or containers, achieving flexible deployment. Furthermore, by configuring multiple hosts to work in the same data center LAN mode through carrier configuration, communication latency and bandwidth costs can be further reduced, ensuring overall performance and cost advantages.
[0056] Furthermore, during actual service deployment, a single business service can run multiple instances in multi-threaded mode, multiple independent processes, or multiple independent hosts. For example, during initialization, a device access service can initialize one or more instances. When traffic is low, the access service can run in threaded mode alongside other services. Alternatively, the service can be initialized in a separate process to facilitate independent management (creating a service thread and calling the service initialization method). When traffic is high, the service can be run on separate independent hosts or on multiple hosts. These services are all registered with the central registration service.
[0057] Step S13: When the deployed business services communicate with each other, the communication layer determines the target sending path based on the preset path determination rule corresponding to the current operating mode of the first business service as the sending end, and uses the target sending path to send the target data to be sent in the first business service to the second business service as the receiving end.
[0058] In this embodiment, when deployed business services communicate with each other, the communication layer detects and determines the current deployment location of the second business service based on a preset path determination rule corresponding to the current operating mode of the first business service serving as the sender, and then determines the target transmission path based on the current deployment location. It should be understood that different transmission paths correspond to corresponding data transmission modes, including direct write transmission modes and transmission modes using TCP / UDP sockets.
[0059] In this embodiment, upon startup, a deployed business service performs corresponding initialization operations by reading a preset configuration file. Specifically, the deployed business service is started, then reads the preset configuration file, initializes itself using the preset configuration file, and registers the initialized business service with the registry service. It should be understood that during initialization, the registry service creates a socket (TCP / UDP socket) that listens on the port configured in the preset configuration file as a server. During initialization, the business service reads the registry service's service listening port from the preset configuration file and, acting as a client, sends a service registration message to the registry service's service listening port. The business service also has a corresponding service listening port, and creates a corresponding socket (TCP / UDP socket) by reading the listening port in the preset configuration file, which the server listens on. After initialization is complete, a registration request message is sent to the registry service based on the domain name information of the registry service read from the preset configuration file. The registration request message carries local operation status data, which includes but is not limited to online status, service name, WAN address, WAN port, LAN address, LAN port, supported data transmission type, real-time bandwidth and real-time resource occupancy information.
[0060] It is understood that when a business service sends a registration request message to a registration center service, the communication layer determines the corresponding target transmission path according to the aforementioned steps, and uses the target transmission path to send the registration request message to the receiving registration center service. After receiving the registration request message from the business service, the registration center service broadcasts the business service data contained in the registration request message. After receiving the business service data broadcast by the registration center service, other business services process the received data and pre-set rules, and determine the corresponding target transmission path according to the aforementioned steps to send connection requests to business services that require a connection. After each business service completes registration, it will also periodically send heartbeat messages to the registration center service to report real-time operating data. The registration center service then broadcasts this to each business service. Simultaneously, business services that have established communication connections will also periodically transmit heartbeat data. During the operation of a business service, data can also be sent to other business services that require communication by determining the corresponding target transmission path according to the aforementioned steps.
[0061] It can be seen that in the embodiment of the present application, the business logic and communication logic of the cloud platform service are separated, and independent business layers and communication layers are extracted; the cloud platform service is divided into several business services according to different business logics through the business layer, and the several business services are deployed accordingly based on the service operation mode combination corresponding to the current business status; the business service includes a registration center service; when the deployed business services communicate with each other, the target sending path is determined by the communication layer based on the preset path determination rule corresponding to the current operation mode of the first business service as the sender, and the target data to be sent in the first business service is sent to the second business service as the receiver using the target sending path. The present application extracts the business layer and the communication layer from the platform service, and deploys several business services based on the service operation mode combination corresponding to the current business status through the business layer. In this way, it can effectively avoid the waste of resources caused by occupying more resources to deploy services when the business volume is low when the cloud platform adopts a microservice architecture, and realizes flexible deployment based on the actual needs of different business stages, and realizes the optimization solution of resource consumption and communication efficiency, thereby saving costs while ensuring service quality. The communication layer determines the target sending path based on the preset path determination rules corresponding to the current operating mode of the first business service as the sending end, and sends the target data to be sent to the second business service as the receiving end. This effectively avoids the communication delay caused by the interaction between services only through calling protocols when the cloud platform adopts a microservice architecture, thereby improving communication efficiency.
[0062] As can be seen from the previous embodiment, when the present application performs inter-service communication, the communication layer determines the target sending path based on the corresponding preset path determination rules, and then uses the target sending path to send the target data to the second business service as the receiving end. To this end, this embodiment will now describe in detail the specific process of communication between business services. Figure 7 As shown, an embodiment of the present invention discloses a service deployment and inter-service communication method, which is applied to a security Internet of Things cloud platform, including:
[0063] Step S21: Separate the business logic and communication logic of the cloud platform service, and extract independent business layers and communication layers.
[0064] Step S22: Divide the cloud platform service into several business services according to different business logics through the business layer, and perform corresponding service deployment on the several business services based on the service operation mode combination corresponding to the current business status; the business service includes a registration center service.
[0065] Step S23: When deployed business services communicate with each other, the communication layer determines the rule based on the first preset path corresponding to the current thread mode of the first business service as the sending end, and sequentially searches whether the second business service as the receiving end is deployed in the global service list, whether it is deployed on the same host as the first business service, and whether it is deployed on the same local area network as the first business service, so as to determine the current deployment location of the second business service, determine the target sending path according to the current deployment location, and use the target sending path to send the target data to be sent in the first business service to the second business service; wherein, the global service list is a list for storing business services running in thread mode.
[0066] In this embodiment, when the current operating mode of the first business service as the sending end is the thread mode, the communication layer sequentially searches based on the first preset path determination rule whether the second business service as the receiving end is deployed in the global service list, whether it is deployed on the same host as the first business service, and whether it is deployed on the same local area network as the first business service, so as to determine the current deployment location of the second business service, and use the target sending path determined based on the deployment location to send the target data to be sent to the second business service.
[0067] Combine Figure 8As shown, in a first embodiment, when the second business service is deployed in the global service list, it indicates that the second business service operates in thread mode. In this case, data transmission is completed by sending the target data to be sent in the first business service to the cache queue of the second business service without sending it over the network. The second business service then asynchronously reads the target data to be sent from the cache queue to complete data reception. In a second embodiment, when the second business service and the first business service are deployed on the same host, it indicates that the second business service operates in process mode. The target data to be sent is sent to the host listening address of the second business service using the local TCP / UDP socket method. In a third embodiment, when the second business service and the first business service are deployed on the same local area network, it indicates that the second business service operates in host mode. The target data to be sent is sent to the local area network listening address of the second business service using the local area network TCP / UDP socket method. In a fourth embodiment, when the second business service is not deployed in the global service list and is not deployed on the same host and the same local area network as the first business service, it indicates that the second business service operates in public host mode. The target data to be sent is sent to the public network listening address of the second business service using the public network TCP / UDP socket method. In the above scheme, the method of directly writing to the second business service buffer queue is the most efficient and has no bandwidth fees; the communication between services in a multi-process mode on the same host uses the local TCP / UDP Socket method, which is highly efficient and has no bandwidth fees; the service communication between hosts on the same LAN uses the LAN TCP / UDP Socket method, which is highly efficient and has no bandwidth fees; the service communication between hosts on the public network uses the public network TCP / UDP Socket method, which is relatively efficient and has bandwidth fees. The sending efficiency of the above-mentioned multiple communication methods becomes lower in turn, and at the same time, sending on the public network requires paying bandwidth fees. Therefore, this embodiment designs the above-mentioned methods to improve efficiency and reduce costs.
[0068] Step S24: When the deployed business services communicate with each other, the communication layer determines the second business service as the receiving end based on the second preset path determination rule corresponding to the current process mode or host / container mode of the first business service as the sending end, and sequentially searches to determine whether the second business service as the receiving end is deployed on the same host and the same local area network as the first business service, so as to determine the current deployment location of the second business service, determine the target sending path according to the current deployment location, and use the target sending path to send the target data to be sent in the first business service to the second business service.
[0069] In this embodiment, when the current operation mode of the first business service as the sending end is process mode or host / container mode, combined with Figure 9 As shown, by successively searching whether the second business service as the receiving end is deployed on the same host as the first business service and whether it is deployed on the same local area network as the first business service, it is determined in turn whether the second business service is running in the mode of a local process and whether it is running in the mode of a local area network host. Based on the judgment result and in combination with the relevant content disclosed in step S23, the target data to be sent is sent to the second business service.
[0070] Among them, the specific processes of the above-mentioned steps S21 and S22 can refer to the corresponding contents disclosed in the above-mentioned embodiments, and will not be repeated here.
[0071] It can be seen that in the embodiment of the present application, when deployed business services communicate with each other, the present embodiment performs a corresponding search operation on the second business service as the receiving end based on the first preset path determination rule or the second preset path determination rule corresponding to the current operating mode of the first business service as the sending end through the communication layer, determines the deployment location of the second business service based on the search result, and sends the target data to be sent to the second business service through the target sending path corresponding to the deployment location by directly writing into the cache queue or using TCP / UDP Socket. In this way, communication efficiency can be effectively improved and costs can be reduced.
[0072] See also Figure 10 As shown, the embodiment of the present application also discloses a service deployment and inter-service communication device, which is applied to the security Internet of Things cloud platform, including:
[0073] The logical layering module 11 is used to separate the business logic and communication logic of the cloud platform service and extract independent business layers and communication layers;
[0074] A service deployment module 12 is configured to divide the cloud platform service into a plurality of business services according to different business logics through the business layer, and to deploy the plurality of business services accordingly based on a combination of service operation modes corresponding to the current business status; the business services include a registration center service;
[0075] The service communication module 13 is used to determine the target sending path through the communication layer based on the preset path determination rules corresponding to the current operating mode of the first business service as the sending end when communicating between deployed business services, and use the target sending path to send the target data to be sent in the first business service to the second business service as the receiving end.
[0076] Among them, for more specific working processes of the above modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0077] It can be seen that the embodiment of the present application separates the business logic and communication logic of the cloud platform service, and extracts independent business layers and communication layers; the cloud platform service is divided into several business services according to different business logics through the business layer, and the several business services are deployed accordingly based on the service operation mode combination corresponding to the current business status; the business service includes a registration center service; when the deployed business services communicate with each other, the target sending path is determined through the communication layer based on the preset path determination rule corresponding to the current operation mode of the first business service as the sending end, and the target data to be sent in the first business service is sent to the second business service as the receiving end using the target sending path. The present application extracts the business layer and the communication layer from the platform service, and deploys several business services based on the service operation mode combination corresponding to the current business status through the business layer. In this way, it can effectively avoid the waste of resources caused by occupying more resources to deploy services when the business volume is low when the cloud platform adopts a microservice architecture. The communication layer determines the target sending path based on the preset path determination rules corresponding to the current operating mode of the first business service as the sending end, and sends the target data to be sent to the second business service as the receiving end. This effectively avoids the communication delay caused by the interaction between services only through calling protocols when the cloud platform adopts a microservice architecture, thereby improving communication efficiency.
[0078] In some specific embodiments, the service deployment and inter-service communication device may further include:
[0079] The service registration unit is used to start the deployed business service, then read the preset configuration file through the deployed business service, initialize itself using the read preset configuration file to obtain the initialized business service, and register the initialized business service with the registration center service.
[0080] In some specific embodiments, the service deployment module 12 may specifically include:
[0081] A first service deployment unit is configured to deploy the plurality of business services based on a corresponding first service operation mode combination if the current business status satisfies a first preset business stage condition; the first service operation mode combination includes a multi-threaded mode;
[0082] a second service deployment unit, configured to deploy the plurality of business services based on a corresponding second service operation mode combination if the current business status satisfies a second preset business stage condition; the second service operation mode combination including a multi-thread mode and a multi-process mode;
[0083] The third service deployment unit is used to deploy the several business services based on the corresponding third service operation mode combination if the current business status meets the third preset business stage condition; the third service operation mode combination includes multi-threaded mode, multi-process mode and multi-host / multi-container mode.
[0084] In some specific embodiments, the service communication module 13 may further include:
[0085] A path determination unit is used to determine the current deployment location of the second business service based on a preset path determination rule corresponding to the current operating mode of the first business service as the sending end through the communication layer, and determine the target sending path according to the current deployment location.
[0086] In some specific embodiments, the service deployment and inter-service communication device may specifically include:
[0087] The first location determination unit is used to sequentially search, through the communication layer and based on a first preset path determination rule corresponding to the current thread mode of the first business service as the sending end, whether the second business service is deployed in a global service list, whether it is deployed on the same host as the first business service, and whether it is deployed on the same local area network as the first business service, so as to determine the current deployment location of the second business service; wherein the global service list is a list for storing business services running in thread mode.
[0088] In some specific embodiments, the service deployment and inter-service communication device may specifically include:
[0089] a first data sending unit, configured to send the target data to be sent in the first business service to the cache queue of the second business service when the second business service is deployed in the global service list;
[0090] a second data sending unit, configured to send the target data to be sent to a host listening address of the second business service when the second business service and the first business service are deployed on the same host;
[0091] a third data sending unit, configured to send the target data to be sent to the local area network listening address of the second business service when the second business service and the first business service are deployed in the same local area network;
[0092] The fourth data sending unit is used to send the target data to be sent to the public network listening address of the second business service when the second business service is not deployed in the global service list and is not deployed on the same host and the same local area network as the first business service.
[0093] In some specific embodiments, the service deployment and inter-service communication device may specifically include:
[0094] The second location determination unit is used to sequentially search, through the communication layer, whether the second business service is deployed on the same host and the same local area network as the first business service based on a second preset path determination rule corresponding to the current process mode or host / container mode of the first business service as the sending end, to determine the current deployment location of the second business service.
[0095] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 11 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.
[0096] Figure 11 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the service deployment and inter-service communication method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0097] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0098] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc. The storage mode can be temporary storage or permanent storage.
[0099] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs that can be used to implement the service deployment and inter-service communication methods disclosed in any of the aforementioned embodiments and executed by the electronic device 20, the computer program 222 can further include computer programs that can be used to perform other specific tasks.
[0100] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when executed by a processor, the computer program implements the aforementioned disclosed method for service deployment and inter-service communication. The specific steps of this method can be referred to the corresponding contents disclosed in the aforementioned embodiments and will not be repeated here.
[0101] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0102] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software mode depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0103] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0104] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0105] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used in this article to illustrate the principles and implementation modes of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for service deployment and inter-service communication, characterized in that: Applied to the security IoT cloud platform, including: Separate the business logic and communication logic of cloud platform services and extract independent business and communication layers; The cloud platform service is divided into several business services according to different business logics through the business layer, and the several business services are deployed accordingly based on the service operation mode combination corresponding to the current business status; the business services include registration center services; When deployed business services communicate with each other, the communication layer determines a target sending path based on a preset path determination rule corresponding to the current operating mode of a first business service as a sender, and uses the target sending path to send target data in the first business service to a second business service as a receiver; the current operating mode is thread mode, process mode, or host / container mode; The deploying the plurality of business services based on a combination of service operation modes corresponding to the current business status includes: If the current business status meets the first preset business stage condition, the plurality of business services are deployed based on the corresponding first service operation mode combination; the first service operation mode combination includes a multi-threaded mode; If the current business status meets the second preset business stage condition, the plurality of business services are deployed based on the corresponding second service operation mode combination; the second service operation mode combination includes a multi-thread mode and a multi-process mode; If the current business status meets the third preset business stage condition, the plurality of business services are deployed based on a corresponding third service operation mode combination; the third service operation mode combination includes a multi-thread mode, a multi-process mode, and a multi-host / multi-container mode; The first preset service stage condition, the second preset service stage condition and the third preset service stage condition are used to represent three different magnitudes of service volume and load size, respectively.
2. The service deployment and inter-service communication method according to claim 1, characterized in that: After deploying the plurality of business services based on the service operation mode combination corresponding to the current business status, the method further includes: The deployed business service is started, and then a preset configuration file is read through the deployed business service to initialize itself using the read preset configuration file to obtain an initialized business service, and the initialized business service is registered with the registration center service.
3. The service deployment and inter-service communication method according to claim 1 or 2, characterized in that: The determining, by the communication layer, a target sending path based on a preset path determination rule corresponding to a current operating mode of the first business service as the sending end includes: The communication layer determines the current deployment location of the second business service based on a preset path determination rule corresponding to the current operation mode of the first business service as the sending end, and determines the target sending path according to the current deployment location.
4. The service deployment and inter-service communication method according to claim 3, characterized in that: The determining, by the communication layer, a current deployment location of the second business service based on a preset path determination rule corresponding to a current operation mode of the first business service as a sending end includes: The communication layer sequentially searches, based on a first preset path determination rule corresponding to the current thread mode of the first business service as the sending end, whether the second business service is deployed in a global service list, whether it is deployed on the same host as the first business service, and whether it is deployed on the same local area network as the first business service, so as to determine the current deployment location of the second business service; The global service list is a list for storing business services running in thread mode.
5. The service deployment and inter-service communication method according to claim 4, characterized in that: The sending of the target data to be sent in the first business service to the second business service as a receiving end includes: When the second business service is deployed in the global service list, sending the target data to be sent in the first business service to the cache queue of the second business service; When the second business service and the first business service are deployed on the same host, sending the target data to be sent to the host listening address of the second business service; When the second business service and the first business service are deployed in the same local area network, sending the target data to be sent to the local area network listening address of the second business service; When the second business service is not deployed in the global service list and is not deployed on the same host and the same local area network as the first business service, the target data to be sent is sent to the public network listening address of the second business service.
6. The service deployment and inter-service communication method according to claim 3, characterized in that: The determining, by the communication layer, a current deployment location of the second business service based on a preset path determination rule corresponding to a current operation mode of the first business service as a sending end includes: The communication layer determines the second business service based on a second preset path rule corresponding to the current process mode or host / container mode of the first business service as the sender, and sequentially searches whether the second business service is deployed on the same host as the first business service and whether it is deployed on the same local area network as the first business service to determine the current deployment location of the second business service.
7. A service deployment and inter-service communication device, characterized in that: Applied to the security IoT cloud platform, including: The logical layering module is used to separate the business logic and communication logic of cloud platform services and extract independent business layers and communication layers; A service deployment module, configured to divide the cloud platform service into a plurality of business services according to different business logics through the business layer, and to deploy the plurality of business services accordingly based on a combination of service operation modes corresponding to the current business status; the business services include a registration center service; a service communication module, configured to, when deployed business services communicate with each other, determine a target sending path through the communication layer based on a preset path determination rule corresponding to the current operating mode of a first business service as a sender, and send target data to be sent in the first business service to a second business service as a receiver using the target sending path; the current operating mode being thread mode, process mode, or host / container mode; The service deployment module includes: A first service deployment unit is configured to deploy the plurality of business services based on a corresponding first service operation mode combination if the current business status satisfies a first preset business stage condition; the first service operation mode combination includes a multi-threaded mode; a second service deployment unit, configured to deploy the plurality of business services based on a corresponding second service operation mode combination if the current business status satisfies a second preset business stage condition; the second service operation mode combination including a multi-thread mode and a multi-process mode; The third service deployment unit is used to deploy the several business services based on the corresponding third service operation mode combination if the current business status meets the third preset business stage condition; the third service operation mode combination includes multi-threaded mode, multi-process mode and multi-host / multi-container mode; wherein the first preset business stage condition, the second preset business stage condition and the third preset business stage condition are used to respectively represent three different business volume sizes and load size magnitudes.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the service deployment and inter-service communication method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that Used to store a computer program, which, when executed by a processor, implements the service deployment and inter-service communication method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Communication method and system for modern distributed micro-service architecture
CN111245925A
Service deployment and inter-service communication method, device, equipment and medium
CN115834670A