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

Fight cold startup times for Kotlin lambdas with GraalVM

Fight cold startup times for Kotlin lambdas with GraalVM

In a live-coding session we'll see how a Custom Runtime can be implemented in Kotlin and how we can run our application as a native image that we create with the help of GraalVM.

by Mathias Düsterhöft
presented on May 2, 2019 @car2go

More Decks by Kotlin User Group Hamburg

Other Decks in Programming

Transcript

  1. FIGHTING COLD STARTUP ISSUES
    FOR YOUR KOTLIN LAMBDA WITH
    GRAALVM

    View full-size slide

  2. COLD STARTUP

    View full-size slide

  3. WHAT IS COLD STARTUP

    View full-size slide

  4. COLD STARTUP AND THE JVM
    What is happening during JVM startup?
    JIT compilation
    garbage collection
    class loading
    static initialization
    ...

    View full-size slide

  5. COLD STARTUP AND THE JVM
    Yan Cui - aws lambda – compare coldstart time...

    View full-size slide

  6. AWS re:Invent 2018: [REPEAT 1] Inside AWS: Technology Choices for Modern Applications (SRV305-R1)

    View full-size slide

  7. GRAALVM
     For existing Java applications,
    GraalVM can provide benefits by
    running them faster, ... creating ahead-
    of-time compiled native images.
    - https://www.graalvm.org/docs/why-graal/

    View full-size slide

  8. GRAALVM - NATIVE IMAGES
    GraalVM can create native images for existing JVM-
    based applications
    native image generation employs static analysis to
    find any code reachable from the main Java method
    the reachable code is then compiled AOT into
    machine code
    the resulting executable is self-contained (contains
    VM components)

    View full-size slide

  9. GRAALVM
    Codrut Stancu - Instant Netty Startup using GraalVM Native Image Generation

    View full-size slide

  10. CUSTOM AWS LAMBDA
    RUNTIMES

    View full-size slide

  11. CUSTOM AWS LAMBDA RUNTIMES
    open up AWS Lambda for any programming
    language
    a runtime is a program that runs the Lambda
    handler
    can be included in the deployment package

    View full-size slide

  12. CUSTOM AWS LAMBDA RUNTIMES

    View full-size slide

  13. SHOW ME THE NUMBERS
    Observed cold startup times

    View full-size slide

  14. CONCLUSION
    GraalVM native images greatly reduce startup time
    native image also seem to improve runtime
    performance
    creating native images for an application is
    cumbersome
    native image generation is slow

    View full-size slide




  15. https://gitpitch.com/mduesterhoe /kotlin-
    graalvm-custom-aws-lambda-runtime-talk
    mduesterhoe /kotlin-graalvm-custom-aws-
    lambda-runtime-talk
    Blog: Fighting cold startup issues for your Kotlin
    Lambda with GraalVM

    View full-size slide