HomeCloud ComputingA sensible information to high-performance serverless with GraalVM and Spring

A sensible information to high-performance serverless with GraalVM and Spring



  1. Construct the Docker picture (e.g., native-compile-image).
  2. Run the container within the background.
  3. Copy the ultimate zip archive from the container to the construct agent’s native filesystem.
Bash


# Run the container in indifferent mode, giving it a reputation for reference
docker run -d --rm --name native-compile-container native-compile-image

# Copy the compiled zip file from the working container to the construct agent's workspace
docker cp native-compile-container:/workspace/goal/spring-serverless-function.zip./goal/

This course of leaves you with a single, deployable spring-serverless-function.zip file, which might then be uploaded to an artifact repository.

Deploying with the AWS CDK

With the deployment artifact prepared, I can outline the Lambda perform utilizing an infrastructure-as-code software just like the AWS Cloud Improvement Package (CDK). The CDK code factors to the zip file created by the pipeline and configures the Lambda perform.

TypeScript


// Instance CDK code for outlining the Lambda perform
import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';

// Assuming 'this' is a CDK Stack context
const functionAssetDirectory = '/runtime/goal/spring-serverless-function.zip';
const runtimeDir = path.be a part of(__dirname, '..', functionAssetDirectory);

new lambda.Perform(this, 'MyNativeLambda', {
  runtime: lambda.Runtime.PROVIDED_AL2023,
  code: lambda.Code.fromAsset(runtimeDir),
  handler: 'org.springframework.cloud.perform.adapter.aws.FunctionInvoker::handleRequest',
  memorySize: 256,
  timeout: Length.seconds(30),
  //... different configurations
});

Right here, lambda.Runtime.PROVIDED_AL2023 specifies that we’re utilizing a customized runtime. The code property factors to our zip archive. Crucially, the handler remains to be set to Spring’s generic FunctionInvoker.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments