Cloud platform and program code processing method based on cloud platform
By setting tags in the program code, the cloud platform automatically creates and manages virtual instances to run subprogram code, solving the problems of complex large-scale computing methods and poor user experience in the existing technology, and achieving more efficient and simple cloud resource utilization.
Patent Information
- Application Number
- CN202110394141.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-09-30
- Filing Date
- 2021-04-13
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-04-13
AI Technical Summary
The existing methods of using cloud services to complete large-scale computing are complex and the user experience is poor. Tenants need to manually log in to the cloud platform, configure virtual machines, and run program code.
Provides a cloud service-based program code processing method. By setting tags in the program code, the cloud platform automatically creates or selects virtual instances and runs subroutine code to reduce the operation steps of tenants.
It improves the experience of programmers using cloud resources for program development. Tenants do not need to log in to virtual instances. The cloud platform automatically configures virtual instances, simplifies the operation process, and improves resource utilization efficiency and user experience.
Smart Images

Figure CN114327742B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud technologies, and in particular, to a cloud platform and a program code processing method based on the cloud platform. Background Art
[0002] At the current stage, cloud computing is becoming increasingly popular and is an inevitable trend in the development of future information technologies. Cloud computing services are provided by cloud service providers to offer basic cloud services, and tenants can use the basic cloud services through the Internet. For example, a cloud service provider configures servers in its own operating cloud data center, and a tenant can obtain the remote usage right of a virtual machine with a specific specification in the server by paying the cloud service provider, thereby realizing the use of the basic cloud service. Cloud services are not limited to virtual machines and may also include object storage services, database services, security services, face recognition services, and so on. Cloud computing services can enable tenants to skip the cumbersome server configuration process and obtain the basic cloud services provided by cloud service providers by paying.
[0003] Due to the popularity of cloud computing, during the process of developing large-scale computing programs, programmers can also utilize the computing power provided by cloud services. For example, programmers can respectively set up multiple virtual machines, write the program code that has been pre-split by the programmers into the multiple virtual machines, and make the multiple virtual machines run the program code respectively. Finally, the programmers collect the running results of the program code in the multiple virtual machines, thereby realizing the running of large-scale computing programs by using the computing power provided by cloud services. For example, Hadoop and Spark under the MapReduce architecture are good ways to complete large-scale computing.
[0004] However, the current method of using cloud services to complete large-scale computing is still relatively complex in use. It requires tenants to log in to the cloud platform, input the configuration of the required virtual machines through the interfaces provided by the cloud platform to create virtual machines, log in to the created virtual machines, and set the virtual machines to run specific program code, resulting in a poor user experience. Summary of the Invention
[0005] This application provides a cloud platform and a program code processing method based on the cloud platform, which can improve the experience of programmers using cloud resources for program development.
[0006] In a first aspect, the present application provides a method for processing program code based on cloud services. The cloud platform can receive the program code of a tenant and process it. Specifically, it includes the following steps: The cloud platform obtains the program code of the tenant. The program code includes a first tag and subroutine code. The first tag is used to indicate the configuration information of the virtual instance for running the subroutine code. The cloud platform creates or selects one or more first virtual instances according to the first tag. The cloud platform sends the subroutine code to one or more first virtual instances respectively. The cloud platform receives the first running results obtained by one or more first virtual instances running the subroutine code respectively.
[0007] When the tenant writes the program code, a first tag for indicating the configuration information of the virtual instance for running the subroutine code can be set in the program code. The cloud platform obtains the program code. The cloud platform creates or selects at least one virtual instance according to the first tag to run the subroutine code and receives the first running results obtained by at least one virtual instance running the subroutine code. Therefore, the tenant can mark the program code, which can notify the cloud platform to create the corresponding virtual instance and run the subroutine code. Without changing the existing programming habits, the cloud resources can be effectively utilized to run the subroutine code, and the user experience can be improved.
[0008] Moreover, the tenant does not need to log in to the first virtual instance. The first virtual instance is configured by the cloud platform in the background, which can further improve the user experience.
[0009] Among them, the tag is also used to separate different subroutine codes so that the cloud platform can confirm different subroutine codes through the tag.
[0010] Optionally, the configuration information includes the virtual instance specification.
[0011] Among them, the virtual instance specification includes the number of processor cores of the virtual instance, the main frequency size of the processor, and the memory size.
[0012] During the programming process, the tenant marks the program code and sets the specification of the virtual instance to be created in the configuration information indicated by the tag. When the computing power required to run the subroutine code is high, the virtual instance specification can be set to a high specification. When the computing power required to run the subroutine code is low, the virtual instance specification can be set to a low specification. Thus, the technical effect of flexibly utilizing cloud resources to run subroutine code can be achieved. Since the virtual instance specification is proportional to the selling price of the virtual instance, the tenant can also reasonably set the virtual instance specification according to the computing power of the cloud resources required by setting the tag, thereby effectively saving the cost of purchasing cloud resources from the cloud platform.
[0013] Optionally, the configuration information includes the virtual instance type, and the virtual instance type is used to indicate any one of a virtual machine, a container, and a bare metal server.
[0014] During the programming process, the tenant marks the program code and sets the type of virtual instance to be created in the configuration information indicated by the mark. The type can be, for example, a virtual machine, a container, or a bare metal server. Thus, the technical effect of flexibly utilizing cloud resources to run subroutine code can be achieved. Since the selling prices of different virtual instance types, such as virtual machines, containers, and bare metal servers, are different, the tenant can also reasonably select the virtual instance type according to the computing power of the cloud resources required by setting the mark, thereby effectively saving the cost of purchasing cloud resources from the cloud platform.
[0015] Among them, for large-scale operations, the tenant can choose a virtual machine or a bare metal server. These two types of virtual instances run stably. For small-scale operations, the tenant can choose a container.
[0016] Optionally, the configuration information includes the number N of virtual instances, where N is a positive integer.
[0017] During the programming process, the tenant marks the program code and sets the number of virtual instances to be created in the configuration information indicated by the mark. This number is used to indicate the number of virtual instances running the subroutine code. When N is set to a plural number, the subroutine code runs on multiple virtual instances. For big data scenarios, parallel computing is an important data processing method. The tenant can mark the number of virtual instances running a specific subroutine code in the program code, enabling multiple virtual instances to run the subroutine code in parallel. Therefore, the cloud platform can provide the tenant with the ability of parallel programming.
[0018] Optionally, the number of the first virtual instances is multiple, and the subroutine code is used to indicate that the multiple first virtual instances respectively obtain different data to be processed from the shared storage space and respectively perform data processing on the obtained data to be processed.
[0019] Based on the scenario where multiple virtual instances run the subroutine code in parallel, through the writing of the subroutine code, the tenant makes the subroutine code used to indicate that the multiple first virtual instances respectively obtain different data to be processed from the shared storage space and respectively perform data processing on the obtained data to be processed. Therefore, the multiple first virtual instances can run the same subroutine code for different data to be processed to implement the same program logic and achieve parallel computing.
[0020] Optionally, the program code further includes nested program code and a second tag. The second tag is used to indicate the configuration information of the virtual instance that runs the nested program code. The nested program code is called by the subprogram code. The above method further includes the following steps: The cloud platform creates or selects one or more second virtual instances according to the second tag, and sends the nested program code to the one or more second virtual instances respectively. The cloud platform receives the second running results obtained by the one or more second virtual instances running the nested program code respectively, and sends the second running results to the first virtual instance.
[0021] In this implementation manner, when the subprogram code calls another subprogram code, this another subprogram code is called nested program code. The second tag indicates the configuration information of the virtual instance that runs the nested program code. The cloud platform creates or selects one or more second virtual instances according to the configuration information indicated by the second tag, sends the nested program code to the one or more second virtual instances to run, and sends the obtained second running results to the first virtual instance. Therefore, in this implementation manner, in the case of subprogram code nesting, the cloud platform obtains the running results from the virtual instance that runs the nested program code and sends them to the virtual instance that runs the subprogram code that calls the nested program code, so that the running results of the nested program code can reach the first virtual instance. The first virtual instance continues to run the subprogram code according to the running results, thereby realizing the nesting of the program code.
[0022] Optionally, the program code further includes main program code. The subprogram code is called by the main program code. The method further includes the following steps: When the cloud platform runs the main program code to the position where the subprogram code needs to be called, it requests the first running result from one or more first virtual instances. The cloud platform continues to run the main program code according to the first running result.
[0023] In this implementation manner, the cloud platform directly runs the main program code. When running to the position where the main program code calls the subprogram code, the cloud platform does not run the subprogram code, but requests the first running result from the first virtual instance that runs the subprogram code, and continues to run the main program code according to the obtained first running result by the request. By directly running the main program code by the cloud platform and communicating with the virtual instance that runs the subprogram code, the whole process of the main program code calling the subprogram code can be realized, thus ensuring that the programming habits of the tenants remain unchanged.
[0024] Optionally, the above method further includes the following steps: The cloud platform provides an upload interface, and the upload interface is used to receive the program code uploaded by the tenant, or the cloud platform provides a program editing interface, and the program editing interface is used to receive the program code remotely input by the tenant.
[0025] In this implementation, after the tenant writes the program code locally, the program code can be uploaded to the cloud platform through the upload interface. Alternatively, the tenant can directly input the program code remotely in the program editing interface provided by the cloud platform, so as to realize online programming on the cloud platform.
[0026] Among them, the above two methods can be provided to the tenant at the same time. The tenant can choose one method according to their own programming habits, so as to further improve the user experience.
[0027] Optionally, the method further includes the following steps: The cloud platform provides cloud services and sets up cloud service application programming interfaces (APIs) for the cloud services. Among them, the cloud service APIs are set in the subprogram code, and the cloud service APIs are used to call the cloud services provided by the cloud platform.
[0028] In this implementation, when writing the subprogram code, the tenant can call the cloud service APIs provided by the cloud platform, so as to make full use of the cloud resources provided by the cloud services.
[0029] Optionally, the cloud service APIs include one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
[0030] Optionally, the first tag and the second tag are annotations of the subprogram code, or the first tag and the second tag are program codes adjacent to the subprogram code and using a predetermined syntax.
[0031] In this implementation, the first tag and the second tag can be set as annotations of the subprogram code. For example, before or after the program code, they are marked with symbols such as @, \, / , / / or other symbols pre-agreed with the cloud platform, and the configuration information such as the type, specification, and quantity of the virtual instance is input in a predetermined format after the symbol. When the cloud platform detects the symbol, it creates a virtual instance according to the type, specification, and quantity of the virtual instance indicated after the symbol, and sends the subprogram code to let the virtual instance run. Through the annotation, without changing the tenant's programming habits, the tenant only needs to input the symbol before or after the subprogram code and input the configuration information after the symbol, so as to realize running the subprogram code using the virtual instance on the cloud side.
[0032] The first tag and the second tag can be set as program codes that adopt a predetermined syntax and are adjacent to the subroutine code. For example, if the cloud platform stipulates that the function creatvirtualinstance(type, spec, N) that adopts a predetermined syntax is used as a tag, then the tenant can call creatvirtualinstance(type, spec, N) at a position adjacent to the subroutine code (before or after the subroutine) during the process of writing the program code, and input one or any combination of the type type, specification spec, and quantity N of the virtual instance according to its own needs, so as to mark the subroutine code, and make the subroutine code run in the virtual instance created or selected by the cloud platform according to one or any combination of the type type, specification spec, and quantity N.
[0033] In a second aspect, the present application provides a method for processing program codes based on cloud services, including the following steps: The cloud platform receives the subroutine code and the first tag sent by the business virtual instance running the main program code, where the subroutine code is called by the main program code, and the first tag is used to indicate the configuration information of the virtual instance running the subroutine code. The cloud platform creates or selects one or more first virtual instances according to the first tag, the cloud platform sends the subroutine code to the one or more first virtual instances, the cloud platform receives the first running results obtained by the one or more first virtual instances running the subroutine code respectively and sends the first running results to the business virtual instance.
[0034] Compared with the first aspect, the main program code can be directly run on the tenant's business virtual machine. The business virtual machine sends the subroutine code called by the main program code and the first tag to the cloud platform. The cloud platform creates or selects at least one virtual instance according to the first tag to run the subroutine code, receives the first running results obtained by the at least one virtual instance running the subroutine code, and sends the first running results to the business virtual instance, so that the business virtual instance can continue to run the main program according to the first running results. Therefore, the tenant can notify the cloud platform to create the corresponding virtual instance and run the subroutine code by marking. Without changing the existing programming habits, the cloud resources can be effectively utilized to run the subroutine code, and the user experience can be improved.
[0035] Optionally, the configuration information includes the virtual instance specification.
[0036] Wherein, the virtual instance specification includes the number of processor cores of the virtual instance, the size of the processor main frequency, and the size of the memory.
[0037] During the programming process, the tenant marks the program code and sets the specifications of the virtual instance to be created in the configuration information indicated by the mark. When the computing power required to run the subroutine code is high, the virtual instance specifications can be set to high specifications. When the computing power required to run the subroutine code is low, the virtual instance specifications can be set to low specifications. Thus, the technical effect of flexibly utilizing cloud resources to run the subroutine code can be achieved. Since the virtual instance specifications are proportional to the selling price of the virtual instance, the tenant can also reasonably set the virtual instance specifications according to the cloud resource computing power required, thereby effectively saving the cost of purchasing cloud resources from the cloud platform.
[0038] Optionally, the configuration information includes the virtual instance type, which is used to indicate any one of a virtual machine, a container, and a bare metal server.
[0039] During the programming process, the tenant marks the program code and sets the type of the virtual instance to be created in the configuration information indicated by the mark. The type is, for example, a virtual machine, a container, or a bare metal server. Thus, the technical effect of flexibly utilizing cloud resources to run the subroutine code can be achieved. Since the selling prices of different virtual instance types, such as virtual machines, containers, and bare metal servers, are different, the tenant can also reasonably select the virtual instance type according to the cloud resource computing power required by setting the mark, thereby effectively saving the cost of purchasing cloud resources from the cloud platform.
[0040] Among them, for large-scale operations, the tenant can choose a virtual machine or a bare metal server, and the running states of these two virtual instances are stable. For small-scale operations, the tenant can choose a container.
[0041] Optionally, the configuration information includes the number N of virtual instances, where N is a positive integer.
[0042] During the programming process, the tenant marks the program code and sets the number of virtual instances to be created in the configuration information indicated by the mark. This number is used to indicate the number of virtual instances running the subroutine code. When N is set to a plural number, the subroutine code runs in multiple virtual instances. For big data scenarios, parallel computing is an important data processing method. The tenant can mark the number of virtual instances running a specific subroutine code in the program code, and let multiple virtual instances run the subroutine code in parallel. Thus, the cloud platform can provide the tenant with the ability of parallel programming.
[0043] Optionally, the subroutine code is used to instruct one or more first virtual instances to respectively obtain different data to be processed from the shared storage space and respectively perform data processing on the obtained data to be processed.
[0044] In the scenario of running subroutine code in parallel based on multiple virtual instances, the tenant writes the subroutine code to instruct one or more first virtual instances to respectively obtain different data to be processed from the shared storage space and respectively perform data processing on the obtained data to be processed. Therefore, one or more first virtual instances can run the same subroutine code for different data to be processed to implement the same program logic and achieve parallel computing.
[0045] Optionally, the above method further includes the following steps: The cloud platform receives the nested program code and the second tag sent by the business virtual instance in operation. The second tag is used to indicate the configuration information of the virtual instance running the nested program code. The nested program code is called by the subroutine code. The cloud platform creates or selects one or more second virtual instances according to the second tag, and sends the nested program code to the one or more second virtual instances. The cloud platform obtains one or more second running results generated by the one or more second virtual instances running the second program code, and sends the second running results to the first virtual instance.
[0046] In this implementation manner, when the subroutine code calls another subroutine code, the other subroutine code is called the nested program code. The second tag indicates the configuration information of the virtual instance running the nested program code. The cloud platform creates or selects one or more second virtual instances according to the configuration information indicated by the second tag, and sends the nested program code to the one or more second virtual instances to run, and sends the obtained second running results to the first virtual instance. Therefore, in this implementation manner, in the case of subroutine code nesting, the cloud platform obtains the running results from the virtual instance running the nested program code and sends them to the virtual instance running the subroutine code that calls the nested program code, so that the running results of the nested program code can reach the first virtual instance, and the first virtual instance continues to run the subroutine code according to the running results, thereby realizing program code nesting.
[0047] Optionally, the method further includes the following steps: The cloud platform provides cloud services and sets a cloud service application programming interface (API) for the cloud services. The cloud service API is set in the subroutine code, and the cloud service API is used to call the cloud services provided by the cloud platform.
[0048] In this implementation manner, when the tenant writes the subroutine code, the cloud service API provided by the cloud platform can be called, so as to make full use of the cloud resources provided by the cloud services.
[0049] Optionally, the cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
[0050] Optionally, the first tag is an annotation of the subroutine code, or the first tag is program code that adopts a predetermined syntax and is adjacent to the subroutine code.
[0051] In this implementation, the first tag and the second tag can be set as annotations of the subroutine code. For example, before or after the program code, they are marked with symbols such as @, \, / , / / or other symbols pre-agreed with the cloud platform, and the configuration information such as the type, specification, and quantity of the virtual instance is input in a predetermined format after the symbol. When the cloud platform detects this symbol, it creates a virtual instance according to the type, specification, and quantity of the virtual instance indicated after the symbol, and sends the subroutine code for the virtual instance to run. Through the annotation, without changing the programming habits of the tenant, the tenant only needs to input the symbol before or after the subroutine code and input the configuration information after the symbol to realize running the subroutine code using the virtual instance on the cloud side.
[0052] The first tag and the second tag can be set as program code that adopts a predetermined syntax and is adjacent to the subroutine code. For example, if the cloud platform agrees to use a function creatvirtualinstance(type, spec, N) with a predetermined syntax as the tag, then the tenant can call creatvirtualinstance(type, spec, N) at a position adjacent to the subroutine code (before or after the subroutine code) during the process of writing the program code, and input one or any combination of the type type, specification spec, and quantity N of the virtual instance according to his own needs, so as to mark the subroutine code and make the subroutine code run in the virtual instance created or selected by the cloud platform according to one or any combination of the type type, specification spec, and quantity N.
[0053] In a third aspect, the present application provides a cloud platform, including: a cloud service providing unit, configured to obtain the program code of the tenant, where the program code includes a first tag and subroutine code, and the first tag is used to indicate the configuration information of the virtual instance for running the subroutine code; a cloud program execution unit, configured to create or select one or more first virtual instances according to the first tag, send the subroutine code to the one or more first virtual instances respectively, and receive first running results obtained by the one or more first virtual instances running the subroutine code respectively.
[0054] The third aspect or any implementation manner of the third aspect is the method implementation corresponding to the first aspect or any implementation manner of the first aspect. The descriptions in the first aspect or any implementation manner of the first aspect are applicable to any implementation manner of the third aspect or any implementation manner of the third aspect, and will not be elaborated here.
[0055] Fourth aspect, the present application provides a cloud platform, including: a cloud service providing unit for creating a business virtual instance, the business virtual instance being used to run the main program code; a cloud program execution unit for receiving the subprogram code and the first tag sent by the business virtual instance, where the subprogram code is called by the main program code, and the first tag is used to indicate the configuration information of the virtual instance for running the subprogram code, creating or selecting one or more first virtual instances according to the first tag, sending the subprogram code to the one or more first virtual instances, receiving the first operation results obtained by the one or more first virtual instances running the subprogram code respectively and sending the first operation results to the business virtual instance.
[0056] The fourth aspect or any implementation manner of the fourth aspect is implemented by the method corresponding to the second aspect or any implementation manner of the second aspect. The descriptions in the fourth aspect or any implementation manner of the fourth aspect are applicable to any implementation manner of the second aspect or any implementation manner of the second aspect, and will not be elaborated herein.
[0057] Fifth aspect, the present application provides a computer device, including: a processor and a memory, the memory is used to store computer execution instructions, and the processor is used to execute the computer execution instructions stored in the memory, so that the computer device implements the method disclosed in the first aspect and any possible implementation manner of the first aspect or so that the computer device implements the method disclosed in the second aspect and any possible implementation manner of the second aspect.
[0058] Sixth aspect, a computer storage medium of the present application includes computer-readable instructions, which when executed, implement the method disclosed in the first aspect and any possible implementation manner of the first aspect or implement the method disclosed in the second aspect and any possible implementation manner of the second aspect.
[0059] Seventh aspect, a computer program product containing instructions, when running on a computer, causes the computer to execute the method disclosed in the first aspect and any possible implementation manner of the first aspect or causes the computer to execute the method disclosed in the second aspect and any possible implementation manner of the second aspect. Description of the Drawings
[0060] Figure 1 is a schematic internal structure diagram of a data center according to an embodiment of the present invention;
[0061] Figure 2 is a schematic system architecture diagram of a program code processing system according to an embodiment of the present invention;
[0062] Figure 3 is another schematic system architecture diagram of a program code processing system according to an embodiment of the present invention;
[0063] Figure 4 It is a data interaction diagram of the program code processing method according to an embodiment of the present invention;
[0064] Figure 5 It is another schematic diagram of the system architecture of the program code processing system according to an embodiment of the present invention;
[0065] Figure 6 It is another schematic diagram of the system architecture of the program code processing system according to an embodiment of the present invention;
[0066] Figure 7 It is another data interaction diagram of the program code processing method according to an embodiment of the present invention;
[0067] Figure 8 It is a schematic diagram of the structure of the storage node according to an embodiment of the present invention;
[0068] Figure 9 It is a schematic diagram of the structure of the computing node according to an embodiment of the present invention;
[0069] Figure 10 It is another schematic diagram of the structure of the computing node according to an embodiment of the present invention;
[0070] Figure 11 It is another schematic diagram of the structure of the computing node according to an embodiment of the present invention;
[0071] Figure 12 It is a schematic diagram of the device structure of the computer device according to an embodiment of the present invention. Detailed implementation manners
[0072] Next, the technical solutions in the embodiments of the present invention will be described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0073] To facilitate the understanding of the embodiments of the present application, first, some terms related to the present application will be explained.
[0074] Cloud platform: It is used to provide an interface related to cloud services for tenants to remotely access cloud services. Tenants can log in to the cloud platform on the cloud service access page with the pre-registered account password. After successful login, they can select and purchase the corresponding cloud services on the cloud service access page. Cloud services such as object storage services, virtual machine services, container services, etc. In the embodiments of the present invention, the cloud platform can provide cloud services for processing the program code of tenants.
[0075] Business Logic: That is, the logic of the program, which describes what the program does. Software engineers write source code, and during the execution of the source code, the business logic is executed. For statically compiled programming languages, the source code developed by software engineers is usually compiled by a compiler into executable binary-format object code and then executed by the computer's processor. For interpreted programming languages, the source code is usually parsed by a script parser to generate object code for execution by the computer's processor. The business logic mentioned in the embodiments of the present invention is the logic of software operation, specifically what the source code asks the computer to do.
[0076] Program Code: In the embodiments of the present invention, the program code can be source code or object code, specifically depending on different application scenarios (which will be described in detail below).
[0077] Compilation: In the embodiments of the present invention, the program code involved can be compiled according to the programming language it uses. When the program code is a scripting language, such as python, java, ruby, etc., in Embodiment 1 described below, the program code is source code, and the tenant can directly upload the uncompiled source code to the cloud platform. The cloud program execution agent in the main program execution unit 30 of the cloud platform dynamically compiles the main program code, the cloud program execution agent of virtual instance 1 dynamically compiles program code 1, and the cloud program execution agents of virtual instances 2-5 respectively dynamically compile program code 2. In Embodiment 2, the cloud program execution agent in the business virtual instance dynamically compiles the main program code, the cloud program execution agent of virtual instance 1 dynamically compiles program code 1, and the cloud program execution agents of virtual instances 2-5 respectively dynamically compile program code 2. A script parser is provided in the cloud program execution agent, and the above dynamic compilation can compile the scripting language into a bytecode file (i.e., object code) that the script parser can run.
[0078] Optionally, in Embodiment 1, the program code is object code, and the tenant can use a script parser to compile the program code locally, compile the main program code, program code 1, and program code 2 into bytecode files, and then upload the bytecode files to the cloud platform. In Embodiment 2, the tenant can use a script parser to compile the program code in the business virtual machine, compile the main program code, program code 1, and program code 2 into bytecode files, and send the bytecode files of program code 1 and program code 2 to the cloud platform. The cloud platform then sends the bytecode file of program code 1 to virtual machine 1 for execution and the bytecode file of program code 2 to virtual machines 2-5 for execution.
[0079] When the program code is a non-script language, such as C++, in Embodiment 1, the program code is source code. The tenant can directly upload the uncompiled source code to the cloud platform. The cloud program execution agent in the main program execution unit 30 of the cloud platform performs static compilation on the main program code, the cloud program execution agent of virtual instance 1 performs static compilation on program code 1, and the cloud program execution agents of virtual instances 2-5 perform static compilation on program code 2 respectively. In Embodiment 2, the cloud program execution agent in the business virtual instance performs static compilation on the main program code, the cloud program execution agent of virtual instance 1 performs static compilation on program code 1, and the cloud program execution agents of virtual instances 2-5 perform static compilation on program code 2 respectively. A compiler is set in the cloud program execution agent, and the above static compilation can compile the source code into a binary executable file (i.e., object code).
[0080] Optionally, in Embodiment 1, the program code is object code. The tenant can compile the program code locally using a compiler, compile the main program code, program code 1, and program code 2 into binary executable files, and then upload the binary executable files to the cloud platform. In Embodiment 2, the tenant can compile the program code using a compiler in the business virtual machine, compile the main program code, program code 1, and program code 2 into binary executable files, and send the binary executable files of program code 1 and program code 2 to the cloud platform. The cloud platform then sends the binary executable file of program code 1 to virtual machine 1 for running and sends the binary executable file of program code 2 to virtual machines 2-5 for running.
[0081] It should be noted that virtual machines 1-5, main program execution unit 30, and cloud program execution agent designed above will be introduced in detail below.
[0082] Virtual instance: A virtual instance is configured by the cloud platform and has a running environment, which includes an operating system and applications. A virtual instance can be, for example, a virtual machine, a container, or a bare metal server.
[0083] Business virtual instance: A virtual instance created by the tenant himself on the cloud platform. The tenant can remotely log in to the business virtual instance through a client and run program code on the business virtual instance. The business virtual instance can be used as the tenant's production environment or test environment.
[0084] Main program code, abbreviated as the main program, also known as the main function. In many imperative programming languages, the main function is where the program starts running.
[0085] Subroutine code: A part of a large program, consisting of one or more statement blocks. It is responsible for completing a specific task and has relative independence compared to other code. In some cases, it has input parameters, and the subroutine code has a return value (i.e., the running result). The subroutine code can be called by the main program code, and the subroutine code can also be called by another subroutine code. Nested program code: Refers to the subroutine code that is called within a subroutine code, which is the called subroutine code.
[0086] Mark: A way of marking program code pre-agreed by the cloud platform. The cloud platform can provide the usage method and format of the mark, allowing tenants to add marks to the program code when writing the program code.
[0087] The mark has the function of separating subroutine code. The mark is set adjacent to the subroutine code and is used to identify that the subroutine code is the program code to be executed by a virtual instance with the configuration information indicated by the mark. One implementation of the mark is an annotation of the subroutine code. For example, before or after the program code, it is marked with @, \, / , / / or other symbols pre-agreed with the cloud platform, and the type, specification, quantity, etc. of the virtual instance are input in a predetermined format after the symbol. When the cloud platform detects this symbol, it creates a virtual instance according to the type, specification, quantity of the virtual instance indicated after the symbol, and sends the subroutine code for the virtual instance to run. Through the annotation, without changing the programming habits of the tenant, the tenant only needs to input the symbol before or after the subroutine code and input the configuration information after the symbol to realize running the subroutine code using the virtual instance on the cloud side. The mark can also be set as program code that adopts a predetermined syntax and is adjacent to the subroutine code. For example, the cloud platform agrees to use the function creatvirtualinstance(type, spec, N) with a predetermined syntax as the mark. Then, during the process of writing the program code, the tenant can call creatvirtualinstance(type, spec, N) at a position adjacent to the subroutine code (before or after the subroutine code) and input one or any combination of the type type, specification spec, quantity N of the virtual instance according to their own needs to mark the subroutine code, so that the subroutine code runs in a virtual instance created or selected by the cloud platform according to one or any combination of the type type, specification spec, quantity N.
[0088] Please refer to Figure 1 , Figure 1 It is a schematic internal structure diagram of the data center according to an embodiment of the present invention. As Figure 1 shown, the cloud platform is set in the data center. The cloud platform is respectively connected to multiple storage nodes 201, 202... and multiple computing nodes 301, 302 through the switching device 203.
[0089] The client accesses the cloud platform, and the tenant operates the client to access the cloud services provided by the cloud platform.
[0090] Among them, the client can be, for example, a terminal device that can be operated by the tenant and can access the Internet, such as a personal computer, a mobile phone, a tablet computer, a vehicle-mounted host, etc. The client accesses the data center through the Internet and accesses the services provided by the cloud platform set in the data center.
[0091] Both the storage node and the computing node can be implemented by physical servers. The storage node can provide shared storage space, such as an Object Storage Service (OBS) bucket, a shared cache, or a shared database. The storage node is implemented by a server with multiple physical disks. The cloud platform can configure virtual instances on the computing node, and the virtual instances are, for example, virtual machines, containers, and bare metal servers.
[0092] The cloud platform is used to provide an interface or an interface related to the cloud service for the tenant to remotely access the cloud service. The tenant can log in to the cloud platform through a pre-registered account password. After successful login, the tenant can select and purchase the corresponding cloud service on the cloud service access page provided by the cloud platform. The cloud service is, for example, an object storage service, a virtual machine service, a container service, etc. In the embodiment of the present invention, the cloud platform can provide a cloud service for processing the program code of the tenant.
[0093] The following will be based on Figure 1 to specifically describe different embodiments respectively.
[0094] Embodiment 1:
[0095] In this embodiment, the tenant can upload the program code to the cloud platform or directly write the program code on the cloud platform. Some of the program code in the program code is annotated with the configuration information of the virtual instance. The cloud platform configures the virtual instance according to the configuration information, executes this part of the program code through the virtual instance, and obtains the running result of this part of the program code from the virtual instance. Finally, the cloud platform notifies the tenant of the running result of the program code.
[0096] First, please refer to Figure 2 , Figure 2 which is a schematic diagram of the system architecture of the program code processing system according to the embodiment of the present invention. As Figure 2 shown, the program code processing system includes a data center and a client, and a cloud platform and a shared storage space are set in the data center.
[0097] The cloud platform includes a cloud service providing unit 10, a cloud program execution unit 20, and a main program execution unit 30. Among them, the cloud service providing unit 10 is used to provide cloud services to tenants. The cloud service providing unit 10 includes a virtual instance service interface 101, a program code service interface 102, and a shared storage service interface 103. Among them, the client can access the virtual instance service interface 101 to notify the cloud service providing unit 10 to create a virtual instance accessible to the tenant in the data center; and, the client can access the shared storage service interface 103 to notify the cloud service providing unit 10 to create a shared storage space accessible to the tenant in the data center. The tenant can upload data to the shared storage space and download data from the shared storage space; the client can also access the program code service interface 102. The client can upload the tenant's program code to the cloud platform through the upload interface provided by the program code service interface 102. The cloud platform processes the program code uploaded by the tenant on the data center side. Or, the tenant can operate the client to access the program editing interface provided by the program code service interface 102 to realize online programming code writing in the cloud platform. The cloud platform processes the program code written online by the tenant on the data center side.
[0098] For example, the shared storage space can be, for example, based on an OBS bucket, a shared cache, or a shared database. The virtual instance can be, for example, a virtual machine, a container, or a bare metal server. The program code can be, for example, java, C++, python, ruby, or any other common programming language.
[0099] Among them, the shared storage space can be provided by Figure 1 the storage nodes shown.
[0100] The main program execution unit 30 includes a cloud program execution agent. The main program execution unit 30 is used to run the main program code. The cloud program execution agent is used to communicate with other cloud program execution agents and execute the program code with marked annotations.
[0101] Among them, the main program execution unit 30 may not be used. The cloud platform can directly use a virtual instance equipped with a cloud program execution agent to run the main program code.
[0102] In this embodiment, the tenant can edit the program on the program editing interface provided by the program code service interface 102, or directly edit the program code locally, and send the edited program code to the upload interface provided by the program code service interface 102 through the client. Among them, the cloud platform will provide instructions to the tenant, so that during the process of editing the program code, the tenant uses a predetermined mark to notify the cloud platform that a specified part of the program code needs to be executed by the virtual instance configured by the cloud platform. The program code service interface 102 can send the program code to the cloud program execution unit 20. The cloud program execution unit 20 sends the main program code in the program code to the main program execution unit 30 for execution, identifies the mark, configures the virtual instance according to the configuration information indicated by the mark, and sends the part of the program code indicated by the mark to the configured virtual instance for execution, so as to realize the execution of the program code in the cloud, which can reduce the computing load of the client and does not need to change the programming habits of the tenant, thus improving the programming experience of the tenant.
[0103] Among them, the mark can be an annotation of a certain section of program code, or program code with a predetermined syntax set adjacent to a certain section of program code.
[0104] The following takes the Java language as an example. Suppose the program code written by the tenant is as follows:
[0105]
[0106]
[0107] The embodiments of the present invention will be mainly described with the above program code. As shown in the above program code, the main program code: public static void main(String[]args) calls program code 1 during the running process. Program code 1 is the function runInCloud1(inputDir, outputDir). Program code 1, that is, the function runInCloud1(inputDir, outputDir) calls program code 2, that is, the function runInCloud2(inputFileList, outputDir) during the running process.
[0108] Therefore, program code 1 is subroutine code, and program code 2 is nested program code. The marks @QtFun(taskNum = 1, flavor = "s2.small.1", type = VM, waitingForFinished = true) and @QtFun(taskNum = 4, cpu = 1, memory = 256, type = VM, waitingForFinished = true) can be used to indicate that program code 1 and program code 2 are separated by the cloud platform
[0109] Moreover, the function runInCloud1(inputDir, outputDir) is proximately set with a tag: @QtFun(taskNum = 1, flavor = "s2.small.1", type = VM, waitingForFinished = true), where @QtFun is a preset tag in the embodiments of the present invention, used to indicate that the function runInCloud1(inputDir, outputDir) annotated by this tag needs to be executed by a virtual instance, and the type type of the virtual instance is a virtual machine, the specification flavor of the virtual machine is s2.small.1, the number of virtual machines taskNum is 1, and the main program needs to wait for the execution of this function to complete before it can execute the next step (waitingForFinished = true).
[0110] Furthermore, the function runInCloud2(inputFileList, outputDir) is set with a tag: @QtFun(taskNum = 4, cpu = 1, memory = 256, type = VM, waitingForFinished = true), where @QtFun is a preset tag in the embodiments of the present invention, used to indicate that the function runInCloud2(inputFileList, outputDir) annotated by this tag needs to be executed by a virtual instance, and the type type of the virtual instance is a virtual machine, the processor specification of the virtual machine is 1 core, the memory specification is 256M, the number of virtual machines taskNum is 1, and the main program needs to wait for the execution of this function to complete before it can execute the next step (waitingForFinished = true).
[0111] The tag is used to separate different subroutine codes, and the cloud platform can confirm different subroutine codes by detecting the tag.
[0112] In the embodiments of the present invention, the specification can be determined by the flavor predefined by the cloud platform, such as s2.small.1 described above, and its specification is, for example, a 2-core processor and 512M of memory. Optionally, the specification can also directly specify the number of CPU cores and the memory size, such as specifying cpu = 1, memory = 256 in runInCloud2(inputFileList, outputDir), and the cloud platform configures the virtual instance according to the configuration information indicated by analyzing the tag.
[0113] Specifically, the program code service interface 102 of the cloud platform sends the above program code to the cloud program execution unit 20. The cloud program execution unit 20 configures virtual instances according to the configuration information indicated by the tag. According to the above program code, the cloud program execution unit 20 first creates 1 virtual machine to run program code 1. When program code 1 runs to the position where program code 2 needs to be called, 4 virtual machines are created to run program code 2 in parallel.
[0114] And please combine with Figure 3 for reference together, Figure 3 is another system architecture diagram of the program code processing system according to an embodiment of the present invention, Figure 3 and Figure 2 The difference is that it newly adds virtual instances 1-5 configured by the cloud program execution unit 20 according to the configuration information indicated by the tag. Moreover, the cloud program execution unit 20 sends the main program code to the main program execution unit 30, sends program code 1 to virtual instance 1 for execution, and sends program code 2 to virtual instances 2-5 for execution, so that the tenant's program code can be executed on the data center side based on the cloud platform.
[0115] Among them, each subprogram code corresponds to a cloud program running area. As Figure 2 shown, virtual instance 1 is set in cloud program running area 1, virtual instance 2 is set in cloud program running areas 2-5, and virtual instances 1-5 can specifically run on the Figure 1 computing nodes shown.
[0116] Optionally, the tag can also be / / , and the implementation method is as follows:
[0117]
[0118] Therefore, @, / / , \\, \, / , or other symbol tags pre-agreed with the cloud platform can be used as the specific implementation methods of the tag.
[0119] It should be noted that in the above example code, program code 1 is a subprogram code, and program code 2 is another subprogram code called by the subprogram code (i.e., nested program code). Optionally, in other implementation methods, it can also be set that the main program code calls two subprogram codes respectively. The following is an example:
[0120]
[0121] In the above program code, the main program code first calls program code 2 to transcode the data in the OBS bucket, and then calls program code 1 to perform H265 hash operation on the transcoded data in the OBS bucket.
[0122] Figure 4It is a data interaction diagram of a program code processing method according to an embodiment of the present invention, which can be applied in Figures 1 - 3 the cloud platform shown. As Figure 3 shown, the program code processing method according to an embodiment of the present invention includes the following steps:
[0123] Step S101: The tenant writes program code on the client side.
[0124] Among them, the tenant writes program code using a program code writing tool installed on the client side. Moreover, the tenant can mark some of the code in the form of comments according to the syntax provided by the cloud platform, and indicate configuration information in the mark. This configuration information can be used to indicate one or any combination of the type, specification, and quantity of the virtual instance running this part of the code. The program code includes main program code, program code 1, and program code 2, and can be, for example, the java code described above.
[0125] Optionally, if the tenant does not indicate the type, specification, or quantity in the mark, the cloud platform configures the virtual instance according to the default type, specification, or quantity.
[0126] Furthermore, the tenant can send the program code written elsewhere to the client side, as long as it is ensured that the program code is commented and marked. The present invention embodiment does not limit the generation method of the program code.
[0127] Step S102: The client side sends the program code to the cloud platform.
[0128] Specifically, the client side sends the program code to the program code service interface 102 in the cloud service providing unit 10.
[0129] The program code service interface 102 is specifically implemented as an upload interface, and this upload interface is used to receive the program code uploaded by the tenant. Optionally, the program code service interface 102 can also be specifically implemented as a program code editing interface. The tenant can remotely log in to the program code editing interface provided by the cloud service providing unit 10 through the operation of the client side and write program code online in the program code editing interface.
[0130] Step S103: The cloud service providing unit 10 sends the program code to the cloud program execution unit 20.
[0131] Step S104: The cloud program execution unit 20 sends the main program code to the main program execution unit 30.
[0132] Specifically, the cloud program execution unit 20 sends the main program code to the program execution unit of the main program execution unit 30.
[0133] The main program code is, for example:
[0134]
[0135] Step S105: The cloud program execution unit 20 configures the virtual instance 1 according to the tag of program code 1.
[0136] The tag of program code 1 is, for example:
[0137] @QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true)
[0138] The cloud program execution unit 20 analyzes the tag and obtains the following configuration information: It is necessary to create 1 virtual instance with a specification of s2.small.1, a type of virtual machine, and a quantity of 1. When the main program code runs to the position where program code 1 is called, it is necessary to wait until program code 1 is executed before continuing to run.
[0139] Among them, VM indicates a virtual machine type. In other embodiments, the type may also include a container and a bare metal server.
[0140] Step S106: The cloud program execution unit 20 sends program code 1 adjacent to the tag to the already configured virtual instance 1.
[0141] Program code 1 is:
[0142]
[0143]
[0144] Among them, the business logic of program code 1 is as follows: Read the file list in the OBS bucket corresponding to the URL, call program code 2, program code 2 performs transcoding processing on each file in the file list, and after program code 2 finishes transcoding, program code 1 performs a hash operation on the transcoded files to obtain the corresponding hash value for each transcoded file.
[0145] Among them, each OBS bucket is located through a Uniform Resource Locator (URL). After the cloud platform creates an OBS bucket, it configures and records the URL for the OBS bucket, and tenants can access the OBS bucket through the URL.
[0146] It should be noted that the OBS bucket mentioned here is Figure 1 and Figure 2The shared storage space shown, the OBS bucket is a specific implementation of the shared storage space, and the shared storage space can also be implemented through a shared cache, a shared database, or other means with shared storage functions.
[0147] In the embodiments of the present invention, the shared storage space is used to store data to be processed, and the data to be processed is, for example, a file in the OBS bucket.
[0148] In the embodiments of the present invention, the program code set adjacent to the tag can be called cloud program code. For example, both program code 1 and program code 2 can be called cloud program code, and the cloud program code is executed by a virtual instance configured by the cloud program execution unit 20. And the virtual instance 1 is set in the cloud program running area 1.
[0149] Step S107: The main program execution unit 30 executes the main program code to the position where program code 1 needs to be called, and pauses the execution of the main program code, waiting for program code 1 to finish execution.
[0150] Among them, the cloud program execution agent of the main program execution unit 30 executes the main program code until after the statement String inputDir = args[2], and needs to call program code 1: runInCloud1(inputDir, outputDir). Since this program code 1 is marked to run in a virtual instance, the cloud program execution agent of the main program execution unit 30 needs to request the running result of program code 1 from the cloud program execution unit 20.
[0151] Step S108: The cloud program execution agent of the main program execution unit 30 requests the running result of program code 1 from the cloud program execution unit 20.
[0152] Step S109: The cloud program execution unit 20 requests the running result of program code 1 from the virtual instance 1.
[0153] Step S110: The virtual instance 1 executes program code 1 to the position where program code 2 needs to be called and starts waiting.
[0154] Specifically, the cloud program execution agent of the virtual instance 1 executes program code 1. After executing String[] inputFileList = Obs.readFileList(inputDir), it is found that the next statement needs to call program code 2: runInCloud2(inputFileList, outputDir). Since this program code 1 is marked to run in a virtual instance, the cloud program execution agent of the virtual instance 1 needs to request the running result of program code 2 from the cloud program execution unit 20.
[0155] Step S111: The cloud program execution agent of virtual instance 1 requests the running result of program code 2 from the cloud program execution unit 20.
[0156] Step S112: The cloud program execution unit 20 configures virtual instances 2-5 according to the configuration information indicated by the label of program code 2.
[0157] Specifically, the label of program code 2 is @QtFun(taskNum=4,cpu=1,memory=256,type=VM,waitingForFinished=true). The cloud program execution unit 20 creates 4 virtual instances of the virtual machine type according to the configuration information, with a specification of 1 cpu core and a memory size of 256M. When program code 1 runs to the position where program code 2 is called, it needs to wait until program code 2 is executed before continuing to run.
[0158] It should be noted that when waitingForFinished=false, when program code 1 runs to the position where program code 2 is called, it can directly skip program code 2 without waiting until program code 2 is executed.
[0159] And virtual instances 2-5 are set in the cloud program running area 2.
[0160] Step S113: The cloud program execution unit 20 sends program code 2 to the configured virtual instances 2-5 respectively.
[0161] Step S114: Virtual instances 2-5 execute program code 2 respectively.
[0162] Specifically, the cloud program execution agents in virtual instances 2-5 execute program code 2 respectively.
[0163]
[0164] In this step, virtual instances 2-5 execute the same program code 2, thus running the same business logic. The business logic of the program code is as follows:
[0165] Each of virtual instances 2-5 obtains its own task identifier taskId according to QtContext.getTaskIndex(). When a virtual instance runs QtContext.getTaskIndex(), it sends a request to the cloud program execution unit 20. The cloud program execution unit 20 returns taskId to the virtual instance according to this request. The taskIds of virtual instances 2-5 are different from each other and arranged in sequence. For example, the taskId of virtual instance 2 is 0, the taskId of virtual instance 3 is 1, the taskId of virtual instance 4 is 2, and the taskId of virtual instance 5 is 3.
[0166] For each file in the file list, if the remainder obtained by taking the modulus of its sequence number i with 4 (the number of virtual instances) is equal to the taskId of the virtual instance, the file with sequence number i is transcoded by that virtual instance. transcodingToH265(fileList[i], outputDir + " / " + i + ".mp4") is used to transcode the i-th file in the file list into an H265 format file.
[0167] After each virtual instance finishes running Program Code 2, record the running result of Program Code 2. The running result is, for example, 1 or 0, where 1 indicates successful operation and 0 indicates failure. In this embodiment, it is assumed that each virtual instance successfully runs Program 2. Therefore, each of virtual instances 2 - 5 records the running result of Program Code 2 as 1.
[0168] Therefore, in this step, the cloud platform provides the data to be processed, and Program Code 2 is used to instruct virtual instances 2 - 5 to obtain the data to be processed from the cloud platform and execute the business logic of Program Code 2 based on the data to be processed.
[0169] Furthermore, QtContext.getTaskIndex() is a message queue service API provided by the cloud platform, which is defined by the cloud program execution unit 20 of the cloud platform. When a virtual instance calls QtContext.getTaskIndex(), it sends a request to the cloud program execution unit 20, and the cloud program execution unit 20 returns the taskId to the virtual instance according to the request.
[0170] It should be noted that the cloud program execution unit 20 of the cloud platform can also provide other cloud services in addition to the message queue service and set cloud service application programming interfaces (APIs) for the cloud services. When there is a corresponding cloud service API set in the program code, the cloud service API can be used to instruct the virtual instance to call the cloud services provided by the cloud platform when it is called. The cloud service AIP also includes an object storage service API, a database service API, and a shared cache service API. The object storage service API is, for example, the above-mentioned Obs.readFileList(outputDir, URL).
[0171] When a virtual instance runs the object storage service API, it needs to input the URL of the OBS bucket, so that the cloud program execution unit 20 can locate the OBS bucket to be accessed according to the URL, and the virtual instance can access the OBS bucket through the cloud program execution unit 20.
[0172] When a virtual instance runs the database service API, it needs to input the name of the database and the account password, so that the cloud program execution unit 20 can locate the database and log in to the database through the account password. The virtual instance can access the database through the cloud program execution unit 20.
[0173] When the virtual instance runs the shared cache service API, the name of the shared cache needs to be input so that the cloud program execution unit 20 can locate the shared cache according to this name, and the virtual instance can share the cache through the cloud program execution unit 20.
[0174] Step S115: The cloud program execution unit 20 requests the running results of program code 2 from the virtual instances 2-5 respectively.
[0175] Specifically, the cloud program execution unit 20 sends requests for the running results of program code 2 to the cloud program execution agents of the virtual instances 2-5 respectively.
[0176] Step S116: The virtual instances 2-5 return the running results of program code 2 to the cloud program execution unit 20 respectively.
[0177] Specifically, the cloud program execution agents of the virtual instances 2-5 return the running results of program code 2 to the cloud program execution unit 20 respectively.
[0178] Step S117: The cloud program execution unit 20 returns the running results of program code 2 to the virtual instance 1.
[0179] Specifically, the cloud program execution unit 20 returns the running results of program code 2 to the cloud program execution agent of the virtual instance 1.
[0180] Step S118: The virtual instance 1 continues to run program code 1.
[0181] Specifically, the cloud program execution agent of the virtual instance 1 continues to run program code 1 according to the running results of program code 2, and executes the remaining statements:
[0182]
[0183] And after the above statements are executed, record the running results of program code 1 (assuming successful execution, the running result is 1)
[0184] Step S119: The virtual instance 1 sends the running results of program code 1 to the cloud program execution unit 20.
[0185] Specifically, the cloud program execution agent of the virtual instance 1 sends the running results of program code 1 to the cloud program execution unit 20, where this step is a response to step 108.
[0186] Step S120: The cloud program execution unit 20 sends the running results of program code 1 to the main program execution unit 30.
[0187] Specifically, the cloud program execution unit 20 sends the operation result of program code 1 to the cloud program execution agent of the main program execution unit 30.
[0188] Step S121: The main program execution unit 30 continues to execute the main program code.
[0189] Specifically, the cloud program execution agent of the main program execution unit 30 continues to execute the main program code according to the operation result (1) of program code 1.
[0190] Step S122: The main program code finishes running.
[0191] Step S123: The cloud program execution agent of the main program execution unit 30 notifies the cloud service providing unit 10 that the main program code has finished running.
[0192] Step S124: The cloud service providing unit 10 notifies the client that the main program code has run successfully.
[0193] Specifically, the cloud service providing unit 10 notifies the client that the main program code has finished running through the program code service interface 102.
[0194] So far, the tenant learns from the program code service interface 102 through the client that the program code has finished running, and the data in the OBS bucket has all been transcoded and hashed.
[0195] It should be noted that in the above embodiments, the number of virtual instances is not limited. As long as the computing power of the data center allows, for example, the tenant can select 1 - 1000 virtual instances for parallel computing of the same program logic for different data to be processed.
[0196] Moreover, in Embodiment 1, only one data center is disclosed. In other embodiments of the present invention, the number of data centers can be more than 1. For scenarios of cross - data - center cooperation, the tenant can select to configure a larger number of virtual instances.
[0197] Further, for steps S105 and S112 of configuring virtual instances, the cloud platform can create virtual instances on physical servers according to the configuration information indicated by the tag; or the cloud platform can pre - create multiple virtual instances and select virtual instances that match the configuration information indicated by the tag from these multiple virtual instances.
[0198] And the above - mentioned tag is an annotation of the program code 1 or program code 2. However, in other embodiments of the present invention, the above - mentioned tag can be other program codes that adopt a predetermined syntax and are adjacent to the program code 1 or program code 2.
[0199] Optionally, the tag can also be any tag pre - agreed with the cloud platform.
[0200] In summary, the embodiments of the present invention enable the tenant's program code to be executed on the data center side, and the tenant does not need to change their own programming habits. The tenant can use their commonly used programming language to write program code. The tenant only needs to mark the part of the program code that needs to be executed on the virtual instance and set the configuration information of the virtual instance that runs the program code in the mark. The cloud platform creates or selects a virtual instance that matches the configuration information according to the mark, sends the program to the virtual instance for running, and obtains the running result from the virtual instance, so that the program code can be run through the virtual instance. For scenarios such as big data processing, neural networks, and large-scale application development, since the computing power of the data center is fully utilized and the entry threshold is relatively low (only the tenant needs to mark specific program code), the convenience of the tenant using cloud resources for large-scale parallel computing can be greatly improved.
[0201] Embodiment 2:
[0202] In this embodiment, the tenant can create a business virtual instance in the data center through the cloud platform, write program code on the business virtual instance, or send program code from other devices to the business virtual instance. The program code runs in the business virtual instance. Some of the program code in the program code is annotated with the configuration information of the virtual instance. When the business virtual instance runs to this part of the program code, it notifies the cloud platform to configure the virtual instance according to the configuration information, executes this part of the program code through the virtual instance, and obtains the running result of this part of the program code from the virtual instance. Finally, the business virtual instance notifies the tenant of the running result of the program code.
[0203] Specifically, refer to Figure 5 , Figure 5 which is another system architecture diagram of the program code processing system according to the embodiments of the present invention. Compared with Figure 2 , Figure 5 in the shown embodiment, the cloud service providing unit 10 does not provide a program code service interface 102, and there is no main program execution unit 30 set in the cloud platform.
[0204] Compared with Embodiment 1, Embodiment 2 directly runs the program code in the tenant's production environment or test environment (i.e., the business virtual instance), and configures the virtual instance to run the marked part of the program code through the cloud platform during the running of the program code. Similarly, it can improve the convenience of the tenant using cloud resources for large-scale parallel computing. And since Embodiment 2 directly runs the program code in the production environment, in the scenario where the tenant purchases a business virtual instance, directly executing the program code on the business virtual instance is more in line with the tenant's usage habits.
[0205] Among them, the program code exemplified in this embodiment is the same as the Java code shown in Embodiment 1. The business virtual instance of the tenant is created by the tenant using the client to access the virtual instance service interface 101 in the service providing unit of the cloud platform. After the business virtual instance is created, the tenant can remotely log in to the business virtual instance through the client. Among them, after the tenant creates the business virtual instance, the cloud platform can provide an installation file for the cloud program execution agent, and the tenant can download and install the installation file into the business virtual instance.
[0206] Optionally, the cloud program execution agent can also be pre-installed in the business virtual instance.
[0207] The business virtual instance directly runs the program code. The cloud program execution agent of the business virtual instance can recognize the tag, configure the virtual instance according to the tag, and send the part of the program code set with the tag to the configured virtual instance for execution, so as to implement the execution of the program code in the cloud, which can reduce the computing load of the client and does not need to change the programming habits of the tenant, thereby improving the programming experience of the tenant.
[0208] And please combine Figure 6 for reference together Figure 6 is another system architecture diagram of the program code processing system according to the embodiment of the present invention, Figure 6 and Figure 5 The difference is that it newly adds virtual instances 1-5 configured by the cloud program execution unit 20 according to the configuration information indicated by the tag. Moreover, the cloud program execution unit 20 sends program code 1 to virtual instance 1 for execution and sends program code 2 to virtual instances 2-5 for execution, so that the tenant's program code can be executed on the data center side based on the cloud platform.
[0209] And please combine Figure 7 for reference together Figure 7 is another data interaction diagram of the program code processing method according to the embodiment of the present invention, Figure 7 The program code processing method shown can be applied to Figures 1 - 3 and Figures 5 - 6 the architecture shown. As Figure 7 shown, the program code processing method according to the embodiment of the present invention includes the following steps:
[0210] Step S201: The client sends a business virtual instance creation request to the cloud platform.
[0211] Specifically, the tenant operates the client to access the virtual instance service interface 101 of the cloud service providing unit 10, selects the type and specification of the business virtual instance in the virtual instance service interface 101, and the cloud platform creates a business virtual instance of the corresponding type and specification.
[0212] Step S202: The cloud platform creates a business virtual instance.
[0213] Specifically, the cloud service providing unit 10 of the cloud platform creates a business virtual instance of the corresponding type and specification.
[0214] Step S203: The tenant remotely logs in to the business virtual instance through the client and develops program code on the business virtual instance.
[0215] Optionally, the tenant can also operate the business virtual instance to download program code from other devices.
[0216] Step S204: The business virtual instance runs the main program code.
[0217] Specifically, the cloud program execution agent of the business virtual instance runs the main program code:
[0218]
[0219]
[0220] Step S205: The business virtual instance runs the main program code to the position where program code 1 needs to be called and starts waiting.
[0221] Specifically, after the cloud program execution agent of the business virtual instance runs the statement String inputDir=args[2], it starts waiting.
[0222] Step S206: The business virtual instance sends program code 1 and program code 2 to the cloud program execution unit 20.
[0223] Specifically, the cloud program execution agent of the business virtual instance identifies the program code 1 annotated by this tag as the program code that needs to be executed by the virtual instance according to the tag @QtFun(taskNum=1,flavor="s2.small.1",type=VM,waitingForFinished=true), and sends program code 1 to the cloud program execution unit 20.
[0224] Similarly, the cloud program execution agent of the business virtual instance identifies the program code 2 annotated by this tag as the program code that needs to be executed by the virtual instance according to the tag @QtFun(taskNum=4,cpu=1,memory=256,type=VM,waitingForFinished=true), and sends program code 2 to the cloud program execution unit 20.
[0225] Step S207: The cloud program execution unit 20 configures virtual instance 1 according to the tag @QtFun(taskNum = 1, flavor = "s2.small.1", type = VM, waitingForFinished = true).
[0226] The cloud program execution unit 20 analyzes this tag and obtains the following information: It is necessary to create 1 virtual instance with a specification of s2.small.1, a type of virtual machine, and a quantity of 1. When the main program code runs to the position of calling program code 1, it is necessary to wait until program code 1 finishes executing before continuing to run.
[0227] Step S208: The cloud program execution unit 20 sends program code 1 to the configured virtual instance 1.
[0228] Step S209: The cloud program execution agent of the business virtual instance requests the running result of program code 1 from the cloud program execution unit 20.
[0229] Step S210: The cloud program execution unit 20 requests the running result of program code 1 from virtual instance 1.
[0230] Step S211: The cloud program execution agent of virtual instance 1 executes program code 1. When it reaches the position where program code 2 needs to be called, it starts to wait.
[0231] Step S212: Virtual instance 1 requests the running result of program code 2 from the cloud program execution unit 20.
[0232] Step S213: The cloud program execution unit 20 configures virtual instances 2 - 5 according to the configuration information indicated by the tag of program code 2.
[0233] Step S214: The cloud program execution unit 20 sends program code 2 to the configured virtual instances 2 - 5 respectively.
[0234] Step S215: Virtual instances 2 - 5 execute program code 2 respectively.
[0235] Step S216: The cloud program execution unit 20 requests the running result of program code 2 from virtual instances 2 - 5.
[0236] Step S217: Virtual instances 2 - 5 send the running result of program code 1 to the cloud program execution unit 20.
[0237] Step S218: The cloud program execution unit 20 sends the running result of program code 2 to virtual instance 1.
[0238] Step S219: The cloud program execution agent of virtual instance 1 receives the running result of program code 2, and continues to run program code 1 based on this running result to generate the running result of program code 1.
[0239] Step S220: Virtual instance 1 sends the running result of program code 1 to cloud program execution unit 20.
[0240] Step S221: Cloud program execution unit 20 sends the running result of program code 1 to the cloud program execution agent of the business virtual instance.
[0241] Step S222: The cloud program execution agent of the business virtual instance ends the waiting according to the running result of program code 1 and continues to execute the main program code.
[0242] Step S223: The cloud program execution agent of the business virtual instance runs the remaining main program code.
[0243] So far, the tenant logs in to the business virtual instance through the client and learns from the cloud program execution agent of the business virtual instance that the program code has finished running, and the data in the OBS bucket has all been transcoded and hashed.
[0244] In Embodiment 2, except that the main program execution entity is a business virtual machine, other aspects are substantially the same as those in Embodiment 1. It should be noted that, similar to Embodiment 1, in this embodiment, as long as the computing power of the data center (depending on the number of idle physical servers) permits, the number of virtual instances is not limited. For example, the tenant can select 1 - 1000 virtual instances for parallel computing of the same program logic for different data to be processed.
[0245] Moreover, in Embodiment 2, only one data center is disclosed. In other embodiments of the present invention, the number of data centers can be more than 1. For scenarios of cross - data - center cooperation, the tenant can select to configure a larger number of virtual instances.
[0246] Furthermore, for steps S207 and S213 of configuring virtual instances, the cloud platform can create virtual instances on physical servers according to the configuration information indicated by the tag; or the cloud platform pre - creates multiple virtual instances and selects virtual instances that match the configuration information indicated by the tag from these multiple virtual instances.
[0247] And the above - mentioned tag is an annotation of program code 1 or program code 2, but in other embodiments of the present invention, the above - mentioned tag can be other program codes that adopt a predetermined syntax and are adjacent to program code 1 or program code 2.
[0248] In summary, in the embodiments of the present invention, the tenant's program code can be executed on the data center side, and the tenant does not need to change their own programming habits and can use their commonly used programming languages to write program code. The tenant only needs to mark some program code that needs to be executed on the virtual instance and set the configuration information of the virtual instance that runs the program code in the mark. The cloud platform creates or selects a virtual instance that matches the configuration information according to the mark, sends the program code to the virtual instance for running, and obtains the running result of the program code from the virtual instance, so that the program code can be run through the virtual instance. For scenarios such as big data processing, neural networks, and large-scale application development, since the computing power of the data center is fully utilized and the entry threshold is relatively low (only the tenant needs to mark specific program code), the convenience of the tenant using cloud resources for large-scale parallel computing can be greatly improved.
[0249] Compared with Embodiment 1, in Embodiment 2, the program code is directly run in the tenant's production environment or test environment (i.e., the business virtual instance), and the cloud platform configures the virtual instance to run the marked part of the program code during the running process of the program code, which can improve the convenience of the tenant using cloud resources for large-scale parallel computing. Moreover, since Embodiment 2 directly runs the program code in the production environment, it is more in line with the tenant's usage habits in the scenario where the tenant has already purchased the business virtual instance.
[0250] It should be noted that in Embodiment 1 and Embodiment 2, the main program code calls Program Code 1, and Program Code 1 then calls Program Code 2. However, it should be noted that the embodiments of the present invention are not limited thereto. The main program code can call Program Code 1 and Program Code 2 respectively, and the tenant can also let the main program code call more Program Code 1 according to actual needs, and Program Code 1 can nest and call more layers of Program Code 2.
[0251] Furthermore, in the above embodiments, the virtual instance 2-5 configured by the cloud program execution unit 20 according to the configuration information indicated by the mark can be released after the virtual instance 2-5 returns the running result of Program Code 2 to the cloud program execution unit 20, and the virtual instance 1 can be released after the virtual instance 1 returns the running result of Program Code 1 to the cloud program execution unit 20. Herein, the release is, for example, to stop running the virtual instance and cancel the virtual instance in the physical server, or to clear the data recorded in the memory of the virtual instance. Timely releasing the virtual instance can improve the resource utilization efficiency of the virtual instance.
[0252] Please also refer to Figure 8 , Figure 8 which is a schematic structural diagram of a storage node according to an embodiment of the present invention. The storage node (i.e., Figure 7The storage nodes 201 or 202 shown include a software layer and a hardware layer. The hardware layer includes a disk controller 2075, a physical network card 2076, physical disks 1 and 2. The software layer includes an Object Storage Device (OSD) control unit 2012 and an operating system 2012. The OSD control unit 2012 runs on the operating system 2012. The operating system 2012 includes a disk driver 2013 and a physical network card driver 2014. The cloud platform can communicate with the OSD control unit 2011 through the physical network card 2016. The OSD control unit 2011 controls the disk controller 2015 through the disk driver 2013 to set physical disks 1 and 2 as multiple object storage devices OSDs. After the cloud platform receives an OBS bucket creation instruction from a tenant, it notifies the OSD control unit 2011 to create an OBS bucket. At this time, the OSD control unit 2011 sets OSD1 - 3 as the OBS bucket and configures a URL for this OBS bucket. The tenant can upload the data to be processed involved in the above embodiments into the OBS bucket, where the URL is the address of the data to be processed provided by the cloud platform.
[0253] And please refer to Figure 9 , Figure 9 is a schematic structural diagram of a computing node according to an embodiment of the present invention. The computing node (such as Figure 7 the computing node 301 or 302 shown) includes a software layer and a hardware layer. The hardware layer includes a processor, a memory, a disk, and a network card respectively connected to a bus. The software layer includes an operating system and multiple virtual machines running on the operating system, such as Figure 9 the virtual machine 1 and virtual machine 2 shown. The virtual machine manager is set in the operating system and is used to manage multiple virtual machines and set virtual hardware for each virtual machine according to the hardware layer. A cloud program execution agent is respectively set in each virtual machine. The cloud platform can communicate with the virtual machine manager through the network card. The cloud platform creates or cancels virtual machines in the computing node through the virtual machine manager and manages the entire life cycle of the virtual machines.
[0254] And please refer to Figure 10 , Figure 10 is another schematic structural diagram of a computing node according to an embodiment of the present invention. The computing node (such as Figure 7 the computing node 301 or 302 shown) includes a software layer and a hardware layer. The hardware layer includes a processor, a memory, a disk, and a network card respectively connected to a bus. The software layer includes an operating system and multiple containers running on the operating system, such as Figure 9As shown in the containers 1 and 2, a container manager is set in the operating system to manage multiple containers and set virtual hardware for each container according to the hardware layer. A cloud program execution agent is respectively set in each container. The cloud platform can communicate with the container manager through a network card. The cloud platform creates or cancels containers on the computing node through the container manager and manages the entire life cycle of the containers.
[0255] And please refer to Figure 11 , Figure 11 which is another structural schematic diagram of a computing node according to an embodiment of the present invention. The computing node (such as the computing nodes 301 or 302 shown in Figure 7 ) includes a software layer and a hardware layer. The hardware layer includes a processor, a memory, a disk, a network card, and an offload card respectively connected to a bus. The software layer includes an operating system and a cloud program execution agent set in the operating system. The cloud platform can manage the computing node through the offload card, so that the hardware resources of the computing node except the offload card are completely managed by the tenant. At this time, the computing node is a bare metal server purchased by the tenant from the cloud platform.
[0256] It should be noted that in the above virtual machines, containers, and bare metal servers, the cloud program execution agent described in the embodiments of the present invention is set. The cloud program execution unit 20 can communicate with the cloud program execution agent to control the virtual machines, containers, and bare metal servers to execute cloud program code.
[0257] Therefore, through compilation technology, the embodiments of the present invention enable developers to retain their programming habits while directly using the computing power provided by the cloud environment during the programming process, without the need to learn complex programming or design and develop the entire distributed system subsequently.
[0258] Further, please refer to Figure 12 , Figure 12 which is a schematic diagram of the device structure of a computer device according to an embodiment of the present invention. As shown in Figure 12 , the computer device includes a processor 1001, a memory 1002, a communication interface 1003, and a bus 1004. The processor 1001, the memory 1002, and the communication interface 1003 are respectively connected to the bus 1004. The memory 1002 is used to store computer execution instructions, and the processor 1001 is used to execute the computer execution instructions stored in the memory 1002, so that the computer device implements the methods executed by the cloud platform in the above Embodiment 1 and / or Embodiment 2.
[0259] Moreover, the embodiments of the present invention also provide a computer storage medium, including computer-readable instructions, which, when executed, implement the methods executed by the cloud platform in the above Embodiment 1 and / or Embodiment 2.
[0260] An embodiment of the present invention also provides a computer program product including instructions, which when running on a computer, causes the computer to execute the methods performed by the cloud platform in the above-mentioned Embodiment 1 and / or Embodiment 2.
[0261] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general-purpose hardware, and of course, it can also be implemented by dedicated hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. Generally, functions accomplished by computer programs can be easily implemented by corresponding hardware, and the specific hardware structures for implementing the same function can also be various, such as analog circuits, digital circuits, or dedicated circuits. However, for the present application, in more cases, software program implementation is a better implementation manner. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product is stored in a readable storage medium, such as a floppy disk, a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disc of a computer, and includes several instructions for causing a computer device (which may be a personal computer, a training device, or a network device, etc.) to execute the methods described in various embodiments of the present application.
[0262] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product.
[0263] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device, or a data center to another website, a computer, a training device, or a data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store, or a data storage device such as a training device or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
Claims
1. A method for processing program code based on cloud services, characterized in that Including: The business virtual instance obtains the program code developed by the tenant in the business virtual instance, where the business virtual instance is remotely logged in by the tenant through the client; or the business virtual instance downloads the program code from other devices; wherein, the obtained program code or the downloaded program code includes the main program code and the subprogram code, and a first annotation is set in the subprogram code, and the first annotation includes first configuration information and a symbol mark, and the symbol mark is adjacent to the first configuration information, and the first configuration information is used to indicate the first virtual instance specification, and the first virtual instance specification includes or specifies the number of processor cores and the memory size; The business virtual instance runs the main program code, and when running the main program code to the position where the subprogram code needs to be called, pauses running the main program code and sends the subprogram code to the cloud platform; The cloud platform configures at least one first virtual instance in at least one data center according to the first annotation, where the at least one first virtual instance matches the first configuration information of the first annotation; and, the cloud platform configures at least one first virtual instance in at least one data center according to the first annotation, including: The cloud platform creates at least one first virtual instance in the at least one data center that matches the first configuration information in the first annotation; or The cloud platform selects the at least one first virtual instance that matches the first configuration information in the first annotation from multiple virtual instances, where the multiple virtual instances are pre-created by the cloud platform in the at least one data center; Wherein, the at least one virtual instance created or selected has the first virtual instance specification indicated by the first configuration information; The at least one first virtual instance obtains the subprogram code from the cloud platform; The at least one first virtual instance runs the subprogram code to obtain at least one running result and sends the at least one running result to the cloud platform; The business virtual instance obtains the at least one running result from the cloud platform; The business virtual instance continues to run the main program code according to the at least one running result; Wherein, after the at least one first virtual instance sends the at least one running result to the cloud platform, the at least one first virtual instance is released.
2. The method according to claim 1, wherein The first configuration information is further used to indicate the number of first virtual instances and the type of first virtual instances, and the at least one virtual instance created or selected has the number of first virtual instances indicated by the first configuration information and belongs to the type of first virtual instances indicated by the first configuration information.
3. The method according to claim 2, wherein Before the step where the business virtual instance obtains the program code developed by the tenant in the business virtual instance; or before the step where the business virtual instance downloads the program code from other devices, the method further includes: The cloud platform determines the type and specification of the business virtual instance selected by the tenant at the virtual instance service interface of the cloud platform. The cloud platform creates, in the at least one data center, a business virtual instance corresponding to the type and the specification.
4. The method according to claim 2, wherein The number of the first virtual instances is greater than 1. The cloud platform configures at least one first virtual instance in the at least one data center according to the first annotation, including: The cloud platform configures the number of the first virtual instances of the first virtual instances in the at least one data center; the method further includes: The number of the first virtual instances of the first virtual instances respectively run the subroutine code to perform data processing on different to-be-processed data respectively obtained from the shared storage space.
5. The method according to claim 4, characterized in that The number of the first virtual instances of the first virtual instances respectively run the subroutine code to perform data processing on different to-be-processed data respectively obtained from the shared storage space, including: The number of the first virtual instances of the first virtual instances respectively run the subroutine code to perform data processing of the same business logic on different to-be-processed data respectively obtained from the shared storage space.
6. The method according to claim 2, characterized in that, The number of the first virtual instances is 1. The cloud platform configures one first virtual instance in the at least one data center according to the number of the first virtual instances. The subroutine code further includes nested program code, and a second annotation is set in the nested program code. The second annotation includes second configuration information, and the second configuration information includes one or any combination of a second virtual instance specification, a second virtual instance number, and a second virtual instance type. The method further includes: When the first virtual instance runs the subroutine code to a position where the nested program code needs to be called, the first virtual instance pauses running the subroutine code and requests the cloud platform for the running result of the nested program code. Wherein, the second annotation is used to instruct the cloud platform to configure at least one second virtual instance in the at least one data center, the at least one second virtual instance matches the second configuration information indicated by the second annotation, and the nested program code is sent by the cloud platform to the at least one second virtual instance; The cloud platform receives at least one running result obtained by the at least one second virtual instance running the nested program code, and sends the at least one running result to the first virtual instance; The first virtual instance continues to run the subroutine code according to the at least one running result.
7. The method according to any one of claims 1 to 6, characterized in that The method further includes: The cloud platform provides cloud services and sets a cloud service application programming interface API for the cloud services, wherein the cloud service API is called in the subroutine code.
8. The method according to claim 7, wherein The cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
9. The method according to any one of claims 1 to 6, characterized in that, The symbol mark is pre-agreed by the cloud platform, and the first virtual instance specification further includes or specifies the processor main frequency size.
10. The method according to any one of claims 1 to 6, characterized in that, The first virtual instance type is used to indicate either a virtual machine or a container.
11. A method for processing program code based on cloud services, characterized in that, Including: The cloud platform receives the program code uploaded by the tenant to the upload interface, where the upload interface is set in the cloud platform; or the cloud platform receives the program code remotely input by the tenant to the program editing interface, where the program editing interface is set in the cloud platform; the uploaded program code or the remotely input program code includes a main program code and a subprogram code, and a first annotation is set in the subprogram code, and the first annotation includes first configuration information and a symbol marker, and the symbol marker is adjacent to the first configuration information, and the first configuration information is used to indicate a first virtual instance specification, and the first virtual instance specification includes or specifies the number of processor cores and the memory size; When the cloud platform runs the main program code to a position where the subprogram code needs to be called, the cloud platform pauses running the main program code and requests at least one first virtual instance to obtain at least one running result obtained by running the subprogram code by the at least one first virtual instance. Wherein, the first annotation is used to instruct the cloud platform to create the at least one first virtual instance in at least one data center or the first annotation is used to instruct the cloud platform to select the at least one first virtual instance that matches the first configuration information in the first annotation from multiple virtual instances, where the multiple virtual instances are pre-created by the cloud platform in the at least one data center, and the subprogram code is sent by the cloud platform to the at least one first virtual instance, and the at least one virtual instance created or selected has the first virtual instance specification indicated by the first configuration information; The at least one first virtual instance sends at least one running result obtained by running the subprogram code by the at least one first virtual instance to the cloud platform; The cloud platform receives at least one running result sent by the at least one first virtual instance and continues to run the main program code according to the at least one running result; Wherein, after the at least one first virtual instance sends the at least one running result to the cloud platform, the at least one first virtual instance is released.
12. The method according to claim 11, wherein The first configuration information is further used to indicate the number of first virtual instances, and the at least one virtual instance created or selected has the number of first virtual instances indicated by the first configuration information.
13. The method according to claim 12, characterized in that, The first configuration information is further used to indicate the type of the first virtual instance, and the at least one virtual instance created or selected belongs to the type of the first virtual instance indicated by the first configuration information.
14. The method according to claim 12, wherein The number of the first virtual instances is greater than 1, and the cloud platform configures at least one first virtual instance in at least one data center according to the first annotation, including: The cloud platform configures the number of first virtual instances of the first virtual instance in at least one data center; the method further includes: The number of first virtual instances of the first virtual instance respectively run the subprogram code to perform data processing on different to-be-processed data respectively obtained from the shared storage space.
15. The method according to claim 14, characterized in that The first virtual instance number of first virtual instances respectively run the subprogram code to perform data processing on different pieces of data to be processed respectively obtained from the shared storage space, including: The first virtual instance number of first virtual instances respectively run the subprogram code to perform data processing with the same business logic on different pieces of data to be processed respectively obtained from the shared storage space.
16. The method according to claim 12, wherein The number of the first virtual instances is 1. The cloud platform configures one first virtual instance in the at least one data center according to the number of the first virtual instances. The subprogram code further includes nested program code, and a second annotation is set in the nested program code. The second annotation includes second configuration information, and the second configuration information includes one or any combination of a second virtual instance specification, a second virtual instance number, and a second virtual instance type. The method further includes: When the first virtual instance runs the subprogram code to a position where the nested program code needs to be called, it pauses running the subprogram code and requests the cloud platform for the running result of the nested program code. Wherein, the second annotation is used to instruct the cloud platform to configure at least one second virtual instance in the at least one data center, and the at least one second virtual instance matches the second configuration information indicated by the second annotation. The nested program code is sent by the cloud platform to the at least one second virtual instance; The cloud platform receives at least one running result obtained by the at least one second virtual instance running the nested program code and sends the at least one running result to the first virtual instance; The first virtual instance continues to run the subprogram code according to the at least one running result.
17. The method according to any one of claims 11 to 16, characterized in that, The method further includes: The cloud platform provides a cloud service and sets a cloud service application programming interface API for the cloud service, wherein the cloud service API is called in the subprogram code.
18. The method according to claim 17, wherein The cloud service API includes: one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
19. The method according to any one of claims 11 to 16, characterized in that The symbol mark is pre-agreed by the cloud platform, and the first virtual instance specification further includes or specifies the processor main frequency size.
20. The method according to any one of claims 11 to 16, characterized in that The first virtual instance type is used to indicate either a virtual machine or a container.
21. A system for providing cloud services, characterized in that, Including: A service virtual instance, which is used to obtain program code developed by a tenant in the service virtual instance or program code downloaded from other devices, wherein the service virtual instance is remotely logged in by the tenant through a client; wherein, the obtained program code or the downloaded program code includes a main program code and a subprogram code, and a first annotation is set in the subprogram code. The first annotation includes first configuration information and a symbol mark, the symbol mark is adjacent to the first configuration information, and the first configuration information is used to indicate a first virtual instance specification. The first virtual instance specification includes or specifies the number of processor cores and the memory size; The business virtual instance is used to run the main program code. When running the main program code to the position where the subprogram code needs to be called, the running of the main program code is paused, and the subprogram code is sent to the cloud platform; The cloud platform is used to configure at least one first virtual instance in at least one data center according to the first annotation, where the at least one first virtual instance matches the first configuration information of the first annotation; wherein, the cloud platform is used to configure at least one first virtual instance in at least one data center in the following manner: The cloud platform is used to create at least one first virtual instance in the at least one data center that matches the first configuration information in the first annotation; or The cloud platform is used to select at least one first virtual instance that matches the first configuration information in the first annotation from multiple virtual instances, where the multiple virtual instances are pre-created by the cloud platform in the at least one data center; Wherein, the at least one virtual instance created or selected has the first virtual instance specification indicated by the first configuration information; The at least one first virtual instance is used to obtain the subprogram code from the cloud platform; The at least one first virtual instance is used to run the subprogram code to obtain at least one running result, and send the at least one running result to the cloud platform; The business virtual instance is used to obtain the at least one running result from the cloud platform; The business virtual instance is used to continue running the main program code according to the at least one running result; Wherein, after the at least one first virtual instance sends the at least one running result to the cloud platform, the at least one first virtual instance is released.
22. The system according to claim 21, wherein The first configuration information is further used to indicate the number of first virtual instances and the type of first virtual instances. The at least one virtual instance created or selected has the number of first virtual instances indicated by the first configuration information and belongs to the type of first virtual instances indicated by the first configuration information.
23. The system according to claim 22, wherein Before the business virtual instance obtains the program code developed by the tenant in the business virtual instance or the program code downloaded from other devices, The cloud platform is used to determine the type and specification of the business virtual instance selected by the tenant at the virtual instance service interface of the cloud platform; The cloud platform is used to create the business virtual instance corresponding to the type and the specification in the at least one data center.
24. The system according to claim 22, wherein The number of first virtual instances is greater than 1, The cloud platform is used to configure the number of first virtual instances of the first virtual instance in at least one data center; The number of first virtual instances is used to respectively run the subprogram code to perform data processing on different to-be-processed data respectively obtained from the shared storage space.
25. The system according to claim 24, wherein, The first virtual instance quantity of first virtual instances is used to respectively run the subprogram code to perform data processing of the same business logic on different to-be-processed data respectively obtained from the shared storage space.
26. The system according to claim 22, wherein The quantity of the first virtual instances is 1. The cloud platform is used to configure one first virtual instance in the at least one data center according to the quantity of the first virtual instances. The subprogram code further includes nested program code, and a second annotation is set in the nested program code. The second annotation includes second configuration information, and the second configuration information includes one or any combination of a second virtual instance specification, a second virtual instance quantity, and a second virtual instance type. When running the subprogram code to a position where the nested program code needs to be called, the first virtual instance is used to pause running the subprogram code and request the cloud platform for the running result of the nested program code. Wherein, the second annotation is used to instruct the cloud platform to configure at least one second virtual instance in the at least one data center, the at least one second virtual instance matches the second configuration information indicated by the second annotation, and the nested program code is sent by the cloud platform to the at least one second virtual instance. The cloud platform is used to receive at least one running result obtained by the at least one second virtual instance running the nested program code and send the at least one running result to the first virtual instance. The first virtual instance is used to continue running the subprogram code according to the at least one running result.
27. The system according to any one of claims 21 to 26, wherein The cloud platform is used to provide cloud services and set a cloud service application programming interface API for the cloud services, and the cloud service API is called in the subprogram code.
28. The system according to claim 27, wherein The cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
29. The system according to any one of claims 21 to 26, characterized in that The symbol mark is pre-agreed by the cloud platform, and the first virtual instance specification further includes or specifies the processor main frequency size.
30. The system according to any one of claims 21 to 26, characterized in that, The first virtual instance type is used to indicate either a virtual machine or a container.
31. A system for providing cloud services, characterized in that, Including: A cloud platform, which is used to receive the program code uploaded by a tenant to an upload interface, where the upload interface is set in the cloud platform; Or used to receive the program code remotely input by the tenant to a program editing interface, where the program editing interface is set in the cloud platform; wherein the uploaded program code or the remotely input program code includes a main program code and a subprogram code, and a first annotation is set in the subprogram code. The first annotation includes first configuration information and a symbol mark, the symbol mark is adjacent to the first configuration information, and the first configuration information is used to indicate a first virtual instance specification. The first virtual instance specification includes or specifies the number of processor cores and the memory size. The cloud platform is used to pause the execution of the main program code when the main program code runs to a position where the subprogram code needs to be called, and request at least one running result obtained by running the subprogram code from at least one first virtual instance. The first annotation is used to instruct the cloud platform to create the at least one first virtual instance in at least one data center or the first annotation is used to instruct the cloud platform to select the at least one first virtual instance that matches the first configuration information in the first annotation from multiple virtual instances. The multiple virtual instances are pre-created by the cloud platform in the at least one data center. And the subprogram code is sent by the cloud platform to the at least one first virtual instance. The at least one virtual instance created or selected has the first virtual instance specification indicated by the first configuration information; The at least one first virtual instance is used to send at least one running result obtained by running the subprogram code by the at least one first virtual instance to the cloud platform; The cloud platform is used to receive at least one running result sent by the at least one first virtual instance and continue to run the main program code according to the at least one running result; Wherein, after the at least one first virtual instance sends the at least one running result to the cloud platform, the at least one first virtual instance is released.
32. The system according to claim 31, wherein The first configuration information is further used to indicate the number of first virtual instances, and the at least one virtual instance created or selected has the number of first virtual instances indicated by the first configuration information.
33. The system according to claim 32, wherein The first configuration information is further used to indicate the type of first virtual instance, and the at least one virtual instance created or selected belongs to the type of first virtual instance indicated by the first configuration information.
34. The system according to claim 32, wherein The number of the first virtual instances is greater than 1, The cloud platform is used to configure the number of first virtual instances in at least one data center; The number of first virtual instances is used to respectively run the subprogram code to process different to-be-processed data respectively obtained from the shared storage space.
35. The system according to claim 34, wherein, The number of first virtual instances is used to respectively run the subprogram code to process different to-be-processed data respectively obtained from the shared storage space with the same business logic.
36. The system according to claim 32, wherein The number of the first virtual instances is 1. The cloud platform configures one first virtual instance in the at least one data center according to the number of the first virtual instances. The subprogram code further includes nested program code, and a second annotation is set in the nested program code. The second annotation includes second configuration information, and the second configuration information includes one or any combination of a second virtual instance specification, a second virtual instance number, and a second virtual instance type. The first virtual instance is used to pause the execution of the subroutine code when the subroutine code runs to a position where the nested program code needs to be called, and request the running result of the nested program code from the cloud platform. The second annotation is used to instruct the cloud platform to configure at least one second virtual instance in the at least one data center, and the at least one second virtual instance matches the second configuration information indicated by the second annotation. The nested program code is sent by the cloud platform to the at least one second virtual instance; The cloud platform is used to receive at least one running result obtained by the at least one second virtual instance running the nested program code, and send the at least one running result to the first virtual instance; The first virtual instance is used to continue running the subroutine code according to the at least one running result.
37. The system according to any one of claims 31 to 36, wherein The cloud platform is used to provide cloud services and set a cloud service application programming interface API for the cloud services, and the cloud service API is called in the subroutine code.
38. The system according to claim 37, wherein, The cloud service API includes one or any combination of an object storage service API, a database service API, a shared cache service API, and a message queue service API.
39. The system according to any one of claims 31 to 36, characterized in that, The symbol mark is pre-agreed by the cloud platform, and the first virtual instance specification further includes or specifies the processor main frequency size.
40. The system according to any one of claims 31 to 36, characterized in that, The first virtual instance type is used to indicate either a virtual machine or a container.
41. A computer storage medium, characterized in that, It includes computer-readable instructions, and when the computer-readable instructions are executed, the method according to any one of claims 1 to 10 is implemented, or the method according to any one of claims 11 to 20 is implemented.
42. A computer program product containing instructions, which when run on a computer, causes the computer to execute the method according to any one of claims 1 to 10, or implement the method according to any one of claims 11 to 20.
Citation Information
Patent Citations
Providing fine-grained access remote command execution for virtual machine instances in a distributed computing environment
CN108292349A