259 points · by emilong · 10y ago · 152 comments
http://i.imgur.com/BNAcSsn.png
I've been using Lambda quite a bit, I think it's SO amazingly useful. Tasks that are highly parallelized and CPU intensive can literally be infinitely scaled out. I find it weird that their poster child use case is still always a reactive event like watching S3 and formatting images. There are so many use cases for directly invoking a lambda directly from your code.
Imagine a case where you had to parse a million documents with a relatively expensive computation, let's say 250MS per document. Maybe you have a solid machine with a few cores that's running your server, but even then you can't have the server cpu locked for so long, so naturally you'd need some sort of worker server set up. With a good machine and multiple cores, maybe you get 8 running at once. With a lambda, you can forego the worker server altogether. Just invoke a million lambdas directly from your application server, completely parallelized.
Theoretically, you've taken something that would take 70 hours and had it run in 250ms without having to set up any additional infrastructure.
The only caveat for those considering taking this path - AWS has an account-wide limit of 100 concurrent lambdas running at once. There's no way to know how many are currently running unless you keep track of it yourself. You'll only find out when you try to kick off a job and it get's throttled. I haven't contacted support yet to find out how hard it is for the limit to get raised or what they'll raise it to.
The guts to make all that work was 50 or so lines of config. I think my auto scale script was 20 lines or so of Python.
I guess the biggest downside was spinning up the new server took about 2 minutes, so for big load spikes it took a bit for it to level out... but with GCE per minute billing, all the napkin math I did says it is a fair bit cheaper per cpu unit to do it this way.
In conclusion, someone good with devops + a normal work queue system could do this years ago. I guess it's cool to lower the barrier to entry, but not it does not seem like a game changer. It totally IS cool to scale out backend work to a job farm. Just seems like not the only way to do it.
- Per-minute billing
- 0-to-cluster in under 90 seconds (aim for 30 seconds)
- Pre-emptiblem VMs
- Custom VMs
Now you start with a job, pay a 30 second penalty, and execute it on an entirely ephemeral cluster. The "get a cluster and fill it with jobs and round up to an hour" model is indeed outdated IMHO.
(work at Google Cloud)
Because those are the things that need to be done in the real world, 99% of the time.
Sadly, we don't all get to work on cool stuff :)
But I think as more people get access to the power and find uses cases, it will get used more.
The 'next' step for Lambda is serverless hosting for web-sites, something which Lambda is 'almost but not quite' ready for, the limiting factor being transactional latency, especially in some weird cases. Once they have that sorted out, I will never want to see a server again :)
Also a simple conversation with AWS increases the limit[0].
They obviously don't want people to write absurd runaway structures and 100 is an arbitrarily chosen value to guard against that.
And you've spent the cost of building out that 8 server infrastructure in one batch.
Assuming 70 hours at $0.000000834/100ms [1]
The whole job costs $2.10.
If you can peg the CPU and don't mind getting interrupted, spot instances are still a fair bit cheaper. But Lambda looks pretty attractive for any other use-case where the statelessness of Lambda doesn't bite you.
I also feel like your comment is implying that the outcomes of the lambda option vs the worker server are comparable. As mentioned, the worker machine will still run in hours, rather than less than a second.
I've considered the possibility of having students do things on AWS (beyond web dev), including Lambda, and just expensing the costs. It seems feasible to quickly set up every student with controlled access via IAM...but is there a way to set up rate-limiting, ideally through a policy? That is, shut an IAM down if a student accidentally invokes a million processes? Or, for that matter, limiting the storage capacity of a S3 bucket?
Google cloud gives free edu grants.
If you go serverless though, it's probably not going to be an issue. I would be amazed if a student used more than $10 doing anything with lambda.
I'm willing just to expense things on my account for the sake of simplicity but will see if AWS has a more streamlined process for class/per-student approval. Thanks!
Such a model would allow infrastructure developers to abstract away most of the concerns around networking, collisions, security, etc., and let game developers concentrate their efforts on simply making the game.
I currently have a game server cluster written in Golang, where the locations are instantiated with an idempotent request operation. It doesn't matter if a particular location-instance exists at a particular moment. It's sufficient for the "master control" server to only approximately know the loads of the different cluster server processes. My experience leads me to believe that something like AWS Lambda, but optimized for implementing game loops would work well, so long as game developers could get their heads around pure functional programming and implement with soft real-time requirements in mind. (John Carmack already advocates the use of pure functions, and game devs in general already do the latter.)
The code was on GitHub but I can't seem to find it.
But what's the solution for structured data? DynamoDB is the obvious main candidate, but it's billed by hour and high concurrency is very expensive, requiring complicated temporary increases and decreases of concurrency that are hard to predict.
Is there a good solution for running massively parallel lamdas on stuctured data?
If you're dealing with a TON (5+ TB) of data I recommend heading in to RDS, BQ, or redshift.
It seems the only storage services compatible with variable unlimited bursts of concurrency are S3 and SimpleDB. S3 comes with many problems for handling structured data (no update of records only replace, locking, listing items is slow/costly, etc.). SimpleDB is no longer being iterated, is limited to 10gb per domain, and looks like it's being slowly phased out.
It seems like massively parallel lambdas depend on few fetches of large blobs of data - which is basically batch-processing EMR-style, or better suited to redshift. Not something that opens the door for novel use-cases.
I would have really liked for dynamodb to be more of a service than a vm. I wish its concurrency was unlimited and you paid for usage rather than time. Basically DynamoDB with SimpleDB pricing.
If you only need one index, then just name your s3 document by the compound index value and call it a day.
Otherwise, just use RDS for everything.
It's like saying deathless meat, because someone else killed the animal you are consuming.
If you have seen "the interview", this is like when the guy says "on the line", and gets corrected each time.
The concept of 'server' loses all meaning in this given architecture.
You create 'Lambdas' - units of functionality - and they do that they are supposed to do entirely independent of the underlying architecture.
In fact, using the concept of 'server' in a Lambda situation probably obfuscates the situation and adds unnecessary complexity.
A 'server' is an implementation detail that concerns only those providing the container/Lambda services. As long as the implementation lives up to the SLA (i.e. performance, uptime, security, price, redundancy) that you have agreed to - then it doesn't matter how it works.
So it is, in fact, both a lie and misleading.
'Serverless Computing' as a term to describe the paradigm I think is very neutral, descriptive and apt. It's even a little bit boring but it does the job.
It's a genuine business case, as running a lean and secure server farm is no child's play, but it's also oversold so much that my eyes hurts.
Actual serverless computing would be implemented as p2p. Possibly interesting in a typical EvilCorpesque large corporation.
Besides, Seti@home (Boinc) have been doing serverless computing for almost 20 years and it wasn't the first implementations.
Some uses of cloud services are superficially comparable to old-school bureau computing. But to say it is "just someone else's computer" is trite, grossly misleading and downright bad advice, because treating it as such will get you burned.
If you have the right workload, it is super awesome.
If you have a reasonably matching workload and you can spend spend time on all the things you counted, it's also probably good but it's far from a clear-cut certainty.
If you have heap of legacy systems you will basically need to rewrite a lot it to make it work, and then it might not be worth it at all. This is the case that is oversold.
It's perfectly reasonable IMO for that to be called "serverless".
It's perfectly reasonable IMO for that to be called "factory-less car".
It's perfectly reasonable IMO for that to be called "farmless chickens".
If anything, this model can provide a more straightforward costing model. e.g: x transactions = x lambda calls = x cost
Also saves you the work of setting up an autoscaling infrastructure.
Is anyone using it in production that can comment?
FYI - we did some experiments and the limiting factor was latency. 250-300ms on average, you have to go through their API feature as well, and that's part of the delay. But worse - Lamda's that have not been called for several minutes (I'm assuming they are not 'hot') often take several seconds, up to 5s to be called. So it creates a problem for intermittent traffic.
If that kind of latency is acceptable to you, it might work for you so long as the cost equation is right.
I think some other people had issues with versioning, it's a problem we didn't go far enough to observe.
P.S. Quoting the author: "As you can see for these queries, the reference implementation performs reasonably well; it's nowhere near Redshift performance for the same queries, but for the price it really can't be beat today"
Disclosure: I work on Google Cloud, but I'm just pointing out a fact ;).
"With HyperContainer, we make the performance/overhead of virtualized container similar to linux container --- 130ms launch time, and sharing the read-only part of memory (kernel and init)." -gnawux
Lambda is a fully elastic infrastructure you can build, deploy, and execute functions.
Simply having docker-engine and docker-cli installed on my machine doesn't give me anything close to lambda.
I find that term confusing, too, but it seems to be well-established by now, so we have to live with that.
Please refrain from strawman arguments. I wrote "AWS lambda and/or similar services".
In the Fowler article, you find a nice classification of these services:
- BaaS (Backend as a Service)
- FaaS (Funciton as a Service)
On AWS' side yes there are servers powering Lambda, but developers do not have worry about them at all. The code just runs.