javaperformanceaws-lambdacold-start

Does support for JDK 11 in AWS Lambdas introduce any performance improvements? Especially regarding cold starts?


It seems, for AWS Lambdas, that Java is noticeably slower than other supported languages when it comes to cold starts. Does JDK 11 have any performance enhancements, compared to JDK 8, that may improve the cold start time?


Solution

  • Theoretically it should via application class-data sharing, it should reduce the startup time by a few seconds. Class-data sharing is enabled by the "--Xshare:on" when booting the JVM.

    aws enable "--Xshare:on" by default for the J11 runtime, the only reason for enabling this flag would be for the case where they have generated an archive using the list of classes that comes with JDK.

    Aplication Class Data Sharing for application classes was introduced first for J9 and was a commercial feature that only became available in OpenJDK 10.

    If you wanted to test the effect of this for your lambda functions with OpenJdk 11 then you would run

    java -Xshare:dump
    

    then in your $JAVA_HOME/lib/server you should see the jdk archive classes.jsa as shown below

    enter image description here

    then you would run your tests with the flag

    java -Xshare:on ....
    

    and the jvm will load the jdk class from this archive
    to run local lambda tests this collection of docker container is a good option
    https://github.com/lambci/docker-lambda