https://serverless-stack.com/ logo
#help
Title
# help
s

Scott Rouse

11/17/2021, 4:44 PM
I am reasonably familiar with AWS and got an SST stack working from examples, but I feel like I am missing something in terms of cost. My SST stack has an Aurora Postgres DB, a couple Lambdas, custom domain, and Cognito. It is all in line with the examples on the website and all are working as expected. However, when I look at AWS cost management I’m consistently burning at $.26/hr (~$187/month). I’ve tracked for a couple days now and this baseline cost doesn’t change relative to whether I have “sst start” running or not (..and I’m ignoring route 53 one time costs). It only stops when I remove the stack. NatGateway-Hours ($.14/hr) and Aurora:ServerLessUsage ($.12/hr) are the primary costs (and fluctuate higher). I know I can remove my dev stack and turn this off, but if I where to push this to production and have it run 24/7 I would be spending $187 a month without any traffic ($62/mn for a single developer working 40/wk). My impression was that you should be able to spin something like this up for relatively minimal cost $20-$50/month especially without any traffic. Is there an article or some resource to help me understand this? Thanks!
t

thdxr

11/17/2021, 4:46 PM
Yeah so this is a major issue with AWS serverless and relational databases
Let me try to lay it out
1. If you use RDS, you need to put that into a VPC 2. Now that it's in a VPC it means your lambdas need to also be in a VPC to talk to it. 3. Your lambdas likely need internet access which requires the use of a managed nat gateway 4. Managed NAT Gateway is stupid expensive and has been the #1 thing people have been complaining about to AWS. Here's how to fix it: You can stick with RDS if you'd like but make sure you're using Serverless v1. This allows you to enable the Data API - this is basically a REST api that accepts SQL. Since data api is an aws service, it is secured by IAM - which means no need for a VPC for your lambdas. Your lambdas don't need to be in your VPC and can just talk to your database over data api. I recently wrote a data-api connecter for Kysely which makes this a lot smoother in typescript: https://github.com/koskimas/kysely https://github.com/serverless-stack/kysely-data-api @Frank is working on a new getting started guide to flesh out the details of this setup
s

Scott Rouse

11/17/2021, 5:09 PM
awesome thank you! That was the fuller explanation I was looking for…I had a rough idea that it was the NAT, but this is much more to work with. Thanks.
t

thdxr

11/17/2021, 5:42 PM
np I went through the exact same rollercoaster that you did when first getting into serverless
j

Jay

11/18/2021, 12:04 AM
Yeah it’s pretty annoying that serverless is half a decade old and AWS doesn’t have a decent RDS option.
2 Views