Disclosure of Invention
The invention provides a service self-adaptive access method, a service self-adaptive access device, electronic equipment and a storage medium, which are used for solving the problems that in the prior art, the front end directly interacts with an edge node, so that the front end has large calculation amount and poor user experience is brought to a front end user.
The invention provides a service self-adaptive access method, which comprises the following steps:
determining the IP address of the front end according to the service request of the front end;
taking the IP address of the front end as a parameter for communicating with a distributed database, and acquiring an available service list;
and selecting a target service from the available service list, and returning the source information of the target service to the front end.
According to a service adaptive access method provided by the present invention, before the step of determining an IP address of a head end according to a service request of the head end, the method further includes:
under the condition that the change of the current IP address of the front end is detected, service migration is triggered;
and acquiring a service request sent by the front end.
According to the service adaptive access method provided by the invention, the step of selecting the target service from the available service list specifically comprises the following steps:
according to the IP address of the front end, carrying out network segment matching on each service in the available service list, and determining the local service in the available service list;
selecting local services with bandwidth smaller than the residual bandwidth threshold value to obtain candidate services;
and taking the candidate service with the highest service quality parameter as a target service.
According to the service adaptive access method provided by the invention, the step of selecting the target service from the available service list specifically comprises the following steps:
determining the different-place service in the service list under the condition that the network segment matching is carried out on each service in the available service list according to the IP address of the front end and the local service cannot be found;
selecting a remote service with the bandwidth smaller than the residual bandwidth threshold value to obtain a candidate service;
and taking the candidate service with the highest service quality parameter as a target service.
According to a service adaptive access method provided by the present invention, after the step of obtaining an available service list, the method further comprises:
triggering service degradation if the bandwidth of all services in the list of available services exceeds a remaining bandwidth threshold;
and sending a service degradation instruction to the front end of the service agent, and then acquiring a degradation service request sent by the front end of the service agent.
According to a service adaptive access method provided by the present invention, after the step of obtaining a downgraded service request sent by a front end of a service agent, the method further includes:
determining to acquire a front-end IP address of a service agent according to the degraded service request;
the front-end IP address of the service agent is used as a parameter for communicating with a distributed database to obtain a degradation available service list;
according to the front-end IP address of the service agent, carrying out network segment matching on each degradation service in the degradation available service list, and determining a local degradation service;
selecting local degradation service with bandwidth smaller than the per-person residual bandwidth threshold value to obtain candidate degradation service;
and taking the candidate degraded service with the highest service quality parameter as the target degraded service.
According to the service adaptive access method provided by the invention, the step of communicating the IP address of the front end as a parameter for communicating with a distributed database to obtain an available service list specifically comprises the following steps:
the IP address of the front end is used as a parameter for communicating with a distributed database to carry out communication, and an agent service name is obtained;
and taking the proxy service name as a parameter for communicating with a distributed database to obtain an available service list.
The invention also provides a service self-adaptive access device, which comprises:
the determining module is used for determining the IP address of the front end according to the service request of the front end;
the acquisition module is used for taking the IP address of the front end as a parameter for communication with a distributed database and acquiring an available service list;
and the service access module is used for selecting a target service from the available service list and returning the source information of the target service to the front end.
The present invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of any of the above-mentioned service adaptive access methods when executing the program.
The invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the service adaptive access method as described in any of the above.
According to the service self-adaptive access method, the service self-adaptive access device, the electronic equipment and the storage medium, the service agent is added between the front end and the edge network node, so that the problem that the edge network node cannot provide services is solved, a new edge network node is searched through the service agent to provide the services, and the service agent selects the target service in the available service list, so that the service request of the front end can be guaranteed. The invention realizes a plurality of operation processes of the original front end and the edge node by the service agent, thereby realizing the transparent access which is not sensed by the user and effectively improving the use experience of the user using the front end.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present 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.
The Service self-adaptive access method described in the present invention is based on a Service-Oriented Architecture (SOA), and based on a Service agent in an edge network environment, the Service agent realizes transparent access to services, and can realize Service self-adaptive adjustment functions such as Service migration and Service degradation.
Fig. 1 is a schematic flow chart of a service adaptive access method provided by the present invention, as shown in fig. 1, including:
step S1, determining the IP address of the front end according to the service request of the front end;
specifically, the front end described in the present invention is a front end relative to an edge service network (background), and the front end may specifically refer to a corresponding terminal device that obtains a service or content from the edge network, and may specifically refer to a smart phone, a tablet computer, or a computer device.
For example, for a streaming system, the front end may specifically obtain a streaming connection from a service in the edge network, and play the streaming.
The service request in the present application may specifically be a data request, such as an http request, or may also be a computation request.
The service in this application specifically refers to a function provided by an edge node in an edge network, for example, a video link provided by the edge node, or a computing service provided by the edge node.
Step S2, using the front end IP address as the parameter of communication with the distributed database, and obtaining the available service list;
the distributed database described in the present invention stores services provided by each node in the distributed network.
The invention takes the IP address of the front end as the parameter of communication with the distributed database, and can acquire the service related to the service request of the front end in the distributed database through the IP address, thereby effectively acquiring the related service in the distributed database with huge amount.
The available service list in the present application includes a plurality of services capable of responding to a service request of the front end.
Step S3, selecting a target service from the available service list, and returning source information of the target service to the front end.
The source information of the target service in the present invention specifically refers to source information for pointing to a node function in an edge network, such as a URL link.
Specifically, when the target service is selected from the available service list, the service with the optimal service quality index in the available service list is selected under the constraint of the service agent bandwidth, because the higher the service quality index is, the better the service can be provided.
That is to say, in the present application, in the available service list, the optimal service satisfying the bandwidth constraint is selected and returned to the front end, so that the front end can obtain a better service.
According to the method and the device, the service agent is added between the front end and the nodes of the edge network, so that the problem that the nodes of the edge network cannot provide services is solved, a new edge network node is searched through the service agent to provide the services, and the service agent selects the target service in the available service list, so that the service request of the front end can be guaranteed. The invention realizes a plurality of operation processes of the original front end and the edge node by the service agent, thereby realizing the transparent access which is not sensed by the user and effectively improving the use experience of the user using the front end.
Optionally, before the step of determining the IP address of the front end according to the service request of the front end, the method further includes:
under the condition that the change of the current IP address of the front end is detected, service migration is triggered;
and acquiring a service request sent by the front end.
Specifically, the front end and the service agent in the invention establish connection through the websocket, and the service agent can realize real-time detection of the IP address of the front end through the websocket.
In the invention, under the condition that the change of the current IP address of the front end is detected, the reason for triggering the service migration is that the front end often has mobility, for example, an intelligent mobile terminal such as a smart phone, and the network environment of the front end often changes along with the movement of the front end, at this time, the changed network environment is likely to be incapable of bearing the original service, and at this time, the service needs to be adaptively adjusted, so that the service is continuously adaptively adjusted to a new network environment.
And whether the network environment of the front end changes or not is detected, and the most effective mode is to detect whether the network segment of the front end changes or not.
And after detecting that the IP address of the front end changes, indicating the front end to resend the service request and determining new service.
Optionally, the step of selecting the target service from the available service list specifically includes:
according to the IP address of the front end, carrying out network segment matching on each service in the available service list, and determining the local service in the available service list;
selecting local services with bandwidth smaller than the residual bandwidth threshold value to obtain candidate services;
and taking the candidate service with the highest service quality parameter as a target service.
The step of selecting a target service from the available service list specifically includes:
determining the different-place service in the service list under the condition that the network segment matching is carried out on each service in the available service list according to the IP address of the front end and the local service cannot be found;
selecting a remote service with the bandwidth smaller than the residual bandwidth threshold value to obtain a candidate service;
and taking the candidate service with the highest service quality parameter as a target service.
Specifically, the general expression of the Service described in the present invention is Service (name, range, para).
Wherein, name represents the service name, range represents the subnet frequency band that this service belongs to, the format is: IP/subnet mask, para denotes quality of service parameter, the larger para the better the quality of service can be provided.
The service agent firstly traverses the available service list, carries out network segment matching on each service in the available service list, takes the service in the same network segment with the front end IP address as a local service, and takes the service in different network segments with the front end IP address as a remote service.
Because the local service can provide service more quickly than the long-distance service, the invention can preferentially select target service from the local service, only if the local service has no proper service, the invention can select service from long-distance service, and if no service meeting the requirement exists in the local service and long-distance service, the invention can report error.
The residual bandwidth threshold described in the present invention refers to a difference between a maximum bandwidth that can be loaded by the service agent and a bandwidth already occupied by a front end currently connected to the service agent.
The remaining bandwidth threshold is the maximum bandwidth capacity that the current service agent can bear, and the quality of service parameter in the service refers to the average bandwidth that the service needs to provide service for a user, and it can be known from the quality of service parameter that the total bandwidth that the service needs to occupy when accessing, if the bandwidth that the service needs exceeds the remaining bandwidth threshold, it is indicated that the service is unavailable, and only the service whose bandwidth that the service needs is less than the remaining bandwidth threshold is available.
Therefore, the local service with the bandwidth smaller than the threshold of the residual bandwidth is selected to obtain the candidate service, and correspondingly, the higher the service quality index is, the better the service quality is, so that the candidate service with the highest service quality parameter in the candidate services is selected as the target service.
Through the mode of service migration in this application, realized under the condition that the front end IP address changes, can carry out adaptive adjustment to the service to guarantee that the function of front end obtains normal realization, and, through the process of many rounds of screening in this application, probably guarantee that the service of screening can provide high-quality service as far as on the basis of guaranteeing that the service normally works, can effectively guarantee front end user's user experience.
Optionally, after the step of obtaining the available service list, the method further includes:
triggering service degradation if the bandwidth of all services in the list of available services exceeds a remaining bandwidth threshold;
and sending a service degradation instruction to the front end of the service agent, and then acquiring a degradation service request sent by the front end of the service agent.
Optionally, after the step of obtaining the downgrade service request sent by the front end of the service agent, the method further includes:
determining to acquire a front-end IP address of a service agent according to the degraded service request;
the front-end IP address of the service agent is used as a parameter for communicating with a distributed database to obtain a degradation available service list;
according to the front-end IP address of the service agent, carrying out network segment matching on each degradation service in the degradation available service list, and determining a local degradation service;
selecting local degradation service with bandwidth smaller than the per-person residual bandwidth threshold value to obtain candidate degradation service;
and taking the candidate degraded service with the highest service quality parameter as the target degraded service.
Specifically, under the condition that the bandwidth of all services in the available service list exceeds the remaining bandwidth threshold, it indicates that the services cannot be provided according to the original service quality, and when the service quality and the availability face selection, the present invention preferentially ensures the service availability, so that the present invention needs to perform service degradation on all front ends connected to the service broker to ensure that the services are provided for the front ends.
The invention needs to send a service degradation instruction for a part of front ends connected with the service agent, thereby determining the service with lower occupied bandwidth for the part of front ends again.
Specifically, the per-person remaining bandwidth threshold described in the present invention refers to a bandwidth threshold that the service agent can equally distribute to each front end, that is, the maximum bandwidth that each front end can occupy, determined according to the total number of the front ends to which the service agent is currently connected and the bandwidth threshold that the service agent can bear.
The service agent described in the invention firstly traverses the available service list, matches each service in the available service list with network segments, takes the service in the same network segment with the front end IP address as a local service, and takes the service in different network segments with the front end IP address as a remote service.
Because the local service can provide service more quickly than the long-distance service, the invention can preferentially select target service from the local service, only if the local service has no proper service, the invention can select service from long-distance service, and if no service meeting the requirement exists in the local service and long-distance service, the invention can report error.
And selecting local services with bandwidth smaller than the per-person residual bandwidth threshold value to obtain candidate services, wherein correspondingly, the higher the service quality index is, the better the service quality is, and therefore, the candidate service with the highest service quality parameter in the candidate services is selected as the target service.
The invention solves the problem that the edge network node can not provide service by adding the service agent between the front end and the edge network node, searches a new edge network node to provide service through the service agent, and selects the target service in the available service list through the service agent, thereby ensuring that the service request of the front end can be ensured. The invention realizes a plurality of operation processes of the original front end and the edge node by the service agent, thereby realizing the transparent access which is not sensed by the user and effectively improving the use experience of the user using the front end.
Optionally, fig. 2 is a schematic structural diagram of a basic service agent system provided by the present invention, and as shown in fig. 2, the system includes a front end, a service agent, a distributed database, and a real service in an edge network; the method takes a streaming media playing service as an example, and deploys the streaming media service on a certain node of a server in a nginx-http-flv-module mode to push a video stream; opening a front-end interface written based on flv.js on a browser supporting Media Source Extensions, wherein the front-end interface comprises a service display module (namely a video player with an empty service Source), and the service display module calls a service Source acquisition module and sends an http request to a background database communication module to acquire video Source information; after monitoring and receiving the http request, the database communication module firstly analyzes the IP information of a sender, then takes the IP information as a parameter for communicating with the distributed database to obtain an agent service name, and then takes the agent service name as a parameter for communicating with the distributed database to obtain an available service list; defaulting to take the first service in the available service list as a service to be provided, taking the service name of the first service as a parameter for communicating with the service, sending an http request to the corresponding service through a real service communication module, and acquiring required service source information and returning the acquired service source information to the front end; the front end plays the video stream normally and displays the service source information in log.
Fig. 3 is a schematic structural diagram of the service migration system provided in the present invention, and as shown in fig. 3, streaming media services are deployed on nodes of two servers in an nginx-http-flv-module manner to respectively push video streams; opening a front-end interface written in flv.js on a browser supporting Media Source Extensions, establishing connection with a websocket of a background, wherein the front-end interface comprises a service display module (namely a video player with an empty service Source), calling a service Source switching module, and sending an http request to a database communication module of the background to acquire video Source information; except for the first connection, the websocket module in the background automatically calculates and stores the per-capita bandwidth which can be acquired at the moment whenever a new connection is established, and automatically sends a request for updating a video source to the front end; after monitoring and receiving the http request, the database communication module firstly analyzes the IP information of the sender, then takes the IP information as a parameter for communicating with the distributed database to obtain an agent service name, and then takes the agent service name as a parameter for communicating with the distributed database to obtain an available service list.
The general representation form of the service is
Service(name,range,para)
Wherein, name represents the service name, range represents the subnet frequency band that this service belongs to, the format is: IP/subnet mask, para denotes quality of service parameter, the larger para the better the quality of service can be provided.
The optimal service selection module firstly traverses the available service list, matches network segments of each service, selects local services with parameters which are not larger than the highest quality of the service quality parameters and are stored in the websocket, establishes a different-place service list, selects services with the highest quality meeting requirements at different places if the service does not exist, and reports an error if the service does not exist; the real service communication module takes the selected optimal service as a service to be provided, sends an http request to the corresponding service by taking the service name of the optimal service as a parameter for service communication, acquires the required service source information and returns the service source information to the front end; the front end normally plays the video stream and displays the service source information in the log; at a certain moment, the IP of the front end is changed, a user can click a button to call the service source switching module, the process is repeated, the front end normally plays the video stream, and the migrated service source information is displayed in the log.
Fig. 4 is a schematic structural diagram of a service downgrading system provided by the present invention, and as shown in fig. 4, streaming media services are deployed on nodes of two servers in an nginx-http-flv-module manner to respectively push video streams. A front-end interface written in flv.js is opened on a browser supporting Media Source Extensions, and connection is established with a websocket in the background, wherein the front-end interface comprises a service presentation module (namely a video player with an empty service Source), and the service presentation module calls a service Source switching module and sends an http request to a database communication module in the background to acquire video Source information. Except for the first connection, the websocket module in the background automatically calculates and stores the per-capita bandwidth which can be acquired at the moment whenever a new connection is established, and automatically sends a request for updating a video source to the front end; after monitoring and receiving the http request, the database communication module firstly analyzes the IP information of the sender, then takes the IP information as a parameter for communicating with the distributed database to obtain an agent service name, and then takes the agent service name as a parameter for communicating with the distributed database to obtain an available service list.
The general representation form of the service is
Service(name,range,para)
Wherein, name represents the service name, range represents the subnet frequency band that this service belongs to, the format is: IP/subnet mask, para denotes quality of service parameter, the larger para the better the quality of service can be provided. The optimal service selection module firstly traverses the available service list, matches network segments of all services, selects local services with parameters which are not larger than the highest quality of the service quality parameters and are stored in the websocket, establishes a different-place service list, selects services with the highest quality meeting requirements in different places if the service quality parameters do not exist, and reports an error if the service quality parameters do not exist. The real service communication module takes the selected optimal service as a service to be provided, sends an http request to the corresponding service by taking the service name of the optimal service as a parameter for service communication, acquires the required service source information and returns the service source information to the front end; the front end plays the video stream normally and displays the service source information in log. (ii) a The action of sending the service request is repeated for a plurality of times, the front end normally plays the video stream, and the current service source information is displayed in the log.
Fig. 5 is a schematic diagram of a service adaptive access device provided by the present invention, as shown in fig. 5, including: a determining module 510, an obtaining module 520 and a service access module 530; the determining module 510 is configured to determine an IP address of the front end according to the service request of the front end; the obtaining module 520 is configured to obtain an available service list by using the IP address of the front end as a parameter for communicating with a distributed database; the service access module 530 is configured to select a target service from the available service list, and return source information of the target service to the front end.
More specifically, the apparatus further includes a service migration module, where the service migration module is specifically configured to trigger service migration when a change in a current IP address of the front end is detected;
and acquiring a service request sent by the front end.
The service migration module is specifically further configured to perform network segment matching on each service in the available service list according to the IP address of the front end, and determine a local service in the available service list;
selecting local services with bandwidth smaller than the residual bandwidth threshold value to obtain candidate services;
and taking the candidate service with the highest service quality parameter as a target service.
The service access module is specifically used for determining the remote service in the service list under the condition that the local service cannot be found by performing network segment matching on each service in the available service list according to the IP address of the front end;
selecting a remote service with the bandwidth smaller than the residual bandwidth threshold value to obtain a candidate service;
and taking the candidate service with the highest service quality parameter as a target service.
The service access module is specifically further configured to trigger service degradation when bandwidths of all services in the available service list exceed a remaining bandwidth threshold;
and sending a service degradation instruction to the front end of the service agent, and then acquiring a degradation service request sent by the front end of the service agent.
The method comprises the following steps:
determining to acquire a front-end IP address of a service agent according to the degraded service request;
the front-end IP address of the service agent is used as a parameter for communicating with a distributed database to obtain a degradation available service list;
according to the front-end IP address of the service agent, carrying out network segment matching on each degradation service in the degradation available service list, and determining a local degradation service;
selecting local degradation service with bandwidth smaller than the residual bandwidth threshold value to obtain candidate degradation service;
and taking the candidate degraded service with the highest service quality parameter as the target degraded service.
The acquisition module is specifically used for communicating the IP address of the front end as a parameter for communicating with a distributed database to obtain an agent service name;
and taking the proxy service name as a parameter for communicating with a distributed database to obtain an available service list.
The invention solves the problem that the edge network node can not provide service by adding the service agent between the front end and the edge network node, searches a new edge network node to provide service through the service agent, and selects the target service in the available service list through the service agent, thereby ensuring that the service request of the front end can be ensured. The invention realizes a plurality of operation processes of the original front end and the edge node by the service agent, thereby realizing the transparent access which is not sensed by the user and effectively improving the use experience of the user using the front end.
Fig. 6 is a schematic physical structure diagram of an electronic device provided in the present invention, and as shown in fig. 6, the electronic device may include: a processor (processor)610, a communication Interface (Communications Interface)620, a memory (memory)630 and a communication bus 640, wherein the processor 610, the communication Interface 620 and the memory 630 communicate with each other via the communication bus 640. The processor 610 may invoke logic instructions in the memory 630 to perform a service adaptive access method comprising: determining the IP address of the front end according to the service request of the front end; taking the IP address of the front end as a parameter for communicating with a distributed database, and acquiring an available service list; and selecting a target service from the available service list, and returning the source information of the target service to the front end.
In addition, the logic instructions in the memory 630 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the service adaptive access method provided by the above methods, the method comprising: determining the IP address of the front end according to the service request of the front end; taking the IP address of the front end as a parameter for communicating with a distributed database, and acquiring an available service list; and selecting a target service from the available service list, and returning the source information of the target service to the front end.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the service adaptive access method provided by the above embodiments, the method including: determining the IP address of the front end according to the service request of the front end; taking the IP address of the front end as a parameter for communicating with a distributed database, and acquiring an available service list; and selecting a target service from the available service list, and returning the source information of the target service to the front end.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.