CN108259418B - System and method for function hosting service - Google Patents

System and method for function hosting service Download PDF

Info

Publication number
CN108259418B
CN108259418B CN201611239761.8A CN201611239761A CN108259418B CN 108259418 B CN108259418 B CN 108259418B CN 201611239761 A CN201611239761 A CN 201611239761A CN 108259418 B CN108259418 B CN 108259418B
Authority
CN
China
Prior art keywords
function
hosted
managed
hosting
subunit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611239761.8A
Other languages
Chinese (zh)
Other versions
CN108259418A (en
Inventor
曹高晋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201611239761.8A priority Critical patent/CN108259418B/en
Publication of CN108259418A publication Critical patent/CN108259418A/en
Application granted granted Critical
Publication of CN108259418B publication Critical patent/CN108259418B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/80Responding to QoS

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Stored Programmes (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The invention discloses a method for function hosting service, which comprises the following steps: after receiving a task creating request containing a function to be managed, a function hosting unit creates a hosting environment for the function to be managed; after the function hosting unit receives a service request containing a function to be hosted, the function calling unit calls the function to be hosted to execute the service request and generate an execution result based on the hosting environment created for the function to be hosted. Meanwhile, the invention also discloses a system for the function hosting service.

Description

System and method for function hosting service
Technical Field
The invention relates to the field of cloud computing, in particular to a system and a method for function hosting service.
Background
The essence of cloud computing is to host business and data on a trusted cloud to reduce costs through scale effects. However, most existing cloud computing platforms encapsulate business logic in units of virtual machines or containers. However, it should be noted that the granularity of computing hosting in units of virtual machines is too large, and the overhead is large, so that the computing performance is reduced because the virtual machines run some unnecessary processes and guest operating systems, etc. in addition to containing business logic; the hosting is performed by taking the container as a unit, and mutual interference among the containers is introduced, which affects the application performance of tenants or users on the same host and cannot reach the Quality of Service (QoS) specified by the users. Meanwhile, the existing cloud computing platforms also use the virtual machine and the container as units for charging, and after part of the overhead except the actual service load is borne by the platform using party, the cost of the platform using party is increased. After the managed function platform is used, charging can be carried out according to the actual calling times or the actual CPU use conditions, and the expenditure is greatly reduced. However, in the prior art, a closed-source mechanism is adopted for solving the problem, and efficient and economic hosting service cannot be realized.
Disclosure of Invention
In view of this, embodiments of the present invention are expected to provide a system and a method for function hosting service, which can provide efficient and economical function hosting service.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the embodiment of the invention provides a system for function hosting service, which comprises: a function hosting unit and a function calling unit; wherein the content of the first and second substances,
the function hosting unit is used for creating a hosting environment for the function to be hosted after receiving a task creating request containing the function to be hosted;
the function call unit is configured to, after the function hosting unit receives a service request including a call to the function to be hosted, call the function to be hosted to execute the service request based on a hosting environment created for the function to be hosted, and generate an execution result.
In the above solution, the function hosting unit includes: a first function support pipe unit, a second function support pipe unit, a third function support pipe unit, a fourth function support pipe unit and a fifth function support sub-unit; wherein the content of the first and second substances,
the first function hosting subunit is used for receiving a task creating request containing a function to be hosted submitted by a user, allocating an identifier for the function to be hosted, and storing information of the function to be hosted;
the second function support pipe unit is used for making a mirror image for the function to be managed according to the information of the function to be managed stored in the first function support pipe unit, and recording the corresponding relation between the identifier of the function to be managed and the mirror image of the function to be managed;
the third function hosting subunit is used for distributing calling interface parameters for the function to be hosted and sending the calling interface parameters and the identification of the function to be hosted to the fifth function hosting subunit;
the fourth function hosting subunit is configured to allocate a message channel to the function to be hosted, and record a corresponding relationship between the message channel of the function to be hosted and a call interface parameter of the function to be hosted;
and the fifth function hosting subunit is used for receiving and storing the call interface parameters and the identifiers of the functions to be hosted, which are sent by the third function hosting pipe unit.
In the foregoing solution, the function call unit includes: the first function calling subunit and the second function calling subunit; wherein the content of the first and second substances,
the fifth function hosting subunit is further configured to receive a service request including a function to be hosted called, encapsulate the service request into a message, and send the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit is configured to obtain the message from a message channel corresponding to the call interface parameter of the function to be managed, obtain an identifier corresponding to the call interface parameter of the function to be managed from the fifth function call subunit, and send the message and the identifier of the function to be managed to the second function call subunit;
and the second function calling subunit is configured to call the function to be hosted to execute the service request according to the received message and the identifier of the function to be hosted, and generate an execution result.
In the above scheme, the first function hosting pipe unit stores the information of the function to be hosted as: storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request;
the second function support pipe unit is specifically configured to: acquiring the identifier of the function to be managed and the address of the code fragment from the first function hosting subunit, analyzing the address of the code fragment of the function to be hosted, manufacturing a mirror image of the function to be hosted according to an analysis result, and recording the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
In the foregoing solution, the second function call subunit is specifically configured to: acquiring a mirror image of the function to be managed from the second function management unit according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
The embodiment of the invention also provides a method for the function hosting service, which comprises the following steps:
after receiving a task creating request containing a function to be managed, a function hosting unit creates a hosting environment for the function to be managed;
after the function hosting unit receives a service request containing a function to be hosted, the function calling unit calls the function to be hosted to execute the service request and generate an execution result based on the hosting environment created for the function to be hosted.
In the above solution, the function hosting unit includes: a first function support pipe unit, a second function support pipe unit, a third function support pipe unit, a fourth function support pipe unit and a fifth function support sub-unit;
after the function hosting unit receives a task creating request containing a function to be hosted, a hosting environment is created for the function to be hosted, and the method comprises the following steps:
a first function hosting subunit receives a task creating request containing a function to be hosted submitted by a user, allocates an identifier for the function to be hosted, and stores information of the function to be hosted;
the second function support pipe unit is used for making a mirror image for the function to be managed according to the information of the function to be managed, which is stored in the first function support pipe unit, and recording the corresponding relation between the identifier of the function to be managed and the mirror image of the function to be managed;
the third function hosting pipe unit distributes calling interface parameters for the function to be hosted, and sends the calling interface parameters and the identification of the function to be hosted to a fifth function hosting subunit;
a fourth function hosting pipe unit distributes a message channel for the function to be hosted, and records the corresponding relation between the message channel of the function to be hosted and the call interface parameter of the function to be hosted;
and the fifth function hosting subunit receives and stores the call interface parameter and the identifier of the function to be hosted, which are sent by the third function hosting subunit.
In the foregoing solution, the function call unit includes: the first function calling subunit and the second function calling subunit;
after the function hosting unit receives a service request including a function to be hosted, the function invoking unit invokes the function to be hosted to execute the service request and generate an execution result based on a hosting environment created for the function to be hosted, including:
a fifth function hosting subunit receives a service request including calling the function to be hosted, packages the service request into a message, and sends the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit acquires the message from a message channel corresponding to the call interface parameter of the function to be managed, acquires an identifier corresponding to the call interface parameter of the function to be managed from the fifth function call subunit, and sends the message and the identifier of the function to be managed to the second function call subunit;
and the second function calling subunit calls the function to be managed to execute the service request according to the received message and the identifier of the function to be managed, and generates an execution result.
In the above scheme, the information for storing the function to be managed is: storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request;
the second function support pipe unit makes a mirror image for the function to be managed according to the information of the function to be managed stored in the first function support pipe unit, and records a corresponding relationship between an identifier of the function to be managed and the mirror image of the function to be managed, including:
the second function hosting pipe unit acquires the identifier of the function to be hosted and the address of the code fragment from the first function hosting subunit, analyzes the address of the code fragment of the function to be hosted, makes a mirror image of the function to be hosted according to an analysis result, and records the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
In the foregoing solution, the second function invoking subunit invokes, according to the received message and the identifier of the function to be hosted, the function to be hosted to execute the service request, and generate an execution result, where the method includes:
the second function calling subunit acquires a mirror image of the function to be managed from the second function hosting pipe unit according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
According to the system and the method for the function hosting service, provided by the embodiment of the invention, after a function hosting unit receives a task creating request containing a function to be hosted, a hosting environment is created for the function to be hosted; after the function hosting unit receives a service request containing a function to be hosted, the function calling unit calls the function to be hosted to execute the service request and generate an execution result based on the hosting environment created for the function to be hosted. Therefore, the embodiment of the invention is based on open source software, and realizes the efficient and economic function hosting service for the user through the container technology, namely, the function hosting service is more economic and efficient by providing a mode of calling as required, calling times or actual running time charging during running for functions and code segments with smaller granularity.
In addition, by means of the code of the managed function, the call to the function can be realized in various manners such as http and event.
Drawings
FIG. 1 is a block diagram of a system for function hosting service according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an implementation of a method for function hosting service according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a specific structure of a system for hosting a service according to a second embodiment of the present invention;
FIG. 4 is a diagram illustrating function management timing according to a second embodiment of the present invention;
fig. 5 is a schematic diagram illustrating a timing sequence of a user access function according to a second embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
Example one
Fig. 1 is a schematic diagram of a component structure of a system for function hosting service according to an embodiment of the present invention, where the system includes: a function hosting unit 11 and a function calling unit 12; wherein the content of the first and second substances,
the function hosting unit 11 is configured to create a hosting environment for a function to be hosted after receiving a task creating request including the function to be hosted;
the function calling unit 12 is configured to, after receiving a service request including a function to be hosted, call the function to be hosted to execute the service request based on a hosting environment created for the function to be hosted, and generate an execution result.
Here, after the function hosting unit 11 creates a hosting environment for the function to be hosted, so that when the function calling unit 12 needs to call the function to be hosted, the function to be hosted can be called quickly based on the hosting environment created by the function hosting unit 11 for the function to be hosted.
The function hosting unit 11 includes: a first function support sub-unit 110, a second function support pipe unit 111, a third function support pipe unit 112, a fourth function support pipe unit 113, and a fifth function support pipe unit 114; wherein the content of the first and second substances,
the first function hosting subunit 110 receives a task creating request containing a function to be hosted, which is submitted by a user, allocates an identifier to the function to be hosted, and stores information of the function to be hosted;
the second function hosting pipe unit 111 is configured to make a mirror image for the function to be hosted according to the information of the function to be hosted stored in the first function hosting sub-unit 110, and record a corresponding relationship between an identifier of the function to be hosted and the mirror image of the function to be hosted;
the third function hosting sub-unit 112 is configured to allocate a calling interface parameter for the function to be hosted, and send the calling interface parameter and the identifier of the function to be hosted to the fifth function hosting sub-unit 114;
the fourth function hosting pipe unit 113 is configured to allocate a message channel to the function to be hosted, and record a corresponding relationship between the message channel of the function to be hosted and a call interface parameter of the function to be hosted;
the fifth function support pipe unit 114 is configured to receive and store the call interface parameter and the identifier of the function to be managed, which are sent by the third function support pipe unit 112.
The first function hosting subunit 110 stores the information of the function to be hosted as follows: and storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request.
Here, the identifier of the function to be managed is used to represent the code of the function to be managed, that is, any function has a distinctive code; the encoding may be used to determine the identity of the function; according to the address of the code segment of the function to be managed, calling of the function to be managed can be achieved.
Here, the first function hosting subunit 110 is further configured to assign a function name to the function to be hosted, and store the function name of the function to be hosted as sub information in the information of the function to be hosted; of course, if the task creating request includes the function name of the function to be managed, the first function hosting subunit 110 does not need to allocate the function name to the function to be managed.
Here, the create task request may further include authorization information of a code segment of the function to be hosted and/or a list of dependency libraries of the function to be hosted; the authorization information can be used as a verification requirement for whether the code segment of the function to be managed is allowed to be modified, that is, when the code segment of the function to be managed is modified, the authorization information is required to be provided to allow the code segment to be modified; the dependency library list is used to determine an operating environment of the function to be hosted, that is, the function calling unit 12 is allowed to call the function to be hosted only when the hosting environment created by the function hosting unit 11 for the function to be hosted meets the requirement of the dependency library list; the authorization information and/or the dependency library list may also be stored to the first function hosting subunit 110 as sub information in the information of the function to be hosted.
The second function support pipe unit 111 is specifically configured to:
acquiring the identifier of the function to be managed and the address of the code fragment from the first function hosting subunit 110, analyzing the address of the code fragment of the function to be hosted, making a mirror image of the function to be hosted according to the analysis result, and recording the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
Here, the mirror image is used for creating a container for the function to be managed in subsequent processing, so as to execute the code segment of the function to be managed in the container, that is, to implement the call to the function to be managed; the recording of the corresponding relationship between the identifier of the function to be managed and the mirror image of the function to be managed can be used for acquiring the mirror image of the function to be managed according to the identifier of the function to be managed.
Here, the fifth function hosting subunit 114 is configured to serve as an access point for calling the function to be hosted, and therefore, after the third function hosting subunit 112 allocates a call interface parameter to the function to be hosted, the call interface parameter and the identifier of the function to be hosted need to be sent to the fifth function hosting subunit 114, so that after the fifth function hosting subunit 114 receives a call request including the call interface parameter of the function to be hosted, the function to be hosted can be called quickly according to the identifier of the function to be hosted.
The function call unit 12 includes: a first function call subunit 120, a second function call subunit 121; wherein the content of the first and second substances,
the fifth function hosting subunit 114 is further configured to receive a service request including a function to be hosted called, encapsulate the service request into a message, and send the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit 120 is configured to obtain the message from a message channel corresponding to a call interface parameter of the function to be hosted, obtain an identifier corresponding to the call interface parameter of the function to be hosted from the fifth function call subunit 114, and send the message and the identifier of the function to be hosted to the second function call subunit 121;
the second function invoking subunit 121 is configured to invoke the function to be hosted to execute the service request according to the received message and the identifier of the function to be hosted, and generate an execution result.
Here, the service request received by the fifth function hosting subunit 114 may exist in various manners such as http, event, and the like; the service request needs to include a call interface parameter of a function to be called, so as to inform the fifth function hosting subunit 114 of which function is the function to be called.
The second function call subunit 121 is specifically configured to: acquiring a mirror image of the function to be managed from the second function hosting pipe unit 111 according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
Here, after receiving the identifier of the function to be managed sent by the first function calling subunit 120, the second function calling subunit 121 obtains a mirror image made by the second function hosting tubular unit 111 for the function to be managed; then, based on the mirror image, creating a container corresponding to the function to be managed through container technologies such as docker and lxc; then, through a sub-process of fork, the sub-process enters the container corresponding to the function to be managed through a container technology such as docker, lxc and the like, so as to execute the code segment of the function to be managed in the container, and generate an execution result, that is, generate a result of calling the function to be managed to respond to the service request.
In practical applications, the first function hosting sub-unit 110, the second function hosting sub-unit 111, the third function hosting sub-unit 112, the fourth function hosting sub-unit 113, the fifth function hosting sub-unit 114, the first function calling sub-unit 120, and the second function calling sub-unit 121 may be implemented by a Central Processing Unit (CPU), a microprocessor unit (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like located at a terminal.
Based on the system for function hosting service, fig. 2 is a schematic flow chart illustrating an implementation process of a method for function hosting service according to an embodiment of the present invention, where the method includes:
step 101: after receiving a task creating request containing a function to be managed, a function hosting unit creates a hosting environment for the function to be managed;
here, after the function hosting unit creates a hosting environment for the function to be hosted, the function calling unit can realize quick calling of the function to be hosted based on the hosting environment created by the function hosting unit for the function to be hosted when the function calling unit needs to call the function to be hosted.
The function hosting unit includes: a first function support pipe unit, a second function support pipe unit, a third function support pipe unit, a fourth function support pipe unit and a fifth function support sub-unit;
after the function hosting unit receives a task creating request containing a function to be hosted, a hosting environment is created for the function to be hosted, and the method comprises the following steps:
a first function hosting subunit receives a task creating request containing a function to be hosted submitted by a user, allocates an identifier for the function to be hosted, and stores information of the function to be hosted;
the second function support pipe unit is used for making a mirror image for the function to be managed according to the information of the function to be managed, which is stored in the first function support pipe unit, and recording the corresponding relation between the identifier of the function to be managed and the mirror image of the function to be managed;
the third function hosting pipe unit distributes calling interface parameters for the function to be hosted, and sends the calling interface parameters and the identification of the function to be hosted to a fifth function hosting subunit;
a fourth function hosting pipe unit distributes a message channel for the function to be hosted, and records the corresponding relation between the message channel of the function to be hosted and the call interface parameter of the function to be hosted;
and the fifth function hosting subunit receives and stores the call interface parameter and the identifier of the function to be hosted, which are sent by the third function hosting subunit.
Wherein, the first function hosting pipe unit stores the information of the function to be hosted as: and storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request.
Here, the identifier of the function to be managed is used to represent the code of the function to be managed, that is, any function has a distinctive code; the encoding may be used to determine the identity of the function; according to the address of the code segment of the function to be managed, calling of the function to be managed can be achieved.
Here, the first function hosting subunit may further allocate a function name to the function to be hosted, and store the function name of the function to be hosted as sub information in the information of the function to be hosted; of course, if the task creating request includes the function name of the function to be managed, the first function hosting subunit does not need to allocate the function name to the function to be managed.
Here, the create task request may further include authorization information of a code segment of the function to be hosted and/or a list of dependency libraries of the function to be hosted; the authorization information can be used as a verification requirement for whether the code segment of the function to be managed is allowed to be modified, that is, when the code segment of the function to be managed is modified, the authorization information is required to be provided to allow the code segment to be modified; the dependency library list is used for determining an operating environment of the function to be hosted, that is, the function calling unit is allowed to call the function to be hosted only when the hosting environment created by the function hosting unit for the function to be hosted meets the requirement of the dependency library list; the authorization information and/or the dependency library list can also be stored to the first function hosting subunit as sub-information in the information of the function to be hosted.
The second function support pipe unit makes a mirror image for the function to be managed according to the information of the function to be managed stored in the first function support pipe unit, and records a corresponding relationship between an identifier of the function to be managed and the mirror image of the function to be managed, including:
the second function hosting pipe unit acquires the identifier of the function to be hosted and the address of the code fragment from the first function hosting subunit, analyzes the address of the code fragment of the function to be hosted, makes a mirror image of the function to be hosted according to an analysis result, and records the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
Here, the mirror image is used for creating a container for the function to be managed in subsequent processing, so as to execute the code segment of the function to be managed in the container, that is, to implement the call to the function to be managed; the recording of the corresponding relationship between the identifier of the function to be managed and the mirror image of the function to be managed can be used for acquiring the mirror image of the function to be managed according to the identifier of the function to be managed.
Here, the fifth function hosting subunit serves as an access point for calling the function to be hosted, and therefore, after the third function hosting subunit allocates a call interface parameter to the function to be hosted, the call interface parameter and the identifier of the function to be hosted need to be sent to the fifth function hosting subunit, so that after receiving a call request including the call interface parameter of the function to be hosted, the fifth function hosting subunit can realize fast call to the function to be hosted according to the identifier of the function to be hosted.
Step 102: after the function hosting unit receives a service request containing a function to be hosted, the function calling unit calls the function to be hosted to execute the service request and generate an execution result based on the hosting environment created for the function to be hosted.
The function call unit includes: the first function calling subunit and the second function calling subunit; after the function hosting unit receives a service request including a function to be hosted, the function invoking unit invokes the function to be hosted to execute the service request and generate an execution result based on a hosting environment created for the function to be hosted, including:
a fifth function hosting subunit receives a service request including calling the function to be hosted, packages the service request into a message, and sends the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit acquires the message from a message channel corresponding to the call interface parameter of the function to be managed, acquires an identifier corresponding to the call interface parameter of the function to be managed from the fifth function call subunit, and sends the message and the identifier of the function to be managed to the second function call subunit;
and the second function calling subunit calls the function to be managed to execute the service request according to the received message and the identifier of the function to be managed, and generates an execution result.
Here, the service request received by the fifth function trusted pipe unit may exist in various manners such as http, event, and the like; the service request needs to include a call interface parameter of a function to be called, so as to inform the fifth function hosting subunit which function is the function to be called.
The second function call subunit calls the function to be hosted to execute the service request according to the received message and the identifier of the function to be hosted, and generates an execution result, where the execution result includes:
the second function calling subunit acquires a mirror image of the function to be managed from the second function hosting pipe unit according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
Here, after receiving the identifier of the function to be managed sent by the first function calling subunit, the second function calling subunit obtains a mirror image that the second function hosting subunit makes for the function to be managed; then, based on the mirror image, creating a container corresponding to the function to be managed through container technologies such as docker and lxc; then, through a sub-process of fork, the sub-process enters the container corresponding to the function to be managed through a container technology such as docker, lxc and the like, so as to execute the code segment of the function to be managed in the container, and generate an execution result, that is, generate a result of calling the function to be managed to respond to the service request.
Example two
Fig. 3 is a schematic diagram of a specific composition structure of a system for hosting a service according to a second embodiment of the present invention, where the system mainly includes: parts of api-server, endpoint scheduler, image builder, task scheduler, channel allocator, gw, executor, etc.; wherein the content of the first and second substances,
api-server: the function server is responsible for receiving a submitted function (function) request, wherein the request comprises a URL (uniform resource locator) required by acquiring a function, a cognitive password (token) required by accessing the function and a dependency library list; the URL is the address of the function code fragment, the token is authorization information for accessing the function code, and the dependency library list is used for determining the running environment of the function, namely the request is allowed to be accepted only when the hosting environment prepared for the function meets the dependency library list; in practical application, the dependency library list is optional, that is, the content of the function may or may not include the dependency library list; after receiving the function, the api-server adds the function to a functions table of the database, namely, creates a new function in the functions table, and assigns a function name (name) and an identifier (id) for the function, and stores information such as token and URL of the function;
end-scheduler: the method comprises the steps that the method is in charge of monitoring a functions table, once the functions table changes, for example, when a new function is added to the functions table, an end-scheduler creates a new line of record in the functions table, namely, the function is allocated with an end, and the corresponding relation among the name, the id and the end of the function is recorded; allocating an endpoint corresponding to the function to a specific gw node, wherein the gw node is a service-draining node and corresponds to the id of the specific path and function;
image-builder: the function table monitoring system is responsible for monitoring the function table, once the function table changes, for example, when a new function is added to the function table, the image-builder acquires the information of the function from the function table, analyzes the URL of the function, and creates a mirror image (image) corresponding to the function on the mirror image server; after the image of the function is made, the image-builder records the corresponding relation between the function and the image of the function in an images list, for example, records the corresponding relation between the name, the id and the image of the function;
channel-allocator: the method comprises the steps that the method is responsible for monitoring a functions table, once the functions table changes, for example, when a new function is added to the functions table, a channel-allocator allocates a message channel (channel) to the function in the channels table, and records the corresponding relation between the function and the channel of the function, for example, the corresponding relation between the name, id, end and channel of the function;
gw: the monitoring system is responsible for monitoring the endpoints table and the channels table, if the information corresponding to the gw is found in the endpoints table, for example, a row of record related to a new function is added in the endpoints table, the corresponding relation between the endpoints table and the function on the gw is updated, that is, the endpoints of the function are stored in the endpoints table on the gw, and the information such as the id and the name of the function is recorded; here, the gw node is the node that actually receives the function call; if gw receives an http request for calling a function under a certain path, such as ip: port/adam/func1, encapsulating the request into a message and sending the message to a channel corresponding to the request in a message queue;
task-scheduler: the component is responsible for distributing requests of calling functions such as http and the like to the nodes for execution; each message generated by gw corresponds to a task (task), a task-scheduler monitors the messages in the message queue, allocates the tasks corresponding to the messages to the computing nodes through a certain allocation algorithm, and records the tasks in a schedules table; the allocation is only to record a row of records in the database, and the allocation algorithm can be scheduled according to the CPU utilization rate and the memory utilization rate;
the computing node is provided with 2 components, one component is an executive and is responsible for monitoring the schedules table, and once the executive finds that the schedules table has tasks distributed to the node, the executive creates a container on the node; here, the creation of the container may be realized by adopting a technique such as docker, lxc, or the like, based on the image of the function; the image needed for creating the container, namely the image of the function, can be obtained from the images store through the fetcher, and the image in the images store is created by the image-builder; meanwhile, the executor will ask a sub-process, and the sub-process enters the container through the container technology such as docker and the like, and executes the code segment of the function so as to realize the calling of the function.
In this embodiment, after the user uploads the function request to be managed through the api-server, the system prepares a managed environment for the function to be managed according to the function to be managed uploaded by the user, including making a mirror image of the function to be managed, creating an endpoint of the function to be managed, creating a message channel of the function to be managed, and the like.
Based on the above system, a schematic diagram of a function management timing sequence in the second embodiment of the present invention is shown in fig. 4, where the function management timing sequence includes:
step 201: a user submits a function creation task request to the api-server;
here, the function creation task request includes an address of a function code fragment, authorization information for accessing the function code, and a dependency library list for determining an operating environment of the function.
Step 202: the api-server receives a function creation task request submitted by a user;
specifically, the api-server receives a function creation task request submitted by a user in a file form.
Step 203: analyzing the function by the image-builder, and making a mirror image for the function;
specifically, the image-builder parses the address of the function code fragment and makes a mirror image of the function on the mirror server.
Step 204: a channel-allocator allocates a message channel for the function;
specifically, the channel-allocator allocates a message channel to the function, so that gw can transmit a task calling the function to the task-scheduler through the message channel of the function.
Step 205: creating a relation between a function and an endpoint in a database by an endpoint-scheduler;
specifically, the endpoint-scheduler creates an endpoint corresponding to the function in the database, and records a corresponding relationship between the function and the endpoint, so that the user can call the function through the endpoint.
Step 206: and the gw updates the corresponding relation between the endpoint and the function, configures a reverse proxy positioned on the gw, and increases the corresponding endpoint path.
Specifically, gw stores the function and the endpoint created by the endpoint-scheduler and corresponding to the function, so that all information of the function can be acquired according to the endpoint of the function.
Fig. 5 is a schematic diagram of a user access function timing sequence in the second embodiment of the present invention, where the user access function timing sequence includes:
step 301: a user sends a request for accessing a function to gw;
here, the request includes an endpoint of a function to be accessed.
Step 302: the gw encapsulates the request of the access function into a message and transmits the message to a message queue;
specifically, after receiving a request for accessing a function sent by the user, gw encapsulates the request for accessing the function into a message, and transmits the message to a message channel corresponding to the function in a message queue according to end of the function.
Step 303: a task-scheduler allocates execution nodes for the tasks corresponding to the messages;
specifically, after the task-scheduler acquires the message from the message queue, the task corresponding to the message is acquired, and an execution node is allocated to the task corresponding to the message, so that the task is executed at the execution node.
Step 304: the executor creates a container for the task and executes the code of the function;
specifically, the executor creates a container for the mirror image made by the function based on the image-builder by using technologies such as docker and lxc, so as to execute the code of the function in the container and generate the execution result of the function responding to the request.
Step 305: the executor returns the result to the message queue;
specifically, the executor returns the execution result generated in step 304 to the message queue.
Step 306: the gw acquires the result from the message queue;
specifically, gw obtains the result of the function that has been hosted in response to the request from the message queue.
Step 307: gw returns the result to the user.
Specifically, gw returns the result to the user to inform the user of the result of invoking the function to respond to the request.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present invention are included in the protection scope of the present invention.

Claims (8)

1. A system for function hosting services, the system comprising: a function hosting unit and a function calling unit; wherein the content of the first and second substances,
the function hosting unit is used for creating a hosting environment for the function to be hosted after receiving a task creating request containing the function to be hosted;
the function call unit is used for calling the function to be managed to execute the service request and generate an execution result based on the managed environment created for the function to be managed after the function hosting unit receives the service request containing the function to be managed;
wherein the function hosting unit includes: a first function support pipe unit, a second function support pipe unit, a third function support pipe unit, a fourth function support pipe unit and a fifth function support sub-unit; wherein the content of the first and second substances,
the first function hosting subunit is used for receiving a task creating request containing a function to be hosted submitted by a user, allocating an identifier for the function to be hosted, and storing information of the function to be hosted;
the second function support pipe unit is used for making a mirror image for the function to be managed according to the information of the function to be managed stored in the first function support pipe unit, and recording the corresponding relation between the identifier of the function to be managed and the mirror image of the function to be managed;
the third function hosting subunit is used for distributing calling interface parameters for the function to be hosted and sending the calling interface parameters and the identification of the function to be hosted to the fifth function hosting subunit;
the fourth function hosting subunit is configured to allocate a message channel to the function to be hosted, and record a corresponding relationship between the message channel of the function to be hosted and a call interface parameter of the function to be hosted;
and the fifth function hosting subunit is used for receiving and storing the call interface parameters and the identifiers of the functions to be hosted, which are sent by the third function hosting pipe unit.
2. The system of claim 1, wherein the function call unit comprises: the first function calling subunit and the second function calling subunit; wherein the content of the first and second substances,
the fifth function hosting subunit is further configured to receive a service request including a function to be hosted called, encapsulate the service request into a message, and send the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit is configured to obtain the message from a message channel corresponding to the call interface parameter of the function to be managed, obtain an identifier corresponding to the call interface parameter of the function to be managed from the fifth function call subunit, and send the message and the identifier of the function to be managed to the second function call subunit;
and the second function calling subunit is configured to call the function to be hosted to execute the service request according to the received message and the identifier of the function to be hosted, and generate an execution result.
3. The system of claim 1,
the first function hosting subunit stores the information of the function to be hosted as follows: storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request;
the second function support pipe unit is specifically configured to:
acquiring the identifier of the function to be managed and the address of the code fragment from the first function hosting subunit, analyzing the address of the code fragment of the function to be hosted, manufacturing a mirror image of the function to be hosted according to an analysis result, and recording the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
4. The system of claim 2,
the second function call subunit is specifically configured to: acquiring a mirror image of the function to be managed from the second function management unit according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
5. A method of function hosting services, the method comprising:
after receiving a task creating request containing a function to be managed, a function hosting unit creates a hosting environment for the function to be managed;
after the function hosting unit receives a service request containing a function to be hosted, the function calling unit calls the function to be hosted to execute the service request and generate an execution result based on a hosting environment created for the function to be hosted;
wherein the function hosting unit includes: a first function support pipe unit, a second function support pipe unit, a third function support pipe unit, a fourth function support pipe unit and a fifth function support sub-unit; after the function hosting unit receives a task creating request containing a function to be hosted, a hosting environment is created for the function to be hosted, and the method comprises the following steps:
a first function hosting subunit receives a task creating request containing a function to be hosted submitted by a user, allocates an identifier for the function to be hosted, and stores information of the function to be hosted;
the second function support pipe unit is used for making a mirror image for the function to be managed according to the information of the function to be managed, which is stored in the first function support pipe unit, and recording the corresponding relation between the identifier of the function to be managed and the mirror image of the function to be managed;
the third function hosting pipe unit distributes calling interface parameters for the function to be hosted, and sends the calling interface parameters and the identification of the function to be hosted to a fifth function hosting subunit;
a fourth function hosting pipe unit distributes a message channel for the function to be hosted, and records the corresponding relation between the message channel of the function to be hosted and the call interface parameter of the function to be hosted;
and the fifth function hosting subunit receives and stores the call interface parameter and the identifier of the function to be hosted, which are sent by the third function hosting subunit.
6. The method of claim 5, wherein the function call unit comprises: the first function calling subunit and the second function calling subunit; after the function hosting unit receives a service request including a function to be hosted, the function invoking unit invokes the function to be hosted to execute the service request and generate an execution result based on a hosting environment created for the function to be hosted, including:
a fifth function hosting subunit receives a service request including calling the function to be hosted, packages the service request into a message, and sends the message to a message channel corresponding to a calling interface parameter of the function to be hosted; the service request comprises a calling interface parameter of the function to be managed;
the first function call subunit acquires the message from a message channel corresponding to the call interface parameter of the function to be managed, acquires an identifier corresponding to the call interface parameter of the function to be managed from the fifth function call subunit, and sends the message and the identifier of the function to be managed to the second function call subunit;
and the second function calling subunit calls the function to be managed to execute the service request according to the received message and the identifier of the function to be managed, and generates an execution result.
7. The method according to claim 5, wherein the information for storing the function to be hosted is: storing the identification of the function to be managed and the address of the code segment of the function to be managed contained in the task creating request;
the second function support pipe unit makes a mirror image for the function to be managed according to the information of the function to be managed stored in the first function support pipe unit, and records a corresponding relationship between an identifier of the function to be managed and the mirror image of the function to be managed, including:
the second function hosting pipe unit acquires the identifier of the function to be hosted and the address of the code fragment from the first function hosting subunit, analyzes the address of the code fragment of the function to be hosted, makes a mirror image of the function to be hosted according to an analysis result, and records the corresponding relationship between the identifier of the function to be hosted and the mirror image of the function to be hosted.
8. The method according to claim 6, wherein the second function call subunit calls the function to be hosted to execute the service request and generate an execution result according to the received message and the identifier of the function to be hosted, and includes:
the second function calling subunit acquires a mirror image of the function to be managed from the second function hosting pipe unit according to the received identifier of the function to be managed; creating a container according to the mirror image of the function to be managed, executing the code segment of the function to be managed in the container, and generating an execution result.
CN201611239761.8A 2016-12-28 2016-12-28 System and method for function hosting service Active CN108259418B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611239761.8A CN108259418B (en) 2016-12-28 2016-12-28 System and method for function hosting service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611239761.8A CN108259418B (en) 2016-12-28 2016-12-28 System and method for function hosting service

Publications (2)

Publication Number Publication Date
CN108259418A CN108259418A (en) 2018-07-06
CN108259418B true CN108259418B (en) 2021-08-24

Family

ID=62720366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611239761.8A Active CN108259418B (en) 2016-12-28 2016-12-28 System and method for function hosting service

Country Status (1)

Country Link
CN (1) CN108259418B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111240806B (en) * 2020-01-14 2022-04-01 南京邮电大学 Distributed container mirror image construction scheduling method
CN111475235B (en) * 2020-04-13 2023-09-12 北京字节跳动网络技术有限公司 Acceleration method, device, equipment and storage medium for function calculation cold start

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662815A (en) * 2012-03-12 2012-09-12 苏州萃智新技术开发有限公司 Cloud computing supervision and management system
CN104836850A (en) * 2015-04-16 2015-08-12 华为技术有限公司 Instance node management method and management equipment
CN105072115A (en) * 2015-08-12 2015-11-18 国家电网公司 Information system invasion detection method based on Docker virtualization
CN105245373A (en) * 2015-10-12 2016-01-13 天津市普迅电力信息技术有限公司 Construction and operation method of container cloud platform system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101826004A (en) * 2009-03-02 2010-09-08 上海科泰世纪科技有限公司 Method for mandating functions by Applet
US8375373B2 (en) * 2010-04-19 2013-02-12 Microsoft Corporation Intermediate language support for change resilience
US9582268B2 (en) * 2015-05-27 2017-02-28 Runnable Inc. Automatic communications graphing for a source application

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662815A (en) * 2012-03-12 2012-09-12 苏州萃智新技术开发有限公司 Cloud computing supervision and management system
CN104836850A (en) * 2015-04-16 2015-08-12 华为技术有限公司 Instance node management method and management equipment
CN105072115A (en) * 2015-08-12 2015-11-18 国家电网公司 Information system invasion detection method based on Docker virtualization
CN105245373A (en) * 2015-10-12 2016-01-13 天津市普迅电力信息技术有限公司 Construction and operation method of container cloud platform system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
谈谈AWS Lambda和severless architecture;陈天;《https://zhuanlan.zhihu.com/p/20297696》;20151027;第1-6页 *

Also Published As

Publication number Publication date
CN108259418A (en) 2018-07-06

Similar Documents

Publication Publication Date Title
US10817331B2 (en) Execution of auxiliary functions in an on-demand network code execution system
US11875173B2 (en) Execution of auxiliary functions in an on-demand network code execution system
US10628207B2 (en) Management of IoT devices in a virtualized network
CN108632074B (en) Service configuration file issuing method and device
CN109889586B (en) Communication processing method and device, computer readable medium and electronic equipment
CN110546920B (en) Service provisioning procedures using slicing and related definitions
CN112512090B (en) Communication processing method and device, computer readable medium and electronic equipment
US10606662B2 (en) System and method for processing task resources
WO2020005764A1 (en) Execution of auxiliary functions in an on-demand network code execution system
Cicconetti et al. Toward distributed computing environments with serverless solutions in edge systems
US10616139B1 (en) Reducing quota access
US20170171245A1 (en) Dynamic detection and reconfiguration of a multi-tenant service
CN108021400B (en) Data processing method and device, computer storage medium and equipment
CN108512672B (en) Service arranging method, service management method and device
CN112104754A (en) Network proxy method, system, device, equipment and storage medium
CN108259418B (en) System and method for function hosting service
CN112104679B (en) Method, apparatus, device and medium for processing hypertext transfer protocol request
CN109428733B (en) Method and device for directional flow charging
CN110493175B (en) Information processing method, electronic equipment and storage medium
CN111832862A (en) Block chain-based process management method and system
CN113055493B (en) Data packet processing method, device, system, scheduling device and storage medium
US20220329635A1 (en) Method and apparatus for media session management for service enabler architecture layer (seal) architecture
CN115314468A (en) IP address allocation method and system for container cloud platform
CN114885024A (en) Routing method, device, equipment and medium of application example
CN103686224A (en) Method and system for transcoding task obtaining on basis of distributed locks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant