Yoaz Menda
Yoaz Menda

Reputation: 1706

AWS Serverless application load time with the Spring framework

I am building a web application in AWS using the serverless architecture.

The purpose of the application is to expose a public API to upload files from around the world.

I use AWS API-Gateway and Lambda to execute my code and S3 as storage.

I know that it is very much possible and well supported (even by 3rd parties like the Serverless framework) to use Java Spring framework to write the code that I deploy in my Lambda function.

However, is it really recommended? Spring applications usually take 30 seconds or more to load completely and Lambda should run Immediately.

How come this option is even supported by AWS (since it sounds like a very bad idea)?

Upvotes: 0

Views: 527

Answers (3)

Suken Shah
Suken Shah

Reputation: 1672

Personally, I would AVOID using java runtime for AWS lambda as much as possible. I understand that it's very tempting to use java assuming that you are looking into migrating an existing implementation into microservices. But you are always going to pay the penalty of slow warm-up time compared to other runtimes. You may also miss out on Java compiler optimisations as the lambda may not be invoked enough number of times to trigger C1 and C2 compilations.

My preference would be only to use java for lambda if you are planning to write a lean implementation, means no spring, hibernate etc. etc.

Upvotes: 1

Simon Martinelli
Simon Martinelli

Reputation: 36113

Using Java with AWS lambdas is perfectly fine but Lambdas are functions not applications!

So you should avoid to use a framework like Spring because you don't need that.

The question is what do you want to achieve in your function and why do you need a framework to execute such small amount of code? What's your use case?

Upvotes: 0

Shimon Tolts
Shimon Tolts

Reputation: 1692

Java is one of the supported programming languages of AWS Lambda. It is possible to run an application using Java, you just have to take the warmup time into consideration, if that fits your use-case - then use it. You could also use SNS and a hook to your lambda to keep it warm if you do not receive requests

Upvotes: 1

Related Questions