Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless Java with Spring Boot (DevBcn 2023)

Serverless Java with Spring Boot (DevBcn 2023)

Serverless technologies have one clear goal: enabling developers to focus on delivering value while the platform takes care of all the infrastructural concerns. How does Java fit into this space?

This session will demonstrate how to use the native constructs in the Java standard libraries to follow a functional programming paradigm when implementing the business logic of your applications. Functions will be transparently enhanced by Spring Cloud Function, a framework that enriches standard Java to build data pipelines, including features like type conversion and function composition.

Building functions is not enough. We need a strategy to expose and integrate them with the rest of the system. This presentation will show different options to consume Java functions via platforms like Knative, AWS Lambda, Azure Functions, and GCP Functions.

Events are a fundamental part of serverless applications. You’ll see how to use the CloudEvents standard and how to integrate functions with message brokers like RabbitMQ and Kafka. Spring Cloud Stream provides such functionality without requiring any change to your code.

Functions are usually deployed to platforms with autoscaling and scale-to-zero features. GraalVM will be used to compile Java functions as native executables and provides instant startup, instant peak performance, and reduced memory consumption.

Thomas Vitale

July 05, 2023
Tweet

More Decks by Thomas Vitale

Other Decks in Technology

Transcript

  1. Systematic • Software Engineer and Cloud Architect. • Author of

    “Cloud Native Spring in Action” (Manning). • OSS contributor (Java, Spring, Cloud Native Technologies) Thomas Vitale thomasvitale.com @vitalethomas
  2. Serverless Architectures Developers focus on code Focus on business logic

    Developer Platform Infrastructure Provisioning Workload Management Dynamic Scaling @vitalethomas
  3. Serverless Platforms From application artifact to URI @vitalethomas aws lambda

    create-function --function-name Uppercase --zip-file java-function.jar kn service create uppercase --image ghcr.io/thomasvitale/java-function
  4. Spring Boot 3 and Native Executables The bene fi ts

    of GraalVM Instant Startup Low Resource Usage Instant Peak Performance @vitalethomas Reduced Surface Attack Compact Packaging
  5. Spring Boot 3 and Native Executables The downsides of GraalVM

    Longer Build Time Additional con fi guration might be needed @vitalethomas
  6. Spring Cloud Function Business logic as functions Transparent Type Conversion

    Function Arity Function Composition Reactive Support JAR Functions @vitalethomas
  7. @vitalethomas AWS Lambda Spring Cloud Function Java Function AWS Lambda

    <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-function-adapter-aws</artifactId> </dependency>
  8. @vitalethomas Azure Function Spring Cloud Function Java Function Azure Functions

    <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-function-adapter-azure</artifactId> </dependency>
  9. @vitalethomas Google Cloud Function Spring Cloud Function Java Function Google

    Cloud Functions <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-function-adapter-aws</artifactId> </dependency>
  10. Spring Cloud Stream Event-driven applications Integration with event brokers Bindings

    with functions Publish Subscribe Consumer Groups Partitions @vitalethomas
  11. Testcontainers Development and testing with external dependencies OCI containers Run

    external dependencies as OCI containers Data Layer Tests Ensure environment parity by testing the data layer with the real database Integration Tests Use containers for databases, message queues, and web servers @vitalethomas
  12. Developer Experience “…developer experience could be defined as a means

    for capturing how developers think and feel about their activities within their working environments, with the assumption that an improvement of the developer experience has positive impacts on characteristics such as sustained team and project performance.” (F. Fagerholm, J. Münch) Developer Experience: Concept and De fi nition (F. Fagerholm, J. Münch) @vitalethomas
  13. Dockerfiles “Dockerfiles are easy to write, but the current development

    guidelines do not produce containers that are repeatable and hardened.” CNCF Software Supply Chain Security Paper https://github.com/cncf/tag-security/tree/main/supply-chain-security @vitalethomas
  14. Deploying Functions with Knative From idea to deployment with autoscaling

    URL func create Image func deploy Kubernetes Cluster Container Container Container Knative Serving @vitalethomas
  15. Deploying Functions with Knative From idea to deployment with autoscaling

    URL func create Image func deploy Kubernetes Cluster Container Container Container Knative Serving @vitalethomas