AI application development under the serverless architecture

Introduction: CI/CD is a method of frequently delivering applications to customers by introducing automated processes during the application development phase. The core concepts of CI/CD are continuous integration, continuous delivery, and continuous deployment.

Combination of Serverless Architecture and CI/CD Tools

CI/CD is an approach to frequently deliver applications to customers by introducing automation into the application development phase. As shown in the figure, the core concepts of CI/CD are continuous integration, continuous delivery and continuous deployment.

As a solution for development and operations teams, CI/CD focuses on the problems that arise when integrating new code. Specifically, CI/CD enables continuous automation and continuous monitoring throughout the application lifecycle (from integration and testing phases to delivery and deployment phases). These associated transactions are often collectively referred to as "CI/CD pipelines" and are collaboratively supported by development and operations teams in an agile manner.

Concept and content diagram of CI/CD

Under the Serverless architecture, there are usually many functions that constitute a complete function or service. This relatively fine-grained function often brings great inconvenience to later project maintenance, including but not limited to function management, project construction, and release. The inconvenience of level etc. At this time, in the serverless architecture, CI/CD is particularly important. A more scientific and secure continuous integration and deployment process will not only make the overall business process more standardized, but also reduce the probability of errors caused by manual operations and manual integration and deployment to a certain extent, and at the same time reduce the work of operation and maintenance personnel on a large scale burden.

If we want to scientifically and conveniently carry out continuous integration, delivery, and deployment of serverless applications through the CI/CD platform, we usually need to use corresponding developer tools, such as Serverless Framework, Serverless Devs, etc. The process of configuring Serverless developer tools to the CI/CD platform can be simplified as the following figure.

The process of configuring serverless developer tools to CI/CD platform

1. Integration with GitHub Action

In the Yaml file of GitHub Action, add Serverless Devs related download, configuration, and command execution related content. For example, create the file .github/workflows/publish.yml in the GitHub warehouse, and the content of the file is as follows:

Integration with GitHub Action mainly includes the following parts.

• Install the latest version of the Serverless Devs developer tools via NPM:
run: npm install -g @serverless-devs/s
• Use the config command to configure information such as keys:
run: s config add --AccountID ${{secrets.AccountID}} --AccessKeyID ${{secrets.
AccessKeyID}} --AccessKeySecret ${{secrets.AccessKeySecret}} -a default
• Execute certain commands, such as deploying the project through the deploy command, or building the project through build and other commands:
run: s deploy

About key configuration: Key information is obtained through ${{secrets.*}}. At this time, you need to configure the required key and the corresponding Key into GitHub Secrets. For example, in the above case, you need AccountID, AccessKeyID, AccessKeySecret three key Key can configure the relevant content.

Find the GitHub Secrets page, as shown.

2. Integration with Gitee Go
After enabling the Gitee Go service, you can add related downloads, configurations, and command execution related content of Serverless Devs in the Yaml file of the pipeline. For example, create the file .github/workflows/publish.yml in the GitHub repository.

Similar to the integration process of GitHub Action, the integration with Gitee Go mainly includes the following parts.
• Install the latest version of the Serverless Devs developer tools via NPM:
npm install -g @serverless-devs/s
• Use the config command to configure information such as keys:
s config add --AccountID $ACCOUNTID --AccessKeyID $ACCESSKEYID --AccessKeySecret
$ACCESSKEYSECRET -a default
• Execute certain commands, such as deploying the project through the deploy command, or building the project through build and other commands:
s deploy
About the configuration of the key: the key information is obtained through $*. At this time, configure the required key and the corresponding Key to the environment variable management of Gitee. For example, in the above case, AccountID, AccessKeyID, AccessKeySecret are required The Key of the three keys can configure the relevant content.
Find the environment variable management page of Gitee, as shown in the figure.

3. Integration with Jenkins

Before integrating Serverless Devs into Jenkins, you need to install and run Jenkins based on the Jenkins official website. Start Jenkins locally, enter the link http://localhost:8080 through the browser and configure the basic settings, and then add the credential settings, as shown in the figure below.

Key information can be added as needed. Taking Alibaba Cloud as an example, add 3 new global credentials:
• jenkins-alicloud-account-id : Aliyun accountId
• jenkins-alicloud-access-key-id : Aliyun accessKeyId
• jenkins-alicloud-access-key-secret : Aliyun accessKeySecret
At this point, you can improve your own Serverless Devs project. Create the file Jenkinsfile:

The main content of integration with Jenkins includes the following two parts.

• Environment part: mainly process the key according to the key information configured in the above steps.
• stages part: including the sh 'scripts/setup.sh' part, that is, to run the scripts/setup.sh file to prepare and configure related content.
To prepare the scripts/setup.sh file, just create the file under the project.

4. Integration with cloud effect

In the cloud effect, you can directly select the Serverless Devs developer tool, and enter the following content in the custom command:
# input your command here
npm install -g @serverless-devs/s
s config add --AccountID ${ACCOUNTID} --AccessKeyID ${ACCESSKEYID} --AccessKeySecret
${ACCESSKEYSECRET} -a default
s deploy
Similar to the configuration of GitHub Action, Gitee Go, and Jenkins, the integration with cloud effects also mainly includes 3 parts.
• Install the latest version of the Serverless Devs developer tools:
npm install -g @serverless-devs/s
• Use the config command to configure information such as keys:
s config add --AccountID ${ACCOUNTID} --AccessKeyID
${ACCESSKEYID} --AccessKeySecret
• Execute certain commands, such as deploying the project through the deploy command, or building the project through build and other commands:
s deploy -y

5. CI/CD platform integration

Summary Through the above cases, it is not difficult to find that when doing automated release, the three core processes are as follows.
• Download tool: The command is npm install -g @Serverless-devs/s.
• Configure the key: the command is s config add --AccountID $ACCOUNTID --AccessKeyID $ACCESSK EYID --AccessKeySecret $ACCESSKEYSECRET -a default.
• Project deployment: the command is s deploy.

Although only GitHub Action, Gitee Go, Jenkins, and Yunxiao are used as examples, in fact, no matter which tool is integrated with the CI/CD platform, the above three core processes will not change substantially. In addition, the processes listed above are mostly for automated release, and sometimes some testing and reconstruction are required before release, so as to be properly improved according to specific actual needs.

To sum up, if you want to complete the CI/CD construction of serverless applications very simply, quickly and scientifically, a complete developer tool is essential.

Serverless Devs is a multi-cloud developer tool. We can use this tool to deploy function computing and other related services of multiple cloud vendors such as AWS, Alibaba Cloud, and Tencent Cloud very simply, quickly, and conveniently. At the same time, Serverless Devs is also an open source project, which is convenient for users to contribute components and applications anytime and anywhere.

Observability of Serverless Applications

The observability of serverless applications has attracted the attention of many users. Observability is the way to judge the internal state of a system through its external manifestations. In application development, observability helps to judge the internal health status of the system. When a problem occurs in the system, it helps to locate, troubleshoot, and analyze the problem; when the system is running smoothly, it helps to assess risks and predict possible problems.

In serverless application development, if the concurrency of functions continues to increase, it is likely that the business scale of the business promotion team is expanding rapidly. In order to avoid triggering flow control when the concurrency limit is reached, developers need to increase the concurrency in advance.

Taking Alibaba Cloud Function Compute as an example, Alibaba Cloud Function Compute provides multiple dimensions of observability, including Logging, Metrics, and Tracing.

In the console monitoring center, we can view the overall metrics, service-level metrics, and metrics of each function, as well as the request records of the current function calculation.

According to different request records, we can also view the detailed information of Function Compute.

In addition to viewing function logs and other information in the monitoring center of the console, we can also view detailed log information of Function Compute on the function details page.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us