Slide 1

Slide 1 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Modernize APIs to run serverless using Apache CXF Dennis Kieselhorst Principal Solutions Architect Amazon Web Services

Slide 2

Slide 2 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Intro - APIs, Apache CXF, Serverless • A Modernization scenario for this session • Contract/ API-First vs. Code First approach • Demo with Java runtime • Lifecycle of a serverless function • Optimize with AWS Lambda SnapStart incl. demo • Optimize with GraalVM native image incl. demo • Summary Agenda

Slide 3

Slide 3 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Simplify programming by abstracting the underlying implementation and only exposing objects or actions needed. • APIs are the „glue“ between applications. Application Programming Interfaces (APIs) Client(s) API Web Server Database Request Response

Slide 4

Slide 4 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Apache CXF is an open source services framework. • CXF helps you build and develop services in Java using frontend programming APIs, like JAX-WS and JAX-RS. • These services can speak a variety of protocols such as SOAP or RESTful HTTP and work over a variety of transports such as HTTP or JMS. • CXF supports API specifications like WSDL and the OpenAPI Specification (formerly known as Swagger). Apache CXF

Slide 5

Slide 5 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is Serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure

Slide 6

Slide 6 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Clients API Backend services • Mature API in place, no changes happened for a long time • Outdated infrastructure causes relability and security challenges • >20 consumers (internal and external), unable/ not willing to change their implementation • Interface definition (WSDL) is part of signed business contracts A Modernization scenario for this session SOAP request SOAP response

Slide 7

Slide 7 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Contract/ API-First vs. Code First approach Contract/ API-First • Specification is defined first and acts as service contract • helpful for different teams on client-/ server side • even more across different companies/ with third parties • Client- and servercode can be generated with a code generator • ensures code is always consistent to the API • compile errors for breaking changing (possible to automate using Continious Integration tool) • code is not as clean as handwritten code, may look confusing • tolerant reader pattern may be a better option over spec-based code generation (depends on the scope and change frequency of the API) Code First • Specification is derived from API implementation • code can be annotated • export is either done at compile or runtime • developers are familiar with it à fast for simple APIs • Generated specification may contain unused resources • easily happens that something is accidently exposed • often lack of documentation

Slide 8

Slide 8 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo with Java runtime 9

Slide 9

Slide 9 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Build time Live-Demo

Slide 10

Slide 10 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execution time Live-Demo

Slide 11

Slide 11 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lifecycle of a serverless function

Slide 12

Slide 12 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. The lifecycle of an AWS Lambda function Time Load and initialize handler JVM start Run handler code Compile Package Deploy Download code Build and deploy Initialize Handler invocation

Slide 13

Slide 13 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Time The lifecycle of an AWS Lambda function Load and initialize handler JVM start Run handler code Compile Package Deploy Cold start Download code Warm start Build and deploy Handler invocation Initialize

Slide 14

Slide 14 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. How Lambda scales: A primer on Lambda concurrency Time 1 Initialization Execution

Slide 15

Slide 15 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. How Lambda scales: A primer on Lambda concurrency Time 1 Initialization Execution Execution Environment is blocked / busy for this entire time

Slide 16

Slide 16 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. How Lambda scales: A primer on Lambda concurrency Time 1 Initialization Execution 2 Initialization Execution

Slide 17

Slide 17 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. How Lambda scales: A primer on Lambda concurrency Time 1 Initialization Execution 2 Initialization Execution 3 Execution 4 Execution

Slide 18

Slide 18 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • 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 • Supports beforeCheckpoint/ afterRestore API created by the Coordinated Restore at Checkpoint (CRaC) project U P T O 1 0 X F A S T E R S T A R T - U P P E R F O R M A N C E Optimize with AWS Lambda SnapStart microVM snapshot technology

Slide 19

Slide 19 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo with AWS Lambda SnapStart

Slide 20

Slide 20 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execution time Live-Demo

Slide 21

Slide 21 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Time The lifecycle of an AWS Lambda function Load and initialize handler JVM start Run handler code Compile Package Deploy Cold start Download code Warm start Build and deploy Handler invocation Initialize

Slide 22

Slide 22 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • GraalVM is a high-performance runtime that is designed to address the limitations of traditional VMs such as initialization overhead and memory consumption. • Beyond using GraalVM as just another JVM you can also create a native executable via the native image capability. This executable already includes all necessary dependencies (e.g. Garbage collector) and therefore does not a require a JVM to run your code. • Major frameworks like Quarkus, Micronaut and Spring Boot Native allow to leverage GraalVM conveniently. • Library changes may be required to make them compatible. A Quarkus extension for CXF (in the Quarkiverse project) already exists to address that. Optimize with GraalVM

Slide 23

Slide 23 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo with GraalVM native image

Slide 24

Slide 24 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Build time Live-Demo

Slide 25

Slide 25 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Execution time Live-Demo

Slide 26

Slide 26 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Summary 27

Slide 27

Slide 27 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. • Apache CXF enables you to provide stable, mature APIs even with a long lifecycle (>10 years). • Modernizing API infrastructure to serverless allows to lower your costs and adapt at scale while eliminating infrastructure management tasks. • Use a mechanism to reduce cold-start times and optimize performance: § AWS Lambda SnapStart offers a managed service functionality (using Firecracker microVM snapshots). § GraalVM native images requires more effort but also significantly reduces memory consumption. Summary

Slide 28

Slide 28 text

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you! Dennis Kieselhorst [email protected] Please complete the survey at the back of your badge!