Java 11 vs 8 performance for AWS Lambda

What our Lambda will do?

Test flow
You can ask why we have this static stuff :)
  1. Use CPU burst on Lambda startup
  2. Get rid of IoC frameworks such as Spring/Guice/Dagger 1
  3. Reduce jar file and load as fewer classes as possible. (Jar size is 6Mb, quite small for Java)
  4. Use AWS SDK 2.0
  5. Explicitly set AWS Region and CredentialProvider for AWS clients

Deployment

The next step is deployment. I created two independent AWS Lambda functions with Java 11 and Java 8 runtimes and uploaded jars accordingly.

Test Scenario

I used JMeter to send POST requests (create new User)to AWS API Gateway. I sent 1 request in a big loop to check the performance of a single AWS Lambda instance.

  1. Max latency (per min)
  2. Average latency (per min)
  3. 90 Percentile latency (per min)

256 MB

256 MB Lambda

512MB

512 MB Lambda

Results warmed up Lambda

As expect we have a big latency for the first invocation and very small latency for the next invocations.

The average latency for 256 MB (warm-up)
The average latency for 512 MB (warm-up)

Results for cold start

We have a significant difference between Java 8 and 11 for the cold start.

Java 8 beats Java 11 during cold start. Latency difference is huge for 256 MB — more than 2 s

Cold start latency daily
Java 11 256MB X-RAY trace

Java 8

Java 8 256Mb X-Ray trace

Conclusion

New Doesn’t Mean Better :)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store