Hacker News new | ask | show | jobs
by vrodic 2872 days ago
Most of these articles I read about AWS Lambda (they rarely mention API Gatweway because it's expensive) sound like paid marketing.

I've seen just API Gateway costing more than entire infrastructure costs of similarly sized websites.

If you can properly saturate EC2 it will be significantly less expensive than Lambda but with lambda you have to pay API GW and the vendor lock-in price.

I've started flagging these submissions.

9 comments

That calculation doesn’t include the salary of the person managing those EC2 instances. Lambda is easier to manage and costs less time than an EC2 box. SSH keys, backups, AMI base images, system updates , it all adds up. Ansible and terraform are so far removed from the core competency of any company that you really need to ask yourself, for any second you spend working on them: is this worth it? At almost no company’s scale* is it so.

Salary is a hidden cost people often forget. Or time spent by your programmer’s debugging infra; time not spent creating value. Frustration from having to deal with TF or ansible in the first place.

These are all benefits of a serverless solution which cost aware criticisms should at least try to quantify and take into account.

Signed, not-a-shill.

* I’ll rephrase: a significant amount of companies don’t have the luxury of being so swamped by requests they can saturate EC2 boxes and make the devops overhead (which, I’m arguing, is big but relatively constant/“sub linear”) worth the price difference (which scales linearly). Significant enough for these articles to have a raison d’être.

In my experience, the developer time it takes to get a serverless application running (on AWS anyway) far exceeds the benefits that serverless brings. We spent over six months on a project written in serverless that we could never really get working properly. We dumped all that code and rewrote it on a standard LAMP stack in less than half that time. Factoring in that the problem was better understood the second time around, it would still have been cheaper to build it the way we are from the beginning.
Was that due more to lack of training? I am first and foremost a developer, but I’ve spent weeks understanding AWS from a netops, devops and development standpoint.

I’m also working on certifications mostly as a method to force me to learn in a structure manner, my company will pay for them, and they still have some market value.

Training also takes time.
Are you proposing that developers shouldn’t study and learn about whatever infrastructure they are using?
I'm not proposing anything. I'm saying that training should be factored in when considering development costs. The notion that training is always a one-time investment that can be pretty much ignored if you plan to stick with some tech long-term is a fallacy.
Isn't that the whole point of the cloud?

I mean, if you care about the infrastructure there are few reasons left not to self-host.

Salary of developers and sre that needs to manage this either way?

Lambda and api gateway is nothing but expensive vendor lock-in.

Excellent point. That's why we don't bother with server virtualization, Docker, or Ansible.
Docker, ansible, red hat stuff are all open source that you can run on your own. There is no vendor lockin.
My last job was running a lot of open source stuff and they spent maybe 20 hours per week troubleshooting things, multiple people together, while the rest of the team was waiting.

It was a complex environment with high availability though, with maybe 15 different types of software trying to work together...

After using AWS for a while, I have to say that things usually work and don't suddenly start to malfunction, even when not doing serverless.

Downsides of serverless is definently vendor lock in, but I think having the complexity of open source software in house, and being able to try new software, is a double edged sword that can cost huge money as well.

It's not a simple choice.

It's not just lockin. It's troubleshooting Lambda. Here's a couple of questions and answers we've recently delved into:

- How do I avoid a cold start? (Fake calls into the system to the point where AWS has to start more instances of your application)

- Why is my cold start time different between development to production? (Production is in a VPC, which has greater instance spin up times)

- Why has Lambda stopped executing on my Kinesis stream? (Oops, AWS' bad)

- How can we get more parallel Lambda processing on a Kinesis stream? (Clone the stream and attach to the cloned stream)

- What can I do to reduce the cold start costs for Java? (Specify your objects as static, since those are evaluated at JVM startup, which AWS doesn't charge you for)

- How do I do Infrastructure as code? (CloudFormation; expect an average of 4 CF objects per function. SAM makes the CF more user friendly, but it's harder to debug and encourages the creation of extra infrastructure)

- How do I increase the bandwidth allocated to my Lambda? (Increase the memory allocation)

But they significantly reduce the workload on the people that would otherwise have to manage those things, just like a serverless architecture does.

If you want to argue about vendor lockin, sure. But removing the necessity of managing scaling, individual instances, and OS / software patching is significant.

> But removing the necessity of managing scaling, individual instances, and OS / software patching is significant.

With AWS (and other cloud provider) APIs and tools like Packer, these difficulties are vastly overstated.

Building VM images is just another step in the CI/CD pipeline, and patching and deploying a zero day fix becomes "kick off the CI/CD pipeline". You can even do automated unit testing of an image with tools like Inspec.

Scaling is an API call to change a "desired instance count" value (if it's not already automated), and complex problems with any individual instance can be resolved with STONITH (terminating the instance).

Nothing is reduced just shifted away from your perspective. You pay for the server running your serverless code. You just share that cost.

Sharing the cost brings benefits but it also brings pain. First time you hit an AWS hard limit you will realize how much pain

So where exactly are we going to run this “on our own” in a regionally or globally distributed manner? Then we have to pay more people for netops to do things that doesn’t have any competitive advantage.
Lambda is often the way to go, but there are a couple tipping points where it becomes less appealing:

- When you start having to spend a lot of time working around its limitations. (As is the case with all managed services.)

- When the sum of its parts create a distributed system whose complexity costs you more in productivity than it gives back.

Performance limits will get better with time. The complexity cost is more difficult to predict. Hopefully it will improve as best-practices emerge and tooling gets better.

Debugging, organizing, and testing lambdas vs traditional stacks is the hidden costs on the developer side.
Testing a lambda is just as easy as testing a controller action in the typical MVC framework. You just pass a JSON payload to your lambda handler.

Organizing is also simple - if you know CloudFormation. You should learn that anyway to provision resources in a repeatable fashion.

Very few companies are big enough that they can make the devops overhead worth the price difference, but most of those plan on eventually being so. So there's an argument to be made that the knowledge should be grown in house while you can still tolerate the small outages you get when you have stuff misconfigured or unbalanced.

Probably not a good argument though. If you're successful enough to be saturating servers you're probably successful enough to be hiring experienced competent help for the transition.

I literally had this discussion at work today about vendor lock in. with AWS Lambda.

At my old job, we were terrible at wanting to use new shiny things (me included). We had terrible vendor lock-in with AWS, although it did make my resume look nice as I could fill it with fancy AWS products.

My supervisor was discussing AWS Lambda with me at lunchtime, and I said that it's not worth it, because any cost savings from using Lambda over a server are outweighed by the cost if we ever wanted or needed to switch vendors.

AWS lambda would make sense for large companies, where server time is more expensive than developer time. But for most companies, developer time is more expensive than server time, using shiny new AWS specific tools is just going to hurt later on.

I'm curious, when is server time ever worth more than developer time?

I mean, sure, if you're doing something as a hobby and consider your own time free but have to pay $5 for a VM somewhere, then maybe.

But especially at large companies, my experience has always been that for any work done the cost of infrastructure is basically a rounding error compared to the cost of developer time. And that doesn't even begin to include the cost of support team time for the eternity that everything seems to need to be maintained for in larger companies.

As a recent example, I know that the amount each developer on a team I've worked on costs (not how much they are paid, all contractors from various companies), per person, more than it would cost to buy a mid range server, colocate it in a data center etc - per day. So after a year, if we just bought infrastructure instead of developer time, we could have had a handy ~15,000 mid range servers racked and ready to go.

Also, API Gateway is incredibly slow. We often have lambdas that run for 20-30 ms, but API Gateway adds another 200 ms extra. We ended up running our own HTTP service in Beanstalk that forwards calls to Lambdas. It's stupid that we can create a better gateway than Amazon using their own services.
Sounds like you might have a config issue. I have Lambda's that take 20ms and API Gateway returns the entire response in ~40-50ms.
Lambda + API Gateway excel at spiky, unpredictable workloads. We have APIs that are spiky enough that EC2 autoscaling cannot spin up instances as quickly as the traffic spike comes in, which means with EC2 services we need to run with a lot of headroom to absorb these spikes. This includes running at night where usage is minimal, but still under threat of sudden spikes. That gets expensive. Our Lambda costs are a fraction for us because of this.

BTW, you can use other self-hosted API gateways like Kong with Lambda if you want to cost optimize.

A different take. Recently we had a AWS training at office, and the Amazon person was selling this as largely a infrastructure automation solution than a application hosting solution.

In essence his point was to use Lambda as a tool only to work with tasks related to AWS infrastructure automation. And not as a tool for everything.

The old adage, of not treating everything as a nail while holding a hammer seems to apply here.

>vendor lock-in

You can avoid that with the Serverless framework.

https://serverless.com/

I guess most of tech articles in general often pay more attention to technology details than to its cost-effectiveness (or even TCO) for certain classes of workloads.

If your workload is a 'traditional' web application, saturating a full VM and not too bursty - don't run it on Lambda.

Regarding vendor lock-in, I don't think Lambda is important for the vendor lock-in question. If you just need 'compute' capacity, it would be easy to move from Lambda to anything else. But if you also use bunch of other AWS services - then moving the Lambda functions is likely to be your least concern, frankly. On the other hand, if you do leverage various AWS services (other than just IaaS) - switching to Lambda (or other managed platform) could be useful to make your entire architecture (more) serverless.

> I've seen just API Gateway costing more than entire infrastructure costs of similarly sized websites.

Do you mean Api Gateway + the lambdas?

API Gateway is $3.50 per 1 million API calls received plus data transfer ($0.09 per GB or $90 per Terrabyte). What kind of API were they serving that was racking up those large bills?

Typically you would serve static content off s3 + cloudfront, and just the API off the API gateway/lambdas.

A mid sized web site with 5000RPM would be 219 million of requests per month: so 766 USD/month just for API GW, without data transfer, lambda, static/cdn or DB costs.
If you expect a steady load of hundreds of requests per second - maybe API Gateway + Lambda is not the best solution. The use-case in the article did not have such load targets. Lambda is not a silver bullet..
In this scenario, the savings come from time + resources spent on configuration management, system admin and troubleshooting, and server security.

Also if you have servers you are probably auto-scaling redundant instances in multiple availability zones and then getting that high CPU utilization is unlikely.

I guess this number goes down drastically if you throw in CloudFront.
Serverless doesn't necessarily mean Lambda. You can use Cloudflare Workers and pay $0.50/million requests flat.
Not advertised much, but you can cut down costs by 7x: Instead of API Gateway you can use Cloudflare Workers as "Gateway". It costs $0.50 instead of $3.70 per million requests. Not a drop-in replacement, but definitely an option.