The reality of running a production Node app on AWS Elastic Beanstalk

Lessons learned from 2 years of running a production Node app on AWS’ ELB platform

Jared Nutt
May 21, 2019 · 6 min read

Front-Matter

Let’s be honest, the AWS pricing calculator is confusing. Part of that is because of the a la carte method of payments AWS offers. This makes trying to give a good quote to a client difficult. Hopefully this article can provide some light on how much it costs to run an app, as well as some ways to reduce cost.

The Real Cost of Running an App

I’ve been managing a node web-app on ELB for about two years now. The first year was great, they gave you everything for free (mostly)! After that, you have to start paying for stuff, like EC2 instances.

Breakdown

This is what I’m currently running on AWS:

  • 1 t2.micro EC2 instance
  • S3 Bucket that holds images (7 GB at time of writing)
  • 1 Route 53 Hosted Zone

Load Balancer

This is the most expensive part of the stack. It costs:

  • $0.008 per GB of data processed by a Classic Load Balancer

EC2 Instance

On-Demand EC2 instances are more expensive than they should be. To save some money here, refer to the section below about Reserved EC2 Instances. In case you were wondering, it would cost $8.40 to run the same type of EC2 instance as mentioned above, on-demand.

S3

I have a couple S3 buckets. One for my static home page, one for holding images and one for holding the application version. As far as I know, ELB automatically creates the one for managing the application versions.

Database

I host my MongoDB DB at mLab, which is going away soon. So I’ll update this when I sort out how much that is actually gonna cost once I’m forced to move over to Mongo’s Atlas.

Reserved EC2 Instances

Let’s talk about Reserved Instances (RI). Amazon’s convoluted billing system is the most confusing part about managing anything on AWS. Reserved Instances can alleviate some of the cost, but are way too confusing.

No Upfront Reserved Instances (RIs) can pose a significant billing risk to new accounts, as they’re a contractual obligation to pay monthly for the entire term of the RI. For this reason, new accounts and lightly used accounts are unable to sign up for No Upfront RIs until a successful billing history is built with us.

You may run into this error if you try and buy a no up-front.

Pain Points

These are just some minor complaints about the overall EBS, which I figured I’d include as an addendum to my original article, in case you’re curious.

Automatic updates aren’t really that automatic

Node versions don’t line up from version to version.

Running more than one environment

Having a development environment and a production running at the same time is easy, but it’s expensive. It doubles it, in fact. Therefore, I usually destroy the dev environment as soon as I’m done with it.

Documentation is horrendous

AWS is too big for its own good. That is part of why I’m writing this. It was really hard to find answers to my specific needs.

How I manage Updates

I have two separate instances of my Git repo installed on my laptop. I have one for dev, and one for production.

Updates not requiring a Linux Environment change

For updates not requiring any changes to the linux environment, it’s as simple as running eb deploy in the terminal. It’s amazing and takes about 10 minutes to propagate.

Updates requiring a Linux Environment change

Occasionally, you will want to update the Linux environment but will be unable too because AWS is freaking dumb (I’m sure there’s a reason) and only allows certain versions of Node on each Linux build. For this, it’s a bit more complicated, but manageable.

  1. Make sure all your updates work. Seems pretty obvious, but this is a good time to make sure there weren’t any hiccups with the new build.
  2. Make sure your env vars are setup correctly. This is sorta part of the previous version, but make sure you’re pulling from the right DB, or whatever.
  3. Make sure your load balancer has the same SSL cert (if applicable). Fun fact, if you try to access an ELB instance in https without a certificate, it will fail!
  4. Swap the instances. Finally, after everything looks good to go, there’s a button in the console to swap the instance urls. EASY PEASY. You don’t have to change anything in the Route 53, it does it all for you.

Final Thoughts

If you have any suggestions to make it cheaper/easier, I would love to hear them. I like the discussion about tools and options just as much as the next developer!

Javarevisited

An humble place to learn Java and Programming better.

Jared Nutt

Written by

Freelance web developer living in Los Angeles. I write articles I wish I had when I was learning — mostly about Javascript and web development.

Javarevisited

An humble place to learn Java and Programming better.

More From Medium

More from Javarevisited

More from Javarevisited

More from Javarevisited

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade