Is API Gateway Right For You?

Image Source: Denys Nevozhai on Unsplash

The following is an excerpt from our guide to going serverless: There’s More To Serverless Than AWS Lambda

You’ve put in the research and decided that AWS Lambda is the right choice to power your website or app. You’ve chosen wisely as Lambda offers a number of benefits that make it an attractive option for many businesses. Before you can deploy though, there are a couple more decisions that you’ll need to make: how you’ll connect your front end to your back end and where you’ll store all of your data. Since Lambda functions are all stateless, your code can access stateful data via other web services — Amazon S3 and DynamoDB among others. Those stateless functions enable Lambda to rapidly scale as needed by launching copies of the function that match the rate of incoming events.

So, how do you get started?

Step 1: Connect Your Front End To Your Back End

If your needs include any of the following:

  • Authorization and authentication for your API
  • Request validation before the integration request
  • Rate throttling for better throughput
  • SDK (software development kit) generation
  • Running multiple API versions simultaneously
  • Flexible security controls with Lambda authorizer
  • Restful API endpoints to that respond in the expected language target
  • Real-time two-way communication applications with WebSocket APIs

Then API Gateway is for you.

API Gateway is built for creating, publishing, monitoring, maintaining and securing REST APIs and web services at any scale. It’s the catalyst for routing calls from clients to their appropriate microservices and allows any two applications to communicate without interruption.

Compelling customer service, communicating with partners and suppliers, and connecting internal applications are all among APIGateway’s top features and benefits. Its core mission is to facilitate API requests, thus helping enterprises increase their revenue, improve developer productivity, and reduce the risk of downtime or slow performance.

Where API Gateway particularly comes in handy is by allowing users to maintain a single API domain with multiple end-point versions, instead of supporting a cluster of interface systems.

The API Gateway Alternative: Application Load Balancer

If you don’t need all the features that API Gateway offers, a viable substitute to connect your front end user experience to your backend business logic is AWS Lambda via application Load Balancer (ALB) routing. ALB is not only a viable alternative; it’s a much less expensive one as well. Something to keep in mind is that you’re not locked into one choice. Starting out, if you find that ALB is a better fit for you, you can always start out using that and switch to API Gateway as your business needs scale over time. Just because you don’t have the above needs today, doesn’t mean that will always be the case. In fact, you’re almost certain to need additional functionality as you grow.

API Gateway Pricing

Once you’ve decided API Gateway is for you, you’ll pay $3.50 per one million API requests for the first 333 million requests each month. Confused? Don’t worry, you’re not alone. Pay-as-you-go pricing structures are often very complex and misleading. It’s easy to look at that pricing equation and think that $3.50 is cheap. However, if you have an API that averages 450 requests per second, that’s pushing 39 million requests every day. In turn, that comes out to $136 per day, or over $4,000 a month, for API Gateway — a fairly daunting amount if you’re not expecting it.

This type of pricing led AWS to announce at the 2018 “re:Invent” conference that ALB would also support routing requests to Lambda functions. Notably, ALBs are priced out by the hour and usually cost $15-$20 per month on an hourly rate, depending on the specifications, stream, and nature of the requests.

Diving deeper into the cost of ALB, we can look at Load Balancer Cost Units (LCUs). These complex set of structures take into account the number of new and active connections each second, as well as the bytes processed by the ALB, and the number of routing rules it needs to evaluate. You’ll need to figure out what your application workload is before determining which is right for you but generally, if you just need Lambda routing ALB is about eight times less than API Gateway.

Choosing between API Gateway and ALB ultimately comes down to what specific needs your company has and how much you’re willing to pay to address those needs. A more robust solution only works when the log of requests calls for it. In other words, don’t bring a power drill to your application if all you need is a small screwdriver. Evaluate your choices and make the right one for you.

To continue reading about how to navigate the world of serverless, check out our guide There’s More To Serverless Than AWS Lambda.

Original post can be found here.

Authored by Chris McLeod:

Chris is a Senior Solution Consultant in our Minneapolis office. Chris has extensive e-commerce experience working the client side as well as leading globally distributed software development teams. He has a passion for making jobs easier, cloud adoption, software architecture, and information protection. It’s his belief that an hour invested in practicing DevOps pays off in multiple hours saved elsewhere. A self-confessed technology geek, beer lover, hockey player, and golf nut, his perspective is rarely boring.

Trusted guidance, global expertise, secure integration. We design and develop custom software solutions that deliver digital transformation at scale.