News for hackers. Stuff that matters.
Re:Serverless: slower and more expensive by dullgiulio on Monday September 23, 2019 @07:12AM (#21047739)
Just to be clear: lambdas are not stateless if you, for example, connect to a DB or use any other external service.

State could be somewhere else, but if you are not also "pure", you don't have any improvement over a normal service.

Re:Serverless: slower and more expensive by bmm6o on Monday September 23, 2019 @12:19PM (#21050351)
That's not what I've understood "stateless" to mean. Sure, anything more complicated than a calculator app is going to rely on data stored elsewhere, and in Lambda world that means you're reading from DynamoDB, S3, RDS or whatever. Those are definitely dependencies and that's where the state lies. But the pattern encouraged by Lambda is that your instance contains no state of its own. The disk is used as scratch for each invocation, objects are created for each request and not shared between them, etc. That's what people mean by stateless.
Re:Serverless: slower and more expensive by arthens on Tuesday September 24, 2019 @03:14AM (#21057359)
I see your point, but this definition is so lax that it applies almost perfectly to any application I've ever deployed to the cloud. Using external services to save state isn't unique to lambda, any app hosted on a normal ec2 instance needs to follow the same pattern because the instance and its filesystem can go away at any time (unless you attach a volume, but I've always considered that to be bad practice).
Re:Serverless: slower and more expensive by bmm6o on Sunday September 29, 2019 @08:43PM (#21110766)
Sure, it's a common pattern and the right one in many scenarios. But especially for non-cloud deployments it's very common to store session data in process memory or temp data to local disk, etc.
Re:Serverless: slower and more expensive by nailer on Tuesday September 24, 2019 @03:22AM (#21057402)
No it's not. There's no in memory state. Your Django rails phoenix app has in memory state.
Re:Serverless: slower and more expensive by arthens on Monday September 30, 2019 @03:10AM (#21112466)
What in memory state?
Re:Serverless: slower and more expensive by nailer on Monday September 23, 2019 @10:55AM (#21049464)
On-disk state isn't what people mean when they say stateless. * They mean there is no memory state, which is true and which absolutely means serverless functions are easy to test.

* you could argue that 'stateless' should include no long term persistence, but you'd be fighting an uphill battle. Like saying 'serverless' isn't correct because there are servers.

Re:Serverless: slower and more expensive by chucksmash on Monday September 23, 2019 @08:35AM (#21048287)
State is saved somewhere, sure. How many useful applications are truly stateless when considered in their entirety?

This isn't the sense in which servers are usually said to be stateless, however. A Lambda that reads and writes state from a database when invoked is not maintaining state outside of the request-response cycle itself, so it can be said to be stateless.

Re:Serverless: slower and more expensive by rapind on Monday September 23, 2019 @09:31AM (#21048737)
It's funny because the only use case I was considering lambda for was a pure / stateless function. As soon as you add state / side-effects I assume you've greatly increased your complexity and testing (you'd want to have separate tests for all of the inputs / outputs that resemble production... which is when things can get complicated).

I'm probably looking at it wrong I guess. I considered using lambda to unload some CPU intensive calculations / logic and that's it. I figured it would be good for that as long as the latency didn't outweigh any benefits.

Re:Serverless: slower and more expensive by dullgiulio on Monday September 23, 2019 @09:31AM (#21048735)
Yes, but the parent said "statelessness that makes it easier to TEST". It is not stateless in that sense: purity makes it easier to test. Here you need to mock all interactions with external services, just like you'd do with non-serverless applications.
Re:Serverless: slower and more expensive by nailer on Monday September 23, 2019 @11:28AM (#21049816)
It is stateless in that sense. To run your lambda, there needs to be zero things in memory, unlike a traditional express/django/rails or other non-serverless apps.

If your lambda involves persistent storage, your testing might want to wipe or prepopulate the DB with some objects first, but that's not hard and doesn't add complexity, and as mentioned you don't need anything in memory.

Re:Serverless: slower and more expensive by redisman on Monday September 23, 2019 @02:05PM (#21051637)
Lazy initialization and caching of a resource literally every instance of a Lambda uses doesn't fit the definition of "state" in my opinion.