Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Serverless Java Challenges & Triumphs

866 vues

Publié le

Will Java ever become relevant in the Serverless space?
Presented at the Singapore JUG (March 2019)

Publié dans : Logiciels
  • Soyez le premier à commenter

Serverless Java Challenges & Triumphs

  1. 1. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Serverless Java Challenges and Triumphs 1 Singapore JUG March 25, 2019 David Delabassee - @delabassee Oracle
  2. 2. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 2 Preamble…
  3. 3. Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
  4. 4. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Belgium
  5. 5. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 5
  6. 6. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 6
  7. 7. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 7
  8. 8. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 8 Serverless
  9. 9. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Function As a Service • Function • As a Service 9 Small bits of code with a well defined job Easy to understand and maintain The system takes care of provisioning, patching, scaling, ... Each function can scale independently
  10. 10. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 10 Interest in Serverless Source: Google Trends
  11. 11. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 11 Serverless Java?
  12. 12. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 12 https://blog.github.com/2018-11-15-state-of-the-octoverse-top-programming-languages/ Top programming languages by contributors as of September 30, 2018
  13. 13. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 13 https://redmonk.com/rstephens/2019/03/20/redmonk-top-20-languages-over-time-january-2019/ RedMonk Top 20 Languages Over Time: Sept 2012 - Jan 2019
  14. 14. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 14 4.96% of functions are Java 8!? https://serverless.com/blog/serverless-by-the-numbers-2018-data-report/
  15. 15. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 15 And the Trend isn’t Great! https://serverless.com/blog/serverless-by-the-numbers-2018-data-report/
  16. 16. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Serverless Java Landscape • AWS Lambda - Java 8 support (June 2015) • Azure Function - Java 8 support (February 2019) • Google Cloud Function - NA 16
  17. 17. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 17 http://redmonk.com/jgovernor/2016/10/12/when-web-companies-grow-up-they-turn-into-java-shops
  18. 18. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Serverless Java • FaaS seen as a scripting platform for the web? • Doesn't fit normal Java development patterns? • JVM not suitable for short-lived “apps”? 18
  19. 19. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Blueprints for Serverless Java • “Plain old Java” • Established toolchains • Ability to build complex applications • Low latency/high performance • Rich JVM ecosystem 19
  20. 20. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. • Open-source, Container NaAve, Serverless PlaDorm • Apache v2 licence • Run anywhere - Cloud / Datacenter / Laptop • Fn ♥ • FuncAons are containers 20 https://github.com/fnproject/fn
  21. 21. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 21 Demo
  22. 22. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Fn Java Function Development Kit • Docker images –A build image for repeatable builds –An optimized runtime image • JUnit test harness • Maven support • Input/output coercion • Flow • … 22
  23. 23. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Blueprints for Serverless Java • “Plain old Java” ✓ • Established toolchains ✓ • Ability to build complex applications • Low latency/high performance • Rich JVM ecosystem 23
  24. 24. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 24 Fn Flow
  25. 25. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Serverless 25 Permanent Storage Lives Elsewhere ts 10 5 5 5 5 8 7 7 8 10
  26. 26. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Fn Flow • Build reliable and scalable Faas applica(ons • Provides rich concurrency primi(ves including fork-join, chaining, delays and error handling • Java support based on Java 8 Comple(onStage API For long-running, reliable, scalable functions
  27. 27. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Fn Flow For long-running, reliable, scalable functions Flow flow = Flows.currentFlow(); FlowFuture<byte[]> stage = flow.invokeFunction(aFunc, input.getBytes()) .thenApply(HttpResponse::getBodyAsBytes); byte[] result = stage.get();
  28. 28. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Fn Flow 28 Demo Java FDK Flow
  29. 29. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Blueprints for Serverless Java • “Plain old Java” ✓ • Established toolchains ✓ • Ability to build complex applications ✓ • Low latency/high performance • Rich JVM ecosystem 29
  30. 30. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Low latency/high performance • Respect resource constraints • Start fast • Run in small(er) images 30 What do we want containerized JVMs to do?
  31. 31. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Respecting Resource Constraints • JDK-8179498:attach in Linux should be relative to /proc/pid/root and namespace aware as jcmd, jsack, etc. fail to attach (resolved in JDK 10) • JDK-8193710: jcmd –l and jps commands do not list Java processes running in Docker containers (resolved in JDK 11) • And more... JDK-8203357: Container Metrics (resolved in JDK 11.0.1) • JDK 11—JEP 318: Epsilon, i.e. No-Op, Garbage Collector (experimental) 31 Being Container Friendly
  32. 32. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Start Fast 32 Moving Startup Costs to Build-Time • Class Data Sharing –Avoid parsing JDK classes on start • Application CDS –Avoid parsing App classes on start • AOT compilation –Compile App classes to native .so libraries (experimental)
  33. 33. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Start Fast 33 Small(er) Container Images = Faster Start-up
  34. 34. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Run Small(er) Images 34 Reduce layers size • Java Function and its dependencies • Java Runtime • Operating System
  35. 35. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Run Small(er) Images 35 Reduce layers size • Project Portola – Run the JVM on musl – https://openjdk.java.net/projects/portola/ • musl – Lightweight, fast, simple, free, C standard library implementation – http://www.musl-libc.org • Alpine – Security-oriented, lightweight Linux distro with 4MB base image – https://www.alpinelinux.org
  36. 36. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Run Small(er) Images 36 Reduce Java Runtime layer size - jlink Modules JLink flags Mb JDK 12 Whole JDK! 318.7 openjdk:11-jre-slim 11 (default) NB: openjdk:12-jre-slim not yet available! 217.0 JRE 12 all (explicit) --add-module $(java --list-modules) 168.3 100.0% + --no-header-files --no-man-pages --strip-debug 143.0 85.0% + --compress=1 107.8 64.1% + --compress=2 83.7 49.7% Custom JRE 12 base, logging --add-module $(jdeps --print-module-deps func.jar) 47.4 28.2% 100.0% + --no-header-files --no-man-pages --strip-debug 41.6 24.7% 87.8% + --compress=2 32.0 19.0% 67.5% OpenJDK (build 12-ea+29) - alpine:3.9 x86_64 318 Mb 168 Mb 47 Mb 32 Mb
  37. 37. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 37 jlink/Alpine Demo
  38. 38. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Run Small(er) Images • GraalVM compiles Java source to a single native binary • Tiny image sizes • Low VM overhead 38 GraalVM
  39. 39. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 39 GraalVM Demo
  40. 40. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Blueprints for Serverless Java • “Plain old Java” ✓ • Established toolchains ✓ • Ability to build complex applications ✓ • Low latency/high performance ✓ • Rich JVM ecosystem 40
  41. 41. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Ongoing Ecosystem Evolution… • Substrate VM • Java release cadence • Other JVM based languages – Kotlin, Groovy, etc. • … • Fn init-image 41
  42. 42. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Blueprints for Serverless Java • “Plain old Java” ✓ • Wide choice of good tooling ✓ • Ability to build complex applications ✓ • Low latency/high performance ✓ • Rich JVM ecosystem ✓ 42
  43. 43. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 43 Serverless Java—Does it have a future? Absolutely!
  44. 44. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 44 Call to Action https://github.com/fnproject/fn
  45. 45. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Coming Soon: Oracle Functions Function Dev KitsOpen Source Engine Oracle Cloud Triggers Events HTTP Timer Streams Container Native Advanced DiagnosticsFine-grained Billing
  46. 46. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. 46 Thanks!

×