DEV Community

Adam Gordon Bell
Adam Gordon Bell

Posted on

Full Backend Apps on AWS Lambda?

Is anyone hosting a full CRUD type app with routing and persisting as an AWS Lambda?

And if so, how is that going?

Since you can run a container as a lambda, and you get built in scaling up and down it seems like it might be a good fit.

Top comments (10)

Collapse
 
ben profile image
Ben Halpern

Are things at a good place in terms of vendor lock-in in this situation?

How might one approach this without having an app that is 100% locked in to AWS?

Not saying it would need to be in a state where it could run anywhere today, but I'd hate to get to a place where it was impossible to make a few changes and migrate vendors.

Not an answer to your question, but I'm wondering about the state of things in that regard.

Collapse
 
adamgordonbell profile image
Adam Gordon Bell • Edited

So, you can run a rails app, or a go app inside a container, and start it up on lambda.

The container means its a bit less locked in. And for low usage stuff, you only pay per request with lambda.

I think cold start-up might be the issue, and where you persist things and if you need many services that call each other then not sure how that would work.

Collapse
 
ben profile image
Ben Halpern

So assuming I'm comfortable with the specific tradeoffs of running in Lambda, there is a pretty low-risk situation here, eh?

What would you say are the best use cases — my mind goes towards... wildly variant traffic volumes — like a company that does flash sales with big spikes — or viral content sites where edge caching is not possible. Or I suppose anything where the flexibility of Lambda pays off once you're all set up?

Thread Thread
 
ben profile image
Ben Halpern
Thread Thread
 
adamgordonbell profile image
Adam Gordon Bell

Scaling up would definitely be one use case. I was thinking about the opposite, scaling down. So a REST API service that is just a side project, I can have it sitting as a lamdba, and then it's idle 99% of the time and so I just pay pennes whenever its called.

So, side projects basically 🤷

Thread Thread
 
ben profile image
Ben Halpern

How does that work in practice? Is the first request after a while painfully slow due to cold boot up?

Thread Thread
 
adamgordonbell profile image
Adam Gordon Bell

yeah, because your app is just starting up. So it depends on how fast your app is to startup, Java is bad at this. I'm using go, and its like 100 ms to start up in lambda i think.

I found this: mikhail.io/serverless/coldstarts/a...

But yeah, I'm just playing around. Here is my lambda app:
earthly.dev/blog/aws-lambda-golang/

I'm not sure about the real world downsides outside of toy app land.

Collapse
 
garretharp profile image
Garret

An entire backend on a single lambda would have high cold start times that I would recommend just using fargate if you would rather use containers.

Otherwise I suggest using API Gateway & a lambda per route.

If you want to take a step further into the AWS land I would highly suggest using appsync and VTL templates to have a fully serverless graphql API with 0 lambdas.

My work currently does API Gateway and Lambda approach, but if I could rewrite I would 100% use appsync and VTL templates.

Collapse
 
adamgordonbell profile image
Adam Gordon Bell

Hey Garret,
What types of start up times do you see and what language are you using?

How is fargate different or better than a Provisioned Concurrency lambda?

Collapse
 
adamgordonbell profile image
Adam Gordon Bell

I ended up writing up a blog post about how to do this in go:
earthly.dev/blog/aws-lambda-api-pr...