Slide 1

Slide 1 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Effectively running Java applications on AWS Maximilian Schellhorn Senior Solutions Architect Amazon Web Services D E E P D I V E Dennis Kieselhorst Principal Solutions Architect Amazon Web Services

Slide 2

Slide 2 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What to expect in the next hours… • Introduction Java on AWS ▪ Motivation – why Java matters for us ▪ OpenJDK versions and Amazon Corretto ▪ How to run Java on AWS? • How to move a Java application to the Cloud? ▪ Demo: Running a (containerized) Java workload on AWS ▪ Common Migration and Modernization scenarios • Developing modern, cloud-native Java applications on AWS ▪ Serverless with AWS Lambda ▪ Developer Tooling ▪ Demo: Building a Serverless Java Function on AWS Lambda

Slide 3

Slide 3 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Motivation

Slide 4

Slide 4 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 4 My Java application is >20 years old.

Slide 5

Slide 5 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. JavaScript Python Go Kotlin Scala Rust Ruby C# Building new apps in Java?

Slide 6

Slide 6 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Evolution of compute over the last years • Restricted & ephemeral environments • Scaling horizontally • Start up-time and resource utilization became important • Need to decrease latency and memory consumption • Portability became less relevant • Abstraction via Containers

Slide 7

Slide 7 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Java is adapting - several new projects to foster innovation • Broad ecosystem (libraries, tools and resources) & Developer experience • Over the past years companies invested in these technologies • New feature development: GraalVM native images, Project Leyden, CRaC (Coordinated Restore at Checkpoint), Accelerated Java release cycle • improved Garbage Collection (Shenandoah GC) and memory reduction via header size reduction (project Lilliput)

Slide 8

Slide 8 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Java @ Amazon

Slide 9

Slide 9 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is Amazon Corretto? • Downstream distribution of OpenJDK • Quarterly security releases • No-cost long-term releases – JDK 8, JDK 11, JDK 17, JDK 21 • Feature release train (JDK 15, JDK 16, JDK 18, JDK 19, JDK 20 …) • Drop-in OpenJDK replacement • certified using the Java Technical Compatibility Kit (TCK) to ensure it meets the Java SE standard • is available on Linux, Windows, and macOS

Slide 10

Slide 10 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. The history of Amazon Corretto • Created in late 2016 for Amazon internal use, released internally in 2017 • Enabled regular release of security patches to production fast and without surprises from breaking changes • With adoption, customers started asking for improvements ▪ Optimized performance (speed, memory utilization, response time) ▪ Lingering bugs in the JVM or the libraries • Decision to distribute Corretto ▪ In 2018 AWS customers started asking us to release our binaries ▪ The end of free updates for Oracle JDK 8 was scheduled for January 2019

Slide 11

Slide 11 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Java versions

Slide 12

Slide 12 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Statistics for Java version usage Source: JRebel 2023 Java Developer Productivity Report

Slide 13

Slide 13 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why should you upgrade? • JDK 11 (or older) is no longer being invested in • Many libraries and JVM fixes released after JDK8 • What should you do? Explore upgrading to JDK 17 or 21 • The performance improvements alone in 17 are worth the effort • It is common to see large (10–50%) improvements • The work to upgrade commonly takes from several days to two weeks.

Slide 14

Slide 14 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. New Relic’s 2023 State of the Java Ecosystem Report • Adoption of Java 17, a recent Long Term Support (LTS) version of Java, has skyrocketed, growing 430% in the past year • Amazon Corretto is now the most-used Java Development Kit (JDK), with a 31% share of Java instances that are using New Relic. • 70% of Java applications reporting to New Relic do so from a container. https://newrelic.com/resources/report/2023-state-of-the-java-ecosystem

Slide 15

Slide 15 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. OpenJDK versions and contributions • We will support JDK 8 until May, 2026 and JDK 11 until Sept, 2027 • Non-LTS versions should be upgraded with 30 days of the next release 2018 2019 2020 2021 JDK17 JDK16 JDK15 JDK14 JDK13 JDK12 JDK11 JDK10 JDK9 JDK8 JDK18 2022 2023 JDK19 JDK20 JDK21

Slide 16

Slide 16 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Growing contributions

Slide 17

Slide 17 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Java at AWS: Lessons Learned from Upgrading and Modernizing a Massive JVM Codebase Wednesday from 15:10 - 16:00 in Room 3

Slide 18

Slide 18 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. How to run Java on AWS?

Slide 19

Slide 19 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Our sample application today AWS Cloud Unicorn Store Amazon EventBridge Publish Event UNICORN_CREATED Virtual private cloud (VPC) Amazon Relational Database (RDS) for PostgreSQL Private subnet Public subnet Load Balancer Store Unicorn Users POST PUT GET DELETE /unicorns

Slide 20

Slide 20 text

AWS Global Infrastructure Regions & Availability Zones N A M E R I C A Available Region Announced # Availability Zone A S I A P A C I F I C A U S T R A L I A & N E W Z E A L A N D S A M E R I C A São Paulo 3 E U R O P E Frankfurt Ireland London Milan Paris Spain 3 3 3 3 3 3 Stockholm Zurich 3 3 A F R I C A Cape Town 3 M I D D L E E A S T Bahrain Tel Aviv UAE 3 3 3 Canada Central GovCloud US-East GovCloud US-West Northern California Northern Virginia Ohio 3 3 3 3 6 3 Oregon Canada West 4 *Beijing *Ningxia Hong Kong Hyderabad Jakarta Mumbai 3 3 3 3 3 3 Osaka Seoul Singapore Tokyo Malaysia Thailand 3 4 3 4 Melbourne Sydney Auckland 3 3 EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE

Slide 21

Slide 21 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Elastic Compute Cloud (Amazon EC2) Virtual servers in the cloud Physical servers in AWS global regions Guest 1 Guest 2 Guest n Hypervisor Host server 650+ EC2 instances

Slide 22

Slide 22 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Start with a source image Customize software and configurations Secure image with AWS-provided or custom hardening templates Test image with AWS provided or custom tests Distribute “golden” image to selected AWS Regions Repeat when updates are pending Build an EC2 Image

Slide 23

Slide 23 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Typical application architecture Multiple copies for scale and redundancy Load Balancer Autoscaling OS Language Runtime App VM Build Deploy CI/CD

Slide 24

Slide 24 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Shared Responsibility Model SOFTWARE COMPUTE STORAGE DATABASE NETWORKING HARDWARE/AWS GLOBAL INFRASTRUCTURE REGIONS AVAILABILITY ZONES EDGE LOCATIONS AWS RESPONSIBILITY FOR SECURITY ‘OF’ THE CLOUD OPERATING SYSTEM, NETWORK & FIREWALL CONFIGURATION PLATFORM, APPLICATIONS, IDENTITY & ACCESS MANAGEMENT CUSTOMER DATA NETWORKING TRAFFIC PROTECTION (ENCRYPTION, INTEGRITY, IDENTITY) SERVER-SIDE ENCRYPTION (FILE SYSTEM AND/OR DATA) CLIENT-SIDE DATA ENCRYPTION & DATA INTEGRITY AUTHENTICATION CUSTOMER RESPONSIBILITY FOR SECURITY ‘IN’ THE CLOUD

Slide 25

Slide 25 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Shared responsibility on Amazon EC2 (released 2006) Physical Server(s) Hypervisor EC2 Instances OS Language Runtime App Autoscaling Build Deploy CI/CD AWS responsibility Customer responsibility Load Balancer $ $ Pay for provisioned resources

Slide 26

Slide 26 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Containers

Slide 27

Slide 27 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Container advantages over traditional VMs Better resource utilization Embrace stateless applications Portability Agility

Slide 28

Slide 28 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Containers became popular Physical Server(s) Hypervisor EC2 Instance AWS responsibility Customer responsibility App Language Runtime OS Containers Container Orchestrator Container Orchestration Agent App Language Runtime

Slide 29

Slide 29 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Shared responsibility on Amazon Elastic Container Service (released 2015) Physical Server(s) Hypervisor EC2 Instance Autoscaling AWS responsibility Customer responsibility OS Container Orchestrator Container Orchestrator Load Balancer Container Orchestration Agent Build Deploy CI/CD ECS Containers App Language Runtime App Language Runtime $ $ Pay for provisioned resources

Slide 30

Slide 30 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Shared responsibility on AWS Fargate (released 2017) Physical Server(s) Hypervisor EC2 Instance Autoscaling AWS responsibility Customer responsibility OS Container Orchestrator Container Orchestration Agent OS Container Orchestration Agent EC2 Instance(s) Load Balancer Build Deploy CI/CD Containers App Language Runtime App Language Runtime $ Pay for provisioned resources at the container level $

Slide 31

Slide 31 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Shared responsibility on AWS App Runner (released 2021) Physical Server(s) Hypervisor Autoscaling AWS responsibility Customer responsibility OS Container Orchestrator Container Orchestration Agent OS Container Orchestration Agent Build Deploy CI/CD Autoscaling Build Deploy CI/CD Load Balancer Load Balancer EC2 Instance(s) Containers App Language Runtime App Language Runtime Containers Language Runtime Language Runtime Pay only during request processing $

Slide 32

Slide 32 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Web applications API servers managed runtime Java Multi-concurrent Stateless AWS App Runner - fully managed service for web applications

Slide 33

Slide 33 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. App Runner: Fully managed service for web applications AWS Fargate Amazon ECS Elastic Load Balancing AWS Auto Scaling AWS CodeBuild Web application Backend server

Slide 34

Slide 34 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Our sample application on App Runner AWS Cloud Unicorn Store on AWS App Runner Amazon EventBridge Publish Event UNICORN_CREATED Virtual private cloud (VPC) Amazon Relational Database (RDS) for PostgreSQL Private subnet Store Unicorn Users POST PUT GET DELETE /unicorns Amazon ECR

Slide 35

Slide 35 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Services for running Java applications beyond EC2 AWS Lambda Serverless AWS Fargate Container orchestration Amazon Elastic Kubernetes Service (EKS) Amazon Elastic Container Service (ECS) Red Hat OpenShift Service on AWS (ROSA) Opinionated deployment AWS App Runner AWS Elastic Beanstalk AWS Batch AWS IoT Greengrass AWS Amplify Amazon Lightsail

Slide 36

Slide 36 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. containers at scale Reduce decisions Reduce time build traditional applications operations minimum Amazon ECS delivers powerful simplicity

Slide 37

Slide 37 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Our sample application on ECS AWS Cloud Unicorn Store Container Amazon EventBridge Publish Event UNICORN_CREATED Virtual private cloud (VPC) Amazon Relational Database (RDS) for PostgreSQL Private subnet Public subnet Load Balancer Store Unicorn Users POST PUT GET DELETE /unicorns Amazon ECR Amazon ECS AWS Fargate

Slide 38

Slide 38 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon EKS or Amazon ECS?

Slide 39

Slide 39 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. agility efficiency AWS optimized Kubernetes Secure Kubernetes deployments Build community around Kubernetes Amazon EKS delivers open flexibility

Slide 40

Slide 40 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Integrated Kubernetes based application platform with built-in CI/CD, monitoring, and developer tools. existing skills Accelerate - Turn-key Platform

Slide 41

Slide 41 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. business logic Scales to zero fast Java AWS Lambda – Serverless Compute at scale

Slide 42

Slide 42 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Optimizations

Slide 43

Slide 43 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Measure. Then optimize. There‘s no silver bullet.

Slide 44

Slide 44 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Well-Architected Framework Container Build Lens https://docs.aws.amazon.com/wellarchitected/latest/container-build-lens/container-build-lens.html We provide cloud-agnostic questions and best practies on how to build and manage containers and container images.

Slide 45

Slide 45 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is initialization? Start JVM Initialize Context and Classes Retrieve Container Image Run method Run method …

Slide 46

Slide 46 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 1 2 Request Request Running application 3 Request … • Initialize the environment once • Handle multiple request with the same instance (concurrently) • Instance keeps running after request processing • Scaling based on metrics or manually Java in a container Initialization

Slide 47

Slide 47 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Topics for optimization • Reduce container image size • Build a custom Java runtime • Lazy loading of the container image • Ahead-of-time compilation • Optimize price-performance with AWS Graviton Kernel Base Image Image Image Container references parent image

Slide 48

Slide 48 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Seekable OCI (SOCI) • Lazy loading snapshotter plugin for containerd • SOCI combines an unmodified container image with a SOCI index (no build-time conversion step required) • the SOCI snapshotter lazily pulls the image at runtime • gain ~50% in container startup performance for large images (>250 MB)

Slide 49

Slide 49 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Optimize price- performance with AWS Graviton

Slide 50

Slide 50 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Custom AWS silicon with 64-bit Arm cores Available in e.g. Amazon EC2, AWS Lambda, AWS Fargate, Amazon Relational Database Service Up to 40% better price performance over comparable current generation x86-based instances Up to 60% less energy for the same performance than comparable EC2 instances AWS Graviton

Slide 51

Slide 51 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Multi-Architecture manifests Build image on arm64 or cross compile Push to registry Push to registry Docker manifest push arm64 image Multi-arch manifest Docker manifest create Build image on x86 Push to registry x86 image

Slide 52

Slide 52 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Common Migration & Modernization scenarios

Slide 53

Slide 53 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 82

Slide 54

Slide 54 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pathways and 7Rs Applications Databases Move to managed data Managed provisioning, backups, patching, monitoring, and scaling No code changes Amazon RDS Migrate to the cloud Apps/DBs run on VMs No code changes Customer operates everything above the infrastructure VMware Cloud on AWS Amazon EC2 Database on Amazon EC2 Relocate/rehost Purpose-built databases High performance and scalability Licensing savings Amazon Aurora Amazon DynamoDB Amazon Neptune Amazon Redshift Move to open-source License freedom/savings Performance improvement Cross-platform support Refactor/rewrite Move to containers Develop and deploy faster Application portability No code changes Replatform Amazon ECS AWS Fargate Amazon EKS Move to cloud- native Move from idea to market, faster Lower costs … AWS Lambda

Slide 55

Slide 55 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Sample enterprise deployments Open Source IBM Red Hat Oracle App Server Apache TomEE Apache Tomcat WebSphere (Open Source version: Open Liberty) JBoss EAP (Open Source version: WildFly) WebLogic (former vendor: BEA) Relational Database MySQL/ MariaDB PostgreSQL IBM DB2 Oracle Database Additional Software OpenJDK Apache HTTPD Nginx IBM JDK IBM HTTP Server OpenJDK JBoss EWS (Tomcat/ HTTPD) Oracle JDK Oracle Http Server Common Operating System Linux IBM Mainframe (z/OS), Windows Server, AIX, Linux, … Red Hat Enterprise Linux Solaris, (Oracle) Linux, …

Slide 56

Slide 56 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Modernization is a Journey Legacy On-Prem workloads Decreasing Cost of IT + Increasing Business Velocity Modernized Cloud-Native Apps Legacy, migrated apps On-Prem workloads On-Prem workloads Legacy, migrated apps Modernized Cloud-Native Apps Conduct assessment / Pilot Modernize a handful of apps - Refactor or Build new Continue to scale across the org to modernize business critical apps Cloud-Native transformation complete, optimization continues 1 2 3 Modernized Cloud-Native Application Estate $$$$ $$$ $$ $ 0% 100% Multi-year Journey 4

Slide 57

Slide 57 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Break

Slide 58

Slide 58 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Serverless Java

Slide 59

Slide 59 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Serverful Java overview Application Load Balancer Web app Auto Scaling Group HTTP server Framework Application code Java application

Slide 60

Slide 60 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why serverless? Get to market faster, deliver features Reduced operational overhead Automatic scaling by unit of consumption High performance and scalability Pay for value Pay for value vs. pay for instance Security & HA Security and high availability built in

Slide 61

Slide 61 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Changes in data state Requests to endpoints Changes in resource state Serverless Architecture Application code AWS Lambda function

Slide 62

Slide 62 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Serverless is more than compute AWS Lambda AWS Fargate Amazon API Gateway Amazon SNS Amazon SQS Compute Data stores Integration Amazon Aurora Serverless Amazon Simple Storage Service (Amazon S3) Amazon DynamoDB AWS AppSync AWS Step Functions

Slide 63

Slide 63 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Serverless with AWS Lambda

Slide 64

Slide 64 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What are Lambda functions? Handler function • Function executed on invocation • Java 8, Java 11, Java 17 supported Event • Invocation data sent to function • JSON event payload differs by source (API, State change, Queue) Context • Additional information from the service • Example: Request ID

Slide 65

Slide 65 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lambda Execution Model 102 Amazon SNS Amazon S3 reqs Amazon Kinesis changes AWS Lambda service Amazon API Gateway Lambda function Lambda function Synchronous Asynchronous Poll Amazon SQS AWS Lambda Function URLs

Slide 66

Slide 66 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda Memory configuration AWS Lambda exposes a memory control CPU core and network capacity are allocated proportionally 10240 MB 128 MB Source: https://github.com/alexcasalboni/aws-lambda-power-tuning

Slide 67

Slide 67 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Getting started

Slide 68

Slide 68 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda Java libraries aws-lambda-java-core ▪ Handler interfaces ▪ Context object aws-lambda-java-events ▪ Object types of AWS native integrations aws-lambda-java-tests ▪ Junit extensions to simplify testing

Slide 69

Slide 69 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Package & Deploy Java applications to AWS Lambda Code Maven Shade Plugin Maven Assembly Plugin Gradle zip task Gradle shadow plugin ZIP or JAR Archive Uber Jar with Maven Shade Plugin Zip Archive with Gradle Task Build Uber Jars or Zip Archives with familiar build tooling Upload via AWS Console, AWS CLI , Amazon S3 or framework automation

Slide 70

Slide 70 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Example: Simple Function URL AWS Lambda User Function Url

Slide 71

Slide 71 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Example: REST API AWS Lambda Amazon API Gateway AWS Lambda GET POST com.unicorn.store.GetHandler /unicorns com.unicorn.store.PostHandler

Slide 72

Slide 72 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Example: Queue processor Amazon SQS Queue Queue Processor Lambda function Lambda function Lambda function

Slide 73

Slide 73 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Compatibility

Slide 74

Slide 74 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Databases AWS Services Etc. Lambda Function API Request State change

Slide 75

Slide 75 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Method 1: Handle request objects AWS Lambda Amazon API Gateway Amazon SQS Queue AWS Lambda AWS Lambda Amazon Simple Storage Service (Amazon S3)

Slide 76

Slide 76 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Method 1: Handle request objects No need for embedded HTTP servers (API Gateway or Function URL take care of this) Handle Requests via aws-lambda-java-events or raw via Map or Input-Outputstream Framework implementations Spring Cloud Function Micronaut Serverless Function (Application Type) Quarkus aws-lambda extension or Funqy

Slide 77

Slide 77 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What about RestControllers?

Slide 78

Slide 78 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Functions are invoked by events • AWS Lambda is invoked via events (API Event, S3 Object Event, SQS Event ..) • Events follow a certain structure • This is different from accepting a HTTP connection Amazon API Gateway AWS Lambda POST /v1/pets HTTP/2 Host: x.execute-api.eu-west-1.. User-Agent: curl/7.64.1 Accept: */* Content-Type: application/json Content-Length: 39 Body: {“data:“ : “test“} { "body": “{“data“: “test“}“ , "resource": "/{proxy+}", "path": "/path/to/resource", "httpMethod": "POST", "isBase64Encoded": true, "headers": { "Accept-Encoding": "gzip", "Accept-Language": "en-US,en;q=0.8" }, }, "requestContext": { "accountId": "123456789012", "requestId": "c6af9ac6-7b61-..", ... } }

Slide 79

Slide 79 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Adapter logic Web app function Invocation event mapped to framework request Function result mapped from framework response Web application wrapped in adapter logic. Amazon API Gateway Method 2: HTTP adapter

Slide 80

Slide 80 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Method 2: Example with AWS Serverless Java Container • Transforms events so that frameworks can handle them as if it was an HTTP Request • Routing via RestController, POJO serialization, HTTP status codes • Add the library to your code and provide a configuration class Now supports Java17 and Spring Boot 3

Slide 81

Slide 81 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Method 2: Advantages of HTTP Adapter Use the familiar @Controller programming style Easily port your existing applications to AWS Lambda Framework implementations Spring Boot via Serverless Java Container Micronaut via micronaut-function-aws-api-proxy Quarkus via AWS Lambda HTTP extension com.amazonaws.serverless.proxy.spring.SpringDelegatingLambdaContainerHandler

Slide 82

Slide 82 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. DEMO Deploying a Spring Boot Application to AWS Lambda

Slide 83

Slide 83 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Performance

Slide 84

Slide 84 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 1 2 Request Request Running application 3 Request … • Initialize the environment once • Handle multiple request with the same instance (concurrently) • Instance keeps running after request processing • Scaling based on metrics or manually Java in a container Initialization

Slide 85

Slide 85 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execution Environment ready? Download Code Start Runtime Initialize Function Code Code execution Request Code execution No Yes Create Execution Environment Execution Environment Cold start Warm start AWS Lambda request handling

Slide 86

Slide 86 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Initialize execution environment on first invoke • An execution environment handles a single request at a time • If an execution environment is busy with a request – another environment is started – simpler programming model • Scales to zero if there is no request – Managed auto scaling 1 Initialization Execution Execution 2 Execution 3 Initialization 4 Execution Java with AWS Lambda Env #1 Env #2

Slide 87

Slide 87 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 0 2 4 6 8 10 12 14 0 1 2 3 4 5 6 7 8 9 Tiered Compilation Compile Time frameworks No framework No optimization Lightweight dep. Function handler GraalVM Effort to modernize Cold-start (seconds) Provisioned Concurrency AWS Lambda performance optimizations Default with Java 17 on AWS Lambda

Slide 88

Slide 88 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda Provisioned Concurrency Sets floor on minimum number of execution environments Pre-warm execution environments to reduce cold-start impact Can save costs in certain situations

Slide 89

Slide 89 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda SnapStart Up to 10x faster start-up performance NEW

Slide 90

Slide 90 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda SnapStart microVM snapshot technology • Takes a snapshot of the memory and disk state • Snapshot encryption & caching for low-latency access • Creates new Lambda environments from cached snapshot • Fully Managed

Slide 91

Slide 91 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Code execution Invoke Resume Resume Snapshot Post Snapshot Hook (optional) Pre Snapshot Hook (optional) Create Execution Environment Init during deployment Download Code Start Runtime Initialize Function Code Create Snapshot first request How SnapStart works

Slide 92

Slide 92 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. SnapStart benefits • No additional cost • Minimal to no code changes • Customization via Runtime Hooks Without SnapStart With SnapStart 6.725 - 80 % 1.15 Full Duration Results will vary based on your application

Slide 93

Slide 93 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. DEMO AWS Lambda SnapStart

Slide 94

Slide 94 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 0 2 4 6 8 10 12 14 0 1 2 3 4 5 6 7 8 9 Tiered Compilation Compile Time frameworks No framework No optimization Lightweight dep. Function handler GraalVM Effort to modernize Cold-start (seconds) Provisioned Concurrency AWS Lambda performance optimizations Default with Java 17 on AWS Lambda SnapStart

Slide 95

Slide 95 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. GraalVM native images on AWS Lambda Create a native binary and deploy as AWS Lambda custom runtime Sub-second application startup and low memory footprint Frameworks provide built-in support (Micronaut, Quarkus, Spring) bootstrap

Slide 96

Slide 96 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Deep Dive: Java on AWS Lambda Workshop https://catalog.workshops.aws/java-on-aws-lambda

Slide 97

Slide 97 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Serverless Java Replatforming Guide

Slide 98

Slide 98 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Powertools for AWS Lambda J A V A L I B R A R Y T O S I M P L I F Y T R A C I N G , S T R U C T U R E D L O G G I N G A N D C U S T O M M E T R I C S • Facilitate best practice adoption • Increase developer velocity • Optional modules: • Parameter handling • Idempotency • SQS Large Message and Batching Options • Serialization, Validation and custom resource support

Slide 99

Slide 99 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Java on AWS Developer Tooling

Slide 100

Slide 100 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. The development flow IDE Support Frameworks & SDK Review & Analyze Build & Deploy

Slide 101

Slide 101 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. IDE Support

Slide 102

Slide 102 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Toolkit for IntelliJ IDEA • AWS Resource explorer • Inspect AWS Cloudformation stacks • View and search Cloudwatch Logs • Serverless Development (Debug, Invoke, Package) Lambda functions • Connect to Amazon RDS with temporary credentials • Amazon CodeWhisperer integration

Slide 103

Slide 103 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Toolkit for Visual Studio Code • AWS Resource & CDK explorer • Cloudformation YAML Support • Viewing Cloudwatch Log Streams • Check ECR images, write ECS task definition files • Debug & develop Serverless applications • Model Step Functions locally

Slide 104

Slide 104 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon CodeWhisperer B U I L D A P P L I C A T I O N S F A S T E R A N D M O R E S E C U R E L Y W I T H Y O U R A I C O D I N G C O M P A N I O N Real-time code suggestions Reference tracker Security scan IDE context automatically sent to CodeWhisperer Receive code suggestions Amazon CodeWhisperer Uses AI to generate code recommendations based on prior code and comments in your IDE Writing code in the IDE

Slide 105

Slide 105 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 106

Slide 106 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 107

Slide 107 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Frameworks & SDK

Slide 108

Slide 108 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS SDK for Java v2 Easily interact with AWS Services from your Java code (S3, SNS, SQS etc.) Integrated retry and backoff behavior Leverage different strategies for IAM authentication GraalVM native image compatible

Slide 109

Slide 109 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Spring framework Spring Cloud for Amazon Web Services (https://awspring.io) • Interact with AWS services using well-known Spring APIs and idioms • Examples: • Spring Messaging API with Amazon SQS • Spring Cache API with Amazon ElasticSearch • Emails via Amazon SES • Bootstrap property sources with AWS Parameter Store or Secrets Manager Spring Cloud Function (AWS) • Use in conjunction with AWS Lambda to avoid payload translation • Use Spring features in a functional environment B U I L D M O D E R N J A V A B A S E D E N T E R P R I S E A P P L I C A T I O N S

Slide 110

Slide 110 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Micronaut Certified for Amazon Corretto Majority of work during compile-time • Eliminates reflection, runtime proxies, dynamic class loading • Smaller startup time & memory footprint AWS CDK Support, AWS SDK integration, AWS Lambda SnapStart Support Easily create GraalVM native images M O D E R N J V M - B A S E D , C L O U D N A T I V E F R A M E W O R K

Slide 111

Slide 111 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Quarkus Build time processing & reduction in reflection usage Reduced startup time & lower memory footprint First-Class Support for GraalVM Native Images Extensions for a variety of AWS services (KMS, S3, SQS, SNS, DynamoDB) Kubernetes & AWS Lambda extensions K U B E R N E T E S & C L O U D N A T I V E J A V A F R A M E W O R K

Slide 112

Slide 112 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Review & Analyze

Slide 113

Slide 113 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon CodeGuru Reviewer AWS Best Practices: Correct use of AWS APIs Resource Leaks: Correct resource handling Not sanitized user input (e.g., cross-site scripting, LDAP injection, OWASP Top 10) Sensitive Information Leak: Compliance Issues (e.g., logging of credit card number)

Slide 114

Slide 114 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon CodeGuru Profiler Memory profiling, hotspots and heap summary Finds methods with high-potential for performance optimization Supports AWS Lambda, AWS EC2, Amazon ECS, EKS, Fargate and on-premise.

Slide 115

Slide 115 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Build & Deploy

Slide 116

Slide 116 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Familiar Your language Just classes and methods Tool support Compatible with testing frameworks you’re already using Abstraction Sane defaults Reusable classes AWS Cloud Development Kit (AWS CDK)

Slide 117

Slide 117 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Abstraction via higher level constructs

Slide 118

Slide 118 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. SAM template transform Creates: • Lambda function • Runtime • Execution Policy • Code • Handler • API Gateway • API endpoint • Permissions Create DynamoDB table with sane defaults AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/function.jar Handler: com.unicorn.store.RequestHandler Runtime: java17 Policies: DynamoDBReadPolicy Events: GetToDo: Type: Api Properties: Path: /todo/{id} Method: GET Listable: Type: AWS::Serverless::Simple Table AWS Serverless Application Model (AWS SAM)

Slide 119

Slide 119 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS SAM CLI sam init Generates a AWS SAM template and example application code sam build Build the application package sam deploy Deploys your serverless application to the AWS Cloud sam local Test your application code locally sam logs Stream functions logs to your local machine

Slide 120

Slide 120 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Outlook & Recap

Slide 121

Slide 121 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Running Java in the cloud AWS Lambda Serverless AWS Fargate Container orchestration Amazon Elastic Kubernetes Service (EKS) Amazon Elastic Container Service (ECS) Red Hat OpenShift Service on AWS (ROSA) Opinionated deployment AWS App Runner AWS Elastic Beanstalk AWS Batch AWS IoT Greengrass AWS Amplify Amazon Lightsail

Slide 122

Slide 122 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Overview: Java on AWS Immersion Day https://catalog.workshops.aws/java-on-aws

Slide 123

Slide 123 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Connect with us! https://aws.amazon.com/contact -us/

Slide 124

Slide 124 text

EFFECTIVELY RUNNING JAVA APPLICATIONS ON AWS – DEEP DIVE © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you!