Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Sebastian Korfmann
Sebastian Korfmann

Posted on

     

AWS AppSync Direct Lambda vs DynamoDB Resolver

I've been experimenting with AWS AppSync and I'm intrigued by the idea of ditching VTL entirely in favour of Direct Lambda Resolvers. Ignoring the monetary cost aspect which Lambda adds, my biggest question was the performance impact this might have. So, I ended up doing some basic real world tests.

Setup

A direct lambda resolver for the fieldQuery.getNote and a VTL DynamoDB resolver forQuery.ddbGetNote. Both versions are performing aGetItem operation on the same DynamoDB table.

1st Attempt

The first try with a Lambda function mostly in AWS CDK default configuration (i.e. 128 MB Ram) was quite disappointing.

Alt Text

The (warm) Lambda resolver took ~ 200 ms compared to 14 ms of the VTL DynamoDB call. Interestingly enough, most time consuming in the Lambda function appears to be the DynamoDB call. This seems odd.

Back to the drawing board?

A bit of research suggested, that this is an issue for underpowered Lambda functions. I've found thisslide deck with a nice chart for balancing performance / costs for DynamoDB calls in Lambda functions.

Alt Text

The sweet spot seems to be around 512 MB memory for a Lambda function.

2nd Attempt

I changed the Lambda function to 512 MB and left everything else as it was. And surprise, surprise - This looks way better now.

Alt Text

Now the (warm) Lambda resolver takes ~ 30 ms compared to still 14 ms of the VTL DynamoDB call.

Conclusion

Skipping VTL in favour of direct Lambda resolvers seems to be reasonable for the gained flexibility, even though there are a few drawbacks. There's a bit of an overhead to call the Lambda function, which gets drastically worse on cold starts (+ ~ 600 ms).

In terms of costs, 1 million invocations at 100 ms with 512 MB would clock in at roughly 1 USD. That's on top of the 4 USD per million operations in AppSync. All in all, not exactly cheap in scale but nothing I'd be concerned about for now. That's something to optimize when costs would become an issue.

I'll continue to explore Direct Lambda Resolvers for all cases and report how it goes :)

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
lewiscowles1986 profile image
Lewis Cowles
  • Location
    Essex, UK
  • Joined

lambda cold starts are shockingly bad. Also the lambda runtime seems unable to work multiple request / responses at a given time, so your whole 128-512MB is taken up per-request.

1000 concurrent requests = 1000 lambdas * RAM
512 GB RAM to serve 1000 requests...

CollapseExpand
 
javiasilis profile image
Jose
TypeStacean 📝🦀. 8 years of web development.Seasoned TypeScript developer on a journey to learning Rust and WASMIt doesn't have to be that hard.
  • Location
    Madrid, Spain - Santo Domingo, Dominican Republic and Miami, United States
  • Education
    INTEC, Rochester Institute of Technology (RIT)
  • Work
    Inventor - Entrepreneur - Civil Engineer and Software Developer
  • Joined

Sebastian, thank you so much for this article. As I am requiring custom business logic, I am using most of my AppSync code through VTL + Lambda (Before the existence of Direct Resolvers).

I didn't know Direct Resolvers were introduced last year until fairly recently (Think it was back in May), and I wanted to see if the Lambda overhead was reduced. I think it still hasn't.

Anyways, it's a great thing that AWS has allowed us to do that, other possibilities that we have is to circumvent the 25 item limit from DynamoDB that is present in VTL templates.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Building a Product | AWS DevTools Hero | Formerly HashiCorp, Creator of CDK for Terraform
  • Location
    Hamburg, Germany
  • Joined

More fromSebastian Korfmann

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp