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

Modernize APIs to run serverless using Apache CXF

Modernize APIs to run serverless using Apache CXF

Years ago the Service-oriented architecture (SOA) architectural style came along with implementations of web services based on standards like the Web Service Description Language (WSDL) and SOAP. Many of these interfaces are still in place as of today as a change requires both provider and all consumers to agree on a new definition and change the implementation (often without any business value). The underlying infrastructure, sometimes based on Enterprise Services Buses (ESB) is however often end-of-life and hard to maintain.

In this session you will learn how to modernize API infrastructure without changing the interface definition in the first place. Apache CXF allows to provide APIs using SOAP or RESTful HTTP protocol in a contract-first manner. The combination with cloud-based serverless function services like AWS Lambda enables you to reduce the management effort and lowering the cost by only paying for what you use.

Dennis Kieselhorst

June 03, 2024
Tweet

More Decks by Dennis Kieselhorst

Other Decks in Programming

Transcript

  1. © 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
  2. © 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
  3. © 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
  4. © 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
  5. © 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
  6. © 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
  7. © 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
  8. © 2024, Amazon Web Services, Inc. or its affiliates. All

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

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

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

    rights reserved. Lifecycle of a serverless function
  12. © 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
  13. © 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
  14. © 2024, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. How Lambda scales: A primer on Lambda concurrency Time 1 Initialization Execution
  15. © 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
  16. © 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
  17. © 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
  18. © 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
  19. © 2024, Amazon Web Services, Inc. or its affiliates. All

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

    rights reserved. Execution time Live-Demo
  21. © 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
  22. © 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
  23. © 2024, Amazon Web Services, Inc. or its affiliates. All

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

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

    rights reserved. Execution time Live-Demo
  26. © 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
  27. © 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!