CN114816445A - System platform architecture, function publishing method and device, platform and storage medium - Google Patents

System platform architecture, function publishing method and device, platform and storage medium Download PDF

Info

Publication number
CN114816445A
CN114816445A CN202110129777.8A CN202110129777A CN114816445A CN 114816445 A CN114816445 A CN 114816445A CN 202110129777 A CN202110129777 A CN 202110129777A CN 114816445 A CN114816445 A CN 114816445A
Authority
CN
China
Prior art keywords
function
container
code
service
target
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.)
Pending
Application number
CN202110129777.8A
Other languages
Chinese (zh)
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 CN202110129777.8A priority Critical patent/CN114816445A/en
Publication of CN114816445A publication Critical patent/CN114816445A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects

Abstract

The embodiment of the invention discloses a system platform architecture, a function publishing method and device, a platform and a storage medium, wherein the method comprises the following steps: receiving a function issuing request; determining the running environment of the target function to be issued according to the function issuing request; starting a function service container according to the image file of the operating environment of the target function; and continuing to publish the target function based on the function service container.

Description

System platform architecture, function publishing method and device, platform and storage medium
Technical Field
The invention relates to the technical field of cloud computing, in particular to a system platform architecture, a function publishing method and device, a platform and a storage medium.
Background
Cloud computing changes our cognition on an operating system, the computing resources, storage and network of an original system can be separately configured and can be elastically expanded, but for a long time, the system is not always out of the constraint of a server when developing applications, the applications must be operated on the server (whether entity or virtual), the applications must be operated after deployment, configuration and initialization, the server and the applications need to be monitored and managed, and meanwhile, the safety of data needs to be ensured.
Whether a public cloud or a self-built data center is selected, the problems of server quantity estimation, storage capacity planning, database model selection and the like can be faced. While requiring the deployment of dependent software on top of the infrastructure to run the application. FaaS (functions as a service) function, FaaS is a form of serverless computing. Different from server-side software, an application program is deployed in a virtual machine or a container with an operating system and generally needs to be resident in the operating system for a long time to run, and FaaS is only needed to directly deploy the program on a platform.
Disclosure of Invention
In view of this, embodiments of the present invention are intended to provide a method and an apparatus for function publishing, a platform and a computer storage medium.
In a first aspect, an embodiment of the present invention provides a system platform architecture, including:
a code repository for storing function codes;
a database;
the container mirror image warehouse is used for storing the running environment corresponding to at least one code language, wherein the running environment comprises a mirror image file;
the cloud platform is respectively connected with the code warehouse, the database and the container mirror image warehouse and is used for uploading the function codes of the target function to the code warehouse based on the received function issuing request of the target function to be issued; uploading the release information carried by the function release request to the database; and starting a function service container according to the image file of the running environment of the target function, and issuing the target function.
In one embodiment, the function service container is a service bearer container.
In one embodiment, the function service container is: the service bearing container loaded with the image file.
In one embodiment, the cloud platform is a Serverless platform.
In one embodiment, the image file is a source image corresponding to the code language acquired from a container image repository, and the source image includes a development kit corresponding to the code language.
In a second aspect, an embodiment of the present invention provides a function publishing method, including:
receiving a function issuing request;
determining the running environment of the target function to be issued according to the function issuing request;
starting a function service container according to the image file of the running environment of the target function;
and continuing to publish the target function based on the function service container.
In one embodiment, the starting a function service container according to an image file of the execution environment of the objective function includes:
creating a service bearer container;
and adding the mirror image file into the service bearing container to obtain the started function service container.
In an embodiment, the determining, according to the function publishing request, a running environment of an object function to be published includes: determining the value of an environment variable corresponding to the operating environment of the target function according to release information carried by the release request;
the method further comprises the following steps:
and assigning the value of the environment variable to the environment variable corresponding to the mirror image file in the function service container.
In one embodiment, the method further comprises:
determining a storage address of a function code of the target function according to release information carried by the function release request;
and pulling the function code from the storage address, wherein the function code is used for being added into the function service container.
In one embodiment, the storage address is stored in a deployment file of the objective function.
In an embodiment, the determining, according to the function publishing request, a running environment of an object function to be published includes:
determining the running environment of the target function according to language information of a code language specified by the function issuing request, wherein the language information at least comprises: the type of language.
In one embodiment, the language information further includes: and version information.
In a third aspect, an embodiment of the present invention provides a function publishing device, including:
a receiving unit, configured to receive a function issuing request;
the determining unit is used for determining the operating environment of the target function to be issued according to the function issuing request;
the starting unit is used for starting the function service container according to the mirror image file of the running environment of the target function;
and the issuing unit is used for continuing issuing the target function based on the function service container.
In a fourth aspect, an embodiment of the present invention provides a platform, where the platform includes: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is used for executing the function calculation program stored in the memory so as to realize the method provided by any one of the above.
In a fifth aspect, embodiments of the present invention provide a computer storage medium having stored thereon computer-executable instructions; the computer executable instructions, when executed, enable any of the methods provided above to be implemented.
The function issuing method of the embodiment of the invention determines the running environment of the target function to be issued according to the received function issuing request; starting a function service container according to the mirror image file of the running environment of the target function; finally, the target function continues to be published based on the function service container. The function issuing method of the embodiment of the invention takes a container technology as a carrier, quickly reproduces a complete dependence environment required by the operation of the target function based on a preset image file, further starts a function service container in the operation dependence environment, and realizes the quick deployment and issuing of the target function in the container.
Drawings
Fig. 1 is a schematic diagram of a system architecture of a function issuing apparatus according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a first function issuing method according to an embodiment of the present invention;
fig. 3 is a schematic view of a mirror image file loading flow provided in an embodiment of the present invention;
fig. 4 is a schematic flowchart of a second function publishing method according to an embodiment of the present invention;
fig. 5 is a schematic flowchart of a third function issuing method according to an embodiment of the present invention;
fig. 6 is a schematic flowchart of a fourth function issuing method according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a function issuing apparatus according to an embodiment of the present invention;
fig. 8 is a schematic flowchart of a fifth function issuing method according to an embodiment of the present invention;
fig. 9 is a functional structure diagram of a function service container according to an embodiment of the present invention.
Detailed Description
The technical solution of the present invention is further described in detail with reference to the drawings and specific embodiments.
The function issuing method provided by the embodiment of the invention realizes the rapid deployment and issuing of the target function based on the container technology.
As shown in fig. 1, a system platform architecture according to an embodiment of the present invention includes:
a code repository for storing function codes;
a database;
the container mirror image warehouse is used for storing the running environment corresponding to at least one code language, wherein the running environment comprises a mirror image file;
the cloud platform is respectively connected with the code warehouse, the database and the container mirror image warehouse and is used for uploading the function codes of the target function to the code warehouse based on the received function issuing request of the target function to be issued; uploading the release information carried by the function release request to the database; and starting a function service container according to the image file of the running environment of the target function, and issuing the target function.
Here, the platform architecture of the Serverless platform includes a code management module, a function management and control module, a gateway service module, and the like. Meanwhile, the Serverless platform is in butt joint with the code warehouse, the database and the container mirror image warehouse. The container mirror image warehouse is used for storing pre-developed mirror image files of a plurality of languages, including but not limited to python mirror image files, nodejs mirror image files, golang mirror image files and java mirror image files, and can be built by a registry or a hardor; the database is provided by an open source database MYSQL and is used for storing code related configuration and function release information; the function operation cluster is usually built by kubernets, and a knetive is deployed to provide a bottom-layer Serverless native service; in addition, the unified service gateway can be built by gloo deployment for forwarding the trigger event for accessing the target function to the specified function service.
In some embodiments, the function service container is a service bearer container.
In some embodiments, the function service container is: the service bearing container loaded with the image file.
In some embodiments, the cloud platform is a Serverless platform.
In some embodiments, the image file is a source image corresponding to the code language acquired from a container image repository, and the source image includes a development kit corresponding to the code language.
As shown in fig. 2, a function publishing method according to an embodiment of the present invention includes:
step S101: receiving a function issuing request;
step S102: determining the running environment of the target function to be issued according to the function issuing request;
step S104: starting a function service container according to the image file of the running environment of the target function;
step S107: and continuing to publish the target function based on the function service container.
In this embodiment, the cloud platform develops the target function, for example, writes a function code of the target function or updates a function code of the target function, and after the development is completed, the cloud platform does not need to directly interact with the code warehouse, but the code management module of the Serverless platform uploads the function code to the code warehouse.
In the present embodiment, a Serverless platform is taken as an example for specific description. After the Serverless platform receives the function publishing request, a code management module in the Serverless platform analyzes publishing information carried in the function publishing request, wherein the publishing information comprises a function code file or a compression packet, an uploaded code warehouse address, language information, function entry information, function runtime information, code language version information, a function name, a function call entry and/or function context information and the like, uploads the function code to a code warehouse specified by the function publishing request, and stores related metadata of a target function, such as function entry file information, function entry name, function runtime information and the like, in a database.
In this embodiment, the execution environment of the objective function includes a complete execution dependent environment required by the execution of the objective function, and the objective functions encoded in different languages correspond to different execution environments. For example, the target function coded by python adopts the running environment corresponding to python, the target function coded by nodejs adopts the running environment corresponding to nodejs, the target function coded by golang adopts the running environment corresponding to golang, and the target function coded by java adopts the running environment corresponding to java.
In this embodiment, the operating environment includes an image file, and on any one machine, the complete operating dependent environment required by the objective function can be reproduced only by decompressing the packaged image file.
The image files are stored in the image warehouse in advance, for example, a python image file corresponding to python, a nodejs image file corresponding to nodejs, a golang image file corresponding to golang and a java image file corresponding to java are stored in the image warehouse in advance.
Here, as shown in fig. 3, the different language execution environments are specifically described:
aiming at a python language environment, because python is an interpretive language, codes can run without compiling, and in order to improve the running speed, when an image file is manufactured, a code server. The basic image made by the image file is a python source image of a docker community, wherein the basic image comprises a common python library and a pip toolkit. At the time of the target function running, the base service is first started through python server. In the basic service, a function call entry is specified through MOD _ NAME and FUNC _ HANDLER environment variables, a target function index is dynamically loaded in the basic service through imp.
Aiming at the nodejs language environment, because nodejs is an interpretive language, codes can run without compiling, and in order to improve the running speed, when a mirror image file is manufactured, basic service codes server. And when the image file is manufactured, a nodejs image of a docker community open source is selected as a basic image, and the image comprises a development kit and an npm tool which are commonly used by nodejs. When the target function runs, the basic service is started directly by executing a server file, in the basic service, a function call entry is specified by MOD _ NAME ═ index. For the golang language environment, since golang is a compiled language, code cannot be directly run. Therefore, after the function code development is completed, the function code index.go needs to be compiled into a plug-in index.so file in advance and uploaded to the Serverless platform. When the image file is manufactured, a golang image of an open source of a docker community is selected as a basic image, and the image comprises a development toolkit commonly used by the golang. And when the container is started, firstly, pulling the target function plug-in unit index. And finally, starting the function service in a mode of executing the server file. In the server.go, the target function is loaded in a plug.open ("index.so") manner, and the target function entry is called in a plug.lookup (FUNC _ handle) manner.
For the java language environment, since java is a compiled language, the run code cannot be executed. Therefore, after the function code is developed, the function code index. When the image file is manufactured, an openjdk image of a docker community open source is selected as a basic image, and the image comprises a tool package based on a java program. And simultaneously, basic service server.java needs to be compiled into a jar packet in advance and preset into an execution path specified in the mirror image. At container startup, a call entry of a function is specified by MOD _ NAME and FUNC _ handle, a target function file is dynamically loaded in a base service by loadJar ("index. jar"), and a call entry HANDLER of the target function is dynamically loaded by class.
Specifically, after the function code is uploaded successfully, the function management and control module in the Serverless platform determines the running environment of the target function, and the specific process is as follows:
first, publish information is read from a database, and the publish information may include language information, function name, function call entry, and function context information.
Then, analyzing an image file required by the operation of the target function from a preset image mapping table of a database according to the language information; and analyzing information such as hardware configuration, environment variables and the like required by the release target function according to the function call entry and the context information.
In this embodiment, after determining the operating environment of the target function to be issued, the function service container is started according to the image file of the operating environment of the target function.
For example, all function issuing information is packaged into a function deployment file, a mirror image file pulled when a function service container is started is specified, after the function deployment file is packaged, the function control module continues to call a bottom deployment cluster, the function deployment file is issued through kubernets and a native API (application program interface), and after the bottom deployment cluster receives the function deployment file, a target function is issued through running the function service container.
The function issuing method of the embodiment of the invention takes the container technology as a carrier, automatically starts the container service based on the mirror image file, and realizes the rapid deployment and issuing of the target function in the container. Moreover, the function issuing method can be packaged into a container mirror image, one-key automatic deployment can be realized, and large-scale deployment can be carried out based on a container cluster. Meanwhile, the container mirror image has no environment dependence and can be deployed and operated in any environment.
The preset mirror image file of the embodiment of the invention is preloaded with all the dependencies of function construction and release of different code languages, and realizes a function module which is universal for a Serverless platform in advance, after a function service container is started, the function code of the target function is automatically pulled and loaded in the function service container, and the target function is released without compiling a complete program or installing a program compiling and running environment, so that the second-level release of the function can be realized.
In some embodiments, as shown in fig. 4, the step S104: starting a function service container according to the image file of the running environment of the target function, wherein the function service container comprises:
step S1041: creating a service bearer container;
step S1042: and adding the mirror image file into the service bearing container to obtain the started function service container.
In this embodiment, the service bearer is used to complete the preset condition required by the function service container before the function service container is started. And when the Serverless platform receives the function release request, triggering a service starting process, and creating a service bearing container according to the function deployment file. As illustrated in fig. 9, the service bearer container includes: the system comprises a pre-starting unit, a function code loading unit, a basic service starting unit and a function hot loading unit.
The pre-starting unit is used for providing an environment detection function. When the function service container is started on the Serverless platform, the environment inside the function service container is detected and the basic environment of the function service container is self-detected, for example, network configuration check, network card connection state, cpu memory health state and/or environment variable analysis are performed. The environment variable analysis mainly analyzes key environment variables required by function operation, such as function code warehouse addresses, function code warehouse branches, function starting file names, function call entries, function entry names, function operation contexts and the like.
The function code loading unit is used for providing a code pulling function. After the function service container is pre-started, firstly, checking the code warehouse information, after confirming that the function codes in the code warehouse are normal, automatically pulling the function codes of the target function from the specified code warehouse to the specified folder according to the code warehouse address in the environment variable.
The basic service unit is used for providing function issuing basic service and is preset in a target execution path of the image file. And when the target function code is pulled, automatically starting basic service according to different code languages, and providing the service for the outside by the basic service in an http mode.
For example, when the function service container is started, after the function code is successfully pulled, the basic service unit starts the basic service according to the starting characteristic of the code-free language, wherein the basic service is realized through the web and can accept http requests.
And after the basic service is started, hot loading is carried out on the function code according to the preset language version of the current function service container environment according to the configured function call entry in the environment variable. The specific loading is determined according to the flow language version, and here, the language version preset by the function service container environment includes python language, nodejs language, golang language, java language, and the like.
Specifically, the basic service starting mode is different according to different language environments. For example, aiming at a python language, a basic service is compiled into a pyc file in advance, the basic service is started through a python command, and a target function is dynamically loaded in the basic service through an imp.load _ source () method; aiming at the nodejs language, firstly, compiling basic service into an executable file in advance, running the service through a node server command, and dynamically loading a target function in the basic service in a require mode; for the golang language, function codes and dependencies need to be packaged into a plug-in form in advance, uploaded to a Serverless platform, loaded with function plug-ins by basic service, jointly compiled into an executable file, and finally executed with service; aiming at java language, function codes and dependencies need to be packaged into jar packages, and the function jar packages are dynamically loaded in basic service.
In some embodiments, when the function service container is started, the basic service may automatically load the function code, detect the syntax of the function code, and return an error message through http if the function code is wrongly written.
And after the service bearing container is created, adding the mirror image file into the service bearing container to obtain the started function service container.
Specifically, the corresponding image file pulled from the container image warehouse is added into the service bearer container to obtain the started function service container.
In some embodiments, as shown in fig. 5, the step S102: determining the operating environment of the target function to be issued according to the function issuing request, wherein the method comprises the following steps:
step S102': determining the value of an environment variable corresponding to the operating environment of the target function according to release information carried by the release request;
the method further comprises the following steps:
step S103: and assigning the value of the environment variable to the environment variable corresponding to the mirror image file in the function service container.
In this embodiment, the function management and control module in the Serverless platform obtains the function issue request to create the function service container, and when creating the function service container, obtains values of the environment variables, such as a code warehouse address, a function call entry, function context information, and the like corresponding to the target function, from the database, and assigns the values of the information to the environment variables of the function service container.
In some embodiments, the parameters in the release information are packaged into a deployment file, and the values are assigned to the environment variables corresponding to the image files in the function service container according to the values of the parameters of the deployment file.
Specifically, the Serverless platform receives a function release request, analyzes release information from the function release request, packages each parameter in the release information into a deployment file, specifies a mirror image file preset by the platform according to a specified language version of the function release in the deployment file, and starts function service through the deployment file.
In some embodiments, as shown in fig. 6, the method further comprises:
step S105: determining a storage address of a function code of the target function according to release information carried by the function release request;
step S106: and pulling the function code from the storage address, wherein the function code is used for being added into the function service container.
In this embodiment, the release information carried by the received function release request includes a code warehouse address, and according to the code warehouse address, the code warehouse address is a storage address of the function code; and after the function service container is pre-started, pulling the function code of the target function from the specified code warehouse into the function service container.
In some embodiments, the memory address is stored in a deployment file of the objective function.
Here, the code repository address is encapsulated as an environment variable (storage address) in a deployment file. After the function service container is pre-started, the value of the environment variable is obtained by analyzing from the deployment file.
In some embodiments, the step S102: determining the operating environment of the target function to be issued according to the function issuing request, wherein the method comprises the following steps:
determining the running environment of the target function according to language information of a code language specified by the function issuing request, wherein the language information at least comprises: the type of language.
The container mirror image warehouse stores pre-developed mirror images of a plurality of languages, and determines the mirror image of the operating environment of the corresponding target function according to the language type of the code language specified by the function issuing request, for example, if the language type is python language, the operating environment is determined to adopt python mirror image, if the language type is nodejs language, the operating environment is determined to adopt nodejs mirror image, and if the language type is golang language, the operating environment is determined to adopt golang mirror image; and if the language type is java, determining that the operating environment adopts java image files.
In some embodiments, the language information further comprises: and version information.
Here, in the container mirror repository, at least one image file storing version information is associated for each language type. For example, for Java language, JDK version 1.0 Java image file, J2SE 1.2 version 1.2 Java image file and Java SE 10 version Java image file are stored in the container image repository. Of course, a specified version of the image file of the desired language type may be pre-stored in the container image repository, depending on the needs of the actual application.
In some embodiments, the function issuing basic service provided by the basic service unit further supports functions of obtaining a context environment, log query, fault tolerance mechanism, function call monitoring and the like, so as to better interface with a Serverless platform.
Specifically, the basic service supports obtaining context information of the function execution environment through context, such as a function name, a language version, a configuration memory, a log library, and the like. Here, the context information of the function execution may be acquired by context, for example, a function name may be acquired by context. Obtaining the running memory configuration through context. Getlogger () acquires a log library, etc.
The base service also supports log query functionality. Generally, based on the related console input and output operation and the log printing operation performed in the target function, the output information is uniformly packaged into a specified format for output, and the compiling is interfaced with the log module of the Serverless platform, so that the call and debugging logs of the function can be retrieved in the log query of the Serverless platform. Here, the basic service intercepts the output of the system, caches the output to a specified memory, and outputs the console output, such as the content of a print, to the log output through a unified loader module by a format.
The base service also supports fault tolerance mechanisms. The written target function usually has code writing errors, which commonly include syntax errors, variable statement errors and the like, a fault-tolerant mechanism is developed by the basic service, when the code errors of the target function are detected, the types of common errors need to be captured, and when the target function is triggered to execute, the code errors are returned in an http mode. Here, for the problem written in the target function code, such as syntax error, no error interrupt is reported in the process of loading the target function, but the error interrupt is directly captured and reported to the client by the way of function call return.
The base service also supports function call monitoring functions. Generally, in the process of calling a target function, calling is often an instant operation, and a monitoring platform cannot accurately acquire hardware resources consumed by current function calling, such as CPU memory consumption and the like. The basic service monitors function calls through an independent memory monitoring process: when the calculation of the target function exceeds the specified memory configuration, actively interrupting the operation of the target function and prompting; meanwhile, aiming at some function calls with too long time consumption, an overtime control function is provided, the problems that the calling time of a target function is too long, a large amount of system resources are consumed and memory leakage is avoided are solved.
In some embodiments, the issued target function obtains a unique internal service address, and the function management and control module registers the function internal service address in the unified gateway service of the cluster. And triggering the execution of the target function service by accessing the uniform gateway of the cluster and by the formulated target function mark. When no event triggers the target function for a period of time, the Serverless platform stops the function service container; once the target function is triggered by an event, the Serverless platform restarts the function service container.
In this embodiment, the Serverless platform may implement arrangement and deployment of a bottom-layer container based on kubernets and kneive, the unified gateway portal may be implemented based on gloo, and the expansion and contraction of the back-end container instance may be dynamically performed according to the request amount.
An embodiment of the present invention further provides a function issuing apparatus 10, as shown in fig. 7, including:
a receiving unit 110, configured to receive a function issuing request;
a determining unit 120, configured to determine, according to the function issuing request, an operating environment of a target function to be issued;
a starting unit 130, configured to start a function service container according to the image file of the operating environment of the objective function;
the publishing unit 140 is configured to continue publishing the target function based on the function service container.
In some embodiments, the starting unit 130 includes:
a first unit, configured to create a service bearer container;
and the second unit is used for adding the mirror image file into the service bearing container to obtain the started function service container.
In some embodiments, the determining unit 120 includes:
a third unit, configured to determine, according to release information carried in the release request, a value of an environment variable corresponding to an operating environment of the objective function;
in some embodiments, the function issuing apparatus 10 further includes:
and the fourth unit is used for assigning the value of the environment variable to the environment variable corresponding to the mirror image file in the function service container.
In some embodiments, the function issuing apparatus 10 further includes:
a fifth unit, configured to determine, according to release information carried in the function release request, a storage address of a function code of the target function;
a sixth unit, configured to pull the function code from the storage address, where the function code is used to be added to the function service container.
In some embodiments, the memory address is stored in a deployment file of the objective function.
In some embodiments, the determining unit 120 includes:
a seventh unit, configured to determine, according to language information of a code language specified by the function issuance request, an execution environment of the objective function, where the language information includes at least: a type of language.
In some embodiments, the language information further comprises: and version information.
An embodiment of the present invention further provides a platform, where the platform includes: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is configured to execute the function calculation program stored in the memory to implement the function issuing method provided by one or more of the foregoing technical solutions.
The embodiment of the invention also provides a computer storage medium, and the computer storage medium stores computer executable instructions; after being executed by a processor, the computer-executable instructions can implement the function issuing method provided by one or more of the technical solutions.
The computer storage medium may be: a storage medium such as a removable storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various media capable of storing program codes may be selected as a non-transitory storage medium.
The following describes a function publishing method and apparatus according to an embodiment of the present invention with a specific example:
as shown in fig. 1, the function issuing apparatus includes: the system comprises a Serverless platform and a multi-language function image file, wherein the Serverless platform comprises a code management module, a function control module and a gateway service module; the container mirror image files comprise python mirror image files, nodejs mirror image files, golang mirror image files and java mirror image files.
The function issuing method provided by the embodiment of the invention is suitable for a typical Serverless platform, and the platform architecture of the method is shown in figure 1. The Serverless platform in the embodiment of the invention comprises a code management module, a function control module, a gateway service module and the like, and is in butt joint with a code warehouse, an SQL database and a container mirror image warehouse.
Wherein, the code warehouse can be generally built by a warehouse such as a gitlab, github, etc. for storing the function code. The user does not need to directly interact with the code warehouse, but submits the developed codes to a Serverless platform, and a code management module of the Serverless platform uploads the function codes to the code warehouse; the database can be provided by an open source database MYSQL and is used for storing code related configuration and function release information; the container mirror image warehouse is used for storing developed multilingual container mirror image files in advance, and comprises python mirror image files, nodejs mirror image files, golang mirror image files and java mirror image files, and the mirror image warehouse can be usually built by a registry or a hardor. Meanwhile, a function operation cluster is usually constructed by kubernets, and a knetive is deployed to provide a bottom-layer Serverless native service. In addition, the unified service gateway shown in the figure can be constructed by gloo deployment and is used for forwarding the trigger event of the access function to the specified function service.
Based on the above system architecture diagram, fig. 8 shows a function publishing method based on a Serverless platform according to an embodiment of the present invention. The method specifically comprises the following steps:
and developing the target function on the Serverless platform, and uploading the function code through the Serverless platform after the development is finished.
And a code management module in the Serverless platform receives the function release request and analyzes the code language version information, the function name, the function call entry and the function context information in the release request. The function code is first stored in a code warehouse, and the information of the target function in the code warehouse is stored in a database.
And after the codes are uploaded successfully, the function control module in the Serverless platform issues the target function. Firstly, function release information including a function language version, a function name, a function call entry and function context information is read from a database.
The function control module analyzes a basic mirror image required by function operation from a database preset mirror image comparison table according to the function language version; determining a pull address of a function in a code warehouse according to the function name; and analyzing information such as hardware configuration, environment variables and the like required by the release function according to the function call entry and the context information. And finally, encapsulating all function release information into a function deployment file.
After the function deployment file is packaged, the function control module continues to call the bottom deployment cluster, and the function deployment file is issued through the Kubernetes and the Kunative API. And after the bottom deployment cluster receives the function release file formulation, releasing the function through the operation container.
The issued target function can obtain a unique internal service address, the function management and control module registers the function internal service address into the unified gateway service of the cluster, and the function service is triggered to execute by accessing the unified gateway of the cluster and by the formulated function mark. When there is no event to trigger the function for a while, the Serverless platform will stop the function service container. Once there is an event triggering function, the Serverless platform restarts the function service container.
The function service container is a core device for function computation, and as shown in fig. 9, mainly includes the following unit modules, a pre-boot unit, a function code loading unit, a basic service boot unit, and a function hot loading unit.
When the container is started by the Serverless platform, the pre-starting unit firstly monitors the environment inside the container, including network configuration check, environment variable analysis and the like. The method mainly analyzes key environment variables required by function operation, including function code warehouse addresses, function call entries, function operation contexts and the like.
And the function code loading unit is used for pulling the target function code to the specified directory according to the function code warehouse address in the environment variable after the container is pre-started for a pre-developed code pulling function. And the code format is checked.
The basic service unit calculates basic service for the function developed by the device in advance, develops according to different code languages, and presets the basic service into a target execution path of the container mirror image. And when the target function code is pulled, automatically starting the basic service, and providing the service for the outside by the basic service in an http mode.
After the basic service is started, firstly, a target function call inlet is configured in an environment variable, and hot loading of a target function code is realized in a specific mode according to a language version preset in the current container environment. The specific loading flow language version depends on.
As shown in fig. 3, for the design method of the preset images in different languages involved in the function publishing method, the following description is made in detail for different language environments:
aiming at the python environment, because python is an interpretive language, codes can run without compiling, and in order to improve the running speed, when an image is manufactured, the codes of basic services server. The basic mirror image of the mirror production is a python source mirror image of a docker community, wherein the python source mirror image comprises a common python library and a pip toolkit. The function runs, first starts the base service through python server. In the basic service, a function call entry is specified through MOD _ NAME and FUNC _ HANDLER environment variables, an object function file index is dynamically loaded in the basic service through imp.
Aiming at the nodejs environment, because nodejs is an interpretive language, codes can run without compiling, and in order to improve the running speed, when a mirror image is manufactured, basic service codes server. And when the mirror image is manufactured, the nodejs mirror image of the docker community open source is selected as a basic mirror image, and the mirror image comprises a development kit and an npm tool which are commonly used by nodejs. When the function runs, the basic service is started directly by executing the server file, in the basic service, a function call entry is specified by MOD _ NAME ═ index.
For the golang environment, since golang is a compiled language, code cannot be directly run. Therefore, after the function code development is completed, the function code index.go needs to be compiled into a plug-in index.so file in advance and uploaded to the Serverless platform. When the mirror image is manufactured, the golang mirror image of the open source of the docker community is selected as a basic mirror image, and the mirror image comprises a development toolkit commonly used by the golang. And when the container is started, firstly, pulling the target function plug-in unit index. And finally, starting the function service in a mode of executing the server file. In the server.go, the target function file is loaded in a plug.open ("index.so") manner, and the target function entry is called in a plug.lookup (FUNC _ dormant) manner.
For the java environment, since java is a compiled language, the run code cannot be executed. Therefore, after the function code is developed, the function code index. When the mirror image is manufactured, the openjdk mirror image of the docker community open source is selected as a basic mirror image, and the mirror image comprises a tool kit based on a java program. And simultaneously, basic service server.java needs to be compiled into a jar packet in advance and preset into an execution path specified in the mirror image. At container startup, a call entry of a function is specified by MOD _ NAME and FUNC _ handle, a target function file is dynamically loaded in a base service by loadJar ("index. jar"), and a call entry HANDLER of the target function is dynamically loaded by class.
In the embodiment of the invention, the basic service in the function computing device provides external access in an http service mode, and transfers the access flow to the target function in a function calling mode. And finally, returning the target function operation interface to the caller through http.
Generally, in the Serverless platform, function publishing is not just a simple target function call. The basic service needs to have a series of additional functions to better interface with the Serverless platform. The method mainly comprises the following functions:
generally, when a function is developed, a mirror image needs to obtain context information of current function operation, which mainly includes functions such as a current function name, operation memory configuration, call time, a log library, and the like. Therefore, the basic service needs to provide a context environment, and the function can directly acquire the information through context, for example, acquiring a function name through context. Acquiring a function configuration memory through context. Getlogger () acquires a log library, etc.
The related console input and output operations performed in the function, and the log printing operation. The output information needs to be uniformly packaged into a specified format for output. The compiling is connected with a log module of the Serverless platform in an abutting mode, and the call and debugging logs of the function can be retrieved in the log query of the Serverless platform. Therefore, the basic service needs to intercept the output of the container environment, cache the output into a designated memory, and output the console, such as the content of the print, into the log output through a formulated format through a unified loader module.
Generally, a written function always has a code writing error, and the common errors include syntax errors, variable declaration errors and the like. When the target function is wrongly written, the operation of the main service cannot be influenced, so that the basic service needs to additionally develop a fault tolerance mechanism, and when a code error of the target function is detected, a common error type needs to be captured. When the trigger function executes, a code error is returned in an http manner.
Generally, in the process of function call, the call is often an instant operation, and the current monitoring platform cannot accurately acquire hardware resources consumed by the current function call, such as CPU memory consumption and the like. Therefore, the basic service needs to monitor the function call through a separate memory monitoring process. And when the function calculation exceeds the specified memory configuration, actively interrupting the function operation and prompting. Meanwhile, aiming at some function calls which take too long time, an overtime control function needs to be provided, so that the problem that a great deal of system resources are consumed due to too long function call time is avoided.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some ports, indirect coupling or communication connection between devices or units, and may be electrical, mechanical or other.
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, that is, may be located in one place, or may be distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may be separately used as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (15)

1. A system platform architecture, comprising:
a code repository for storing function codes;
a database;
the container mirror image warehouse is used for storing the running environment corresponding to at least one code language, wherein the running environment comprises a mirror image file;
the cloud platform is respectively connected with the code warehouse, the database and the container mirror image warehouse and is used for uploading the function codes of the target function to the code warehouse based on the received function issuing request of the target function to be issued; uploading the release information carried by the function release request to the database; and starting a function service container according to the image file of the running environment of the target function, and issuing the target function.
2. The system platform architecture of claim 1, wherein the function service container is a service bearer container.
3. The system platform architecture of claim 2, wherein the function service container is: the service bearing container loaded with the image file.
4. The system platform architecture according to any of claims 1 to 3, wherein the cloud platform is a Serverless platform.
5. The system platform architecture of any one of claims 1 to 3, wherein the image file is a source image corresponding to the code language obtained from a container image repository, and the source image includes a development kit corresponding to the code language.
6. A method for issuing a function, comprising:
receiving a function issuing request;
determining the running environment of the target function to be issued according to the function issuing request;
starting a function service container according to the image file of the running environment of the target function;
and continuing to publish the target function based on the function service container.
7. The method of claim 6,
the starting a function service container according to the image file of the running environment of the target function includes:
creating a service bearer container;
and adding the mirror image file into the service bearing container to obtain the started function service container.
8. The method of claim 7,
the determining the operating environment of the target function to be issued according to the function issuing request comprises the following steps: determining the value of an environment variable corresponding to the operating environment of the target function according to release information carried by the release request;
the method further comprises the following steps:
and assigning the value of the environment variable to the environment variable corresponding to the mirror image file in the function service container.
9. The method according to any one of claims 6 to 8, further comprising:
determining a storage address of a function code of the target function according to release information carried by the function release request;
and pulling the function code from the storage address, wherein the function code is used for being added into the function service container.
10. The method of claim 9, wherein the memory address is stored in a deployment file of the objective function.
11. The method according to claim 6, wherein the determining, according to the function publishing request, the execution environment of the target function to be published comprises:
determining the running environment of the target function according to language information of a code language specified by the function issuing request, wherein the language information at least comprises: the type of language.
12. The method of claim 11, wherein the language information further comprises: and (4) version information.
13. A function issuing apparatus, comprising:
a receiving unit, configured to receive a function issuing request;
the determining unit is used for determining the operating environment of the target function to be issued according to the function issuing request;
the starting unit is used for starting the function service container according to the mirror image file of the running environment of the target function;
and the issuing unit is used for continuing issuing the target function based on the function service container.
14. A platform, characterized in that the platform comprises: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is configured to execute a function calculation program stored in the memory to implement the method of any one of claims 6 to 12.
15. A computer storage medium having stored thereon computer-executable instructions; the computer-executable instructions, when executed, enable the method of any one of claims 6 to 12.
CN202110129777.8A 2021-01-29 2021-01-29 System platform architecture, function publishing method and device, platform and storage medium Pending CN114816445A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110129777.8A CN114816445A (en) 2021-01-29 2021-01-29 System platform architecture, function publishing method and device, platform and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110129777.8A CN114816445A (en) 2021-01-29 2021-01-29 System platform architecture, function publishing method and device, platform and storage medium

Publications (1)

Publication Number Publication Date
CN114816445A true CN114816445A (en) 2022-07-29

Family

ID=82525601

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110129777.8A Pending CN114816445A (en) 2021-01-29 2021-01-29 System platform architecture, function publishing method and device, platform and storage medium

Country Status (1)

Country Link
CN (1) CN114816445A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115562690A (en) * 2022-12-05 2023-01-03 杭州未名信科科技有限公司 Algorithm service processing method, device and medium based on Docker container

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115562690A (en) * 2022-12-05 2023-01-03 杭州未名信科科技有限公司 Algorithm service processing method, device and medium based on Docker container

Similar Documents

Publication Publication Date Title
CN110413288B (en) Application deployment method, device, server and storage medium
JP6182160B2 (en) Dynamic code insertion into a running process
CN110187910B (en) Thermal updating method, device, equipment and computer readable storage medium
US20160232017A1 (en) System and Method for Reloading Constructors
US20080127054A1 (en) Connecting with an application instance
CN109542506B (en) System capable of flexibly configuring interface and rapidly delivering service
US20030149799A1 (en) System supporting unified event handling in ECMAScript
WO2019079080A1 (en) Using semantic annotations to control compatibility behaviors
CN111176722B (en) Method, device and storage medium for detecting file version of third party library
US11537367B1 (en) Source code conversion from application program interface to policy document
CN110688174A (en) Container starting method, storage medium and electronic device
CN112214388A (en) Memory monitoring method, device, equipment and computer readable storage medium
US9218139B2 (en) Minimally disruptive virtual machine snapshots
CN112256351B (en) Method for realizing Feign component, method and device for calling micro-service
KR20110130611A (en) Web platform unit for mobile terminal connectioned web-application program in heterogeneous operating system
CN114816445A (en) System platform architecture, function publishing method and device, platform and storage medium
CN108228266B (en) Method and device for starting Fragment component between different plug-ins under Android plug-in framework
KR102337962B1 (en) System and method for executing application based on microservice architecture and computer program for the same
US10394610B2 (en) Managing split packages in a module system
CN111090442A (en) Application updating method and device and storage medium
WO2011157105A2 (en) Method and device for component expansion
CN111459547B (en) Method and device for displaying function call link
CN111273940B (en) Method and device for uploading program file to code warehouse
CN109358972B (en) Log management method and device of middleware client and computer system
KR102485154B1 (en) Power Communication Service

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