Live data from Hacker News

Serverless: slower and more expensive

einaregilsson.com

271–280 of 733 posts

Re: Serverless: slower and more expensive

#271
post #208

Earlier quoted context omitted.

Logged in to say that this has actually been done (not by me) and my team has been finding it very helpful for local “serverless” SDLC: https://github.com/lambci/docker-lambda . It‘s billed as “ A sandboxed local environment that replicates the live AWS Lambda environment almost identically – including installed software and libraries, file structure and permissions, environment variables, context objects and behavio…

Nice! I saw that the SAM CLI uses an Alpine based image, does yours use Amazon Linux 2? I'm jusz asking, because I compiled some libs on Cloud9 (which uses AL) and they worked on Lambda, so I assumed it's the same dist.

I’m not 100% sure as I didn’t create the image (though I’m evangelizing as someone who has found it truly helpful for daily dev.) . I believe the creators tarball’d the entire distro/execution environment from a running lambda so the file system layout and libs likely match Amazon Linux if that’s the default lambda execution distro image. If not I assume it matches the default

Re: Serverless: slower and more expensive

#272
Serverless doesn't make sense for every workload, and it may not be a good fit here, but there's a few issues with this article and the setups discussed on both the serverless and regular setups.

I'll start with the initial setup: We can see m1 and t1 instances in there, as well as an m3. These first two are almost certainly running paravirtualized AMIs, and there is a chance the m3 is as well. PV AMIs are going to run slower in most cases to begin with (see: http://www.brendangregg.com/blog/2017-11-29/aws-ec2-virtuali... ) and are running on old instance types that have poor cost/performance ratios compared to modern ones - m1 and t1 are ancient. So, they could likely get even better performance by switching to modern instance types, getting away from old PV style virtualization on Xen, to the more modern Nitro stuff - t3 should be able to replace all of those instances, and you gain access to SR-IOV based drivers for disk and network. Even just switching to HVM instances and going to previous generation t2 would likely be a big win vs. t1.micro and m1.small.

And this brings me to my first point in favor of serverless: With Lambda, you don't have to worry about this. You don't have to keep up on which EC2 instance has the best price/performance ratio, you don't need to bother with migrating AMIs from Xen PV to Xen HVM (or PVHVM) or KVM compatible with NVMe and ENA drivers and all of that. You just manage your code. There's a mountain of other things to worry about when managing your own EC2 instances as well, even beyond this - just general patching, keeping up to date with new kernel versions, worrying about deprecation/EOL of the OS running in your instance, making sure your code works with new versions of glibc and all the other packages when you move to a new major release, etc. You might be able to skate by for a while ignoring all of this, but eventually, it's likely to cause problems. I know what I charge people to help manage all of that sort of stuff, and it's way more than the cost difference between the two setups.

Second: There's no indication if the latency calculation includes cold-start response times. They would likely be enough to drag the average up quite a bit for lambda, and there's lots of documented ways to eliminate them from a production lambda setup. (Though, they'd also likely see a latency decrease moving to t3 for their EC2 based setup as well, as previously mentioned.)

Third: API Gateway might not be the best tool for the job, especially as the author notes they don't make much use of all of the API gateway features. You can just use an ALB instead (or depending on your use case, potentially skip any sort of front end altogether, though it sounds like ALB is probably a better fit for what they're doing) and save on complexity and cost.

All in all, this comparison isn't really showing a setup that is well optimized on either the EC2/Beanstalk or Serverless sides - there's major wins on both the performance and cost sides for both implementations. Without both being optimally setup, it's really hard to draw a good conclusion on which is a better solution from a technical standpoint, and the discussion also completely ignores the cost in managing EC2, even with Beanstalk vs. a serverless setup.

Re: Serverless: slower and more expensive

#273
Treat serverless like another thing in your toolbelt. With Zappa, Julia, Jets, or any other platform that lets you use classical web server code to host a Lambda with API Gateway, you're getting the flexibility to inexpensively deploy new services and evaluate their utility ahead of having to go through the full exercise of productionalizing a service, purchasing reserved instances, or any of the other heavyweight stuff you may normally associate with rolling out a service.

I'd also like to point out that Lambda is a serverless option. Fargate is another. I've worked with infrastructures that use ECS + Fargate in cases where a real long-running server is a better spend than millions of lambda invocations. In other words, there's definitely a right-tool-for-the-job consideration to be had here.

Working with new tech is always a learning experience, and it's nice to see concrete numbers about what was learned.

Re: Serverless: slower and more expensive

#274
post #201
post #49

Earlier quoted context omitted.

>The whole idea of serverless is so you don't have to manage infrastructure Is this even achievable with Lambda though? Even with Lambda, you still have to configure your "infrastructure", just that instead of ELB and EC2, you now have to manage APIGW and Lambda, and any other "wiring" that you need to put in to do what you needed. All in all, I can't really say Lambda is really all that "easy" considering options li…

> you now have to manage APIGW and Lambda, and any other "wiring" that you need to put in to do what you needed. You know those url.py files in a django install? Those are the equivalent of ELB/APIGW thing. You don't manage those, you make them once. Not sure where you personally draw the line between app development and infra work, but for me "request that comes on this path, calls this function", either via ELB ->…

For the record, you can easily abstract that away or include it in your own code with frameworks like Chalice [0]

[0] https://github.com/aws/chalice

Re: Serverless: slower and more expensive

#275
post #265

Building out MVPs for very ambitious clients, I'm so glad to be working with Serverless to manage my lambdas. I'm able to test locally and deploy in seconds, it's the most efficient dev setup I've ever had.

I think the issues with serverless are when you grow well beyond the MVP stage and are pushing a production load. I’d recommend doing that cost analysis for your clients.

Re: Serverless: slower and more expensive

#276

Earlier quoted context omitted.

Do you have any resources on testing a Lambda? When I was fooling around with it, the only thing I ran into was that AWS Sam-client or whatever. Thing looked like an absolute nightmare to get up and running.

seriously, its a function. if you remove the aws/lambda specifics you _should_ have something testable that you then call from your lambda handler.

This! To me the only upside to the whole architecture (from a devs perspective) is that you can deploy these things to production independently of other parts of the system. If you can't do that with confidence because you're attempting to test it's functionality in some larger deployed context you've turned your monolith into a distributed monolith and now you have the worst of both worlds.

The good news; you should be able to accomplish most testing locally, in memory. The bad news; your test code is probably going to be much larger and your going to have to be very aware of the data model representing the interface to the lambda and you're going to have to test the different possible states of that data.

Re: Serverless: slower and more expensive

#277

Earlier quoted context omitted.

You’re always locked into your infrastructure. People don’t willy nilly change their infrastructure once they reach a certain size any more than companies get rid of their six figure Oracle infrastructure just because a bushy tailed developer used the “repository pattern” and avoided using Oracle specific syntax. And the “lock-in” in lambda is over exaggerated. If you’re using lambda to respond to AWS events, you’re…

Do you have any resources on testing a Lambda? When I was fooling around with it, the only thing I ran into was that AWS Sam-client or whatever. Thing looked like an absolute nightmare to get up and running.

You’re doing it wrong (tm). You setup and test lambda just like you test your controller action in an API.

Your handler should just accept the JSON value and the lambda context and then convert the JSON to whatever plain old object your code needs to do to process it and call your domain logic.

AWS has samples of what the JSON looks like for the different types of events. You can see the samples by just creating a new lambda in the console, click on test and then see the different types of events.

You can also log the JSON you receive and use that to setup your test harness. I don’t mean an official AAA type of unit test, it can be as simple as having a console app that calls your lambda function and passes in the JSON.

For instance in Python, you can wrapped your test harness in an

  if __name__ == "__main__":
block in the same file as your lambda.

This is the same method that a lot of people use to test API controllers without using something like Postman.

Re: Serverless: slower and more expensive

#279
post #164

Earlier quoted context omitted.

This is all strawman. There are valid reasons for serverless, most people choose it for reasons other than hype, and the savings and security of not self managing servers is tangible. All technology can be misused or poorly utilized, and even the best can have pathological edge cases. For the 80% or more, serverless works just fine.

Wow everyone all excited about hosted FreeBSD jails Some of us had deploy pipelines into “containers” working like a Lambda in 2003. Nothing in software is all that novel these days, IMO. All these features that have been there for a decade plus are just wrapped in a corporate brand now. Progress.

> Nothing in software is all that novel these days, IMO.

There is surely truth in this. But also, almost nothing is novel if you watch at the new stuff with the same mindset of the past.

It is wise to realize that most new stuff was already invented, but it is also wise to understand that the surrounding might have changed more than you realize.

(Talking out of my own ass here, just in philosophical terms)

Re: Serverless: slower and more expensive

#280
post #33

"Serverless", or "App Engine" as it was called for the few years prior the hype, actually delivers pretty good results for a range of parameters. It might even be a wider range of parameters than the ones where the results are subpar... Or not, I'm not sure how to weight the "I have a predictable base load large enough for its cost to dominate the other factors" vs the other cases. But as always - popularity of a too…

App Engine is a PaaS, not serverless/FaaS
Post reply on HN