Dude where's my coldstart?
openfaas.com
openfaas.com
Then again, maybe it is cost-effective to burn seconds of CPU time and tens to hundreds of megabytes per request handled.
I’m sure some C programmer from the CGI days would be floored by how much resources multithreaded ruby and python app servers use.
Most businesses have no need for such a system, of course, and the costs per function execution are astronomical in comparison to a native program, but for some use cases, the benefits outweigh the costs.
As for Ruby and Python, the cost is measured in dev time rather than server costs. Servers are cheap compared to devs, and if a dev can pump out a feature three times as fast because they can make use of a simpler framework, you can afford the overhead of slower programming languages.
For this reason I'm watching the Rust space with interest, because the speed is much closer to C++ than to the traditional Java/C# servers most big applications are written in, but the frameworks are slowly shaping up to be similarly complete. Of course, there's a huge difference between Rust and most other languages that cannot be overlooked, but services like Vaultwarden show an interesting opportunity in the server space. It'll still be a while before the tools and frameworks reach a similar level of usability, though.
This is the biggest deal IMHO. FaaS in CDN edge DCs are remarkably fast and affordable. If you can respond to an API call faster than a request can get through to a load balancer, you're providing quite a UX improvement regardless of cost. For most people running stateful apps this requires some large tradeoffs in the form of the data layer, but they are getting more reasonable over time. In the case of CloudFlare which may have the strongest edge function hosting now, it used to only support its Worker KV data store (fast but KV only and globally eventually consistent ~10 secs). More recently they have added support for fast connections to their R2 (S3-like) service, and now they have a new service that can proxy to MySQL and Postgres databases.
https://blog.cloudflare.com/relational-database-connectors/
Its an exciting space, because its not just about CDNs: as 5G towers are rolling out, they are building in edge compute clusters along with them. So now you have a 5G iPhone with faster single-threaded performance than your desktop able to get 1Gbps down and faster response times because of its path to edge compute. ISPs are also getting in the game:
https://www.coxedge.com/serverless https://www.limelight.com/resources/data-sheet/edge-compute/
If performance is THAT important you would be better served with a HUGE machine with a huge cache of the database. That's not something you can do with a FAAS. Other than saying "hello world" fast. I can't think of a proper use case where the performance of FAAS would be realistically better than a dumb monolith. The performance and complexity overheads of FAAS make the case even harder to make.
https://blog.cloudflare.com/durable-objects-ga/
I don’t disagree that a huge database can handle an astonishing amount of load but at often unreasonable expense. There as many cases where FaaS is dramatically more affordable to run, both in compute cost and ops time. There are others where its costs spiral out of control under load and with dev effort to fit its constrained programming models. Its hard to say its entirely a trendy frivolity when there are many use cases where its the best tool for the job.
How much faster will this be? I think even for servers on the other side of the planet, the max ping will be something like 500ms. I think most pings in the same continent will be something like 100-200ms. On the other hand, a Node hello world was 164ms. That means that compared to just being in the same continent, you don't have much of an advantage. Python is ~30ms for a hello world, That's better. On the other hand, the "competition" is marked as 250ms for a cold start. That's a lot, and I doubt you get the benefits of being close to the user at this point.
There may be some things I missed, I don't know much about that space.
I've also used some AWS Lambdas and GCP Cloud Functions in background data processing settings where there are under 1M invocations/month, so its cheaper than running a tiny instance 24/7. In that setting latency doesn't really matter as much, but I was seeing cold starts ~2 seconds and warm start invocations on my node and python code responding within 30-60ms in most cases. Once the container is up and running its reused for follow-on invocations, but eventually(and opaquely) times out and the next invocation will be cold. People who are using serverless runtimes have historically done hacky things to ensure they always have a running container like invoking the function with a cron job. At that point it seems a bit silly not to just run a small vm / container.
Also, the vast majority of the world doesn't have an iPhone, so assuming everyone is spending over a thousand dollars on the latest and greatest cellphone will lead to even worse websites.
A $10 VPS will manage thousands of users fine for most CRUD apps. You don't need tons of VM.
You can always make it a... $20 VPS to have some margin if you fear HN hug of death.
You won't get a CDN close to the user or automatic backup, but that's really fine for the immense majority of projects.
It takes one hour to setup a VPS with nginx, python/node/ruby and postgres. Then it mostly runs on its own for years: no coldstart problem, no kubs to manage.
I get the benefit of the cloud at scale, but for thousands of users, it seems really overkill.
Some tasks, though, are just terribly slow. For example, crawling a webpage and taking a screenshot of it sounds incredibly easy but turns out to involve a lot of resource-intensive moving parts. The most common solution I see involves running Chrome in a container and taking a screenshot. That kind of code can easily overwhelm even a moderately expensive VPS with just a few clients. On the other hand, most CRUD stuff and frontend-heavy applications would run fine even off a modern Raspberry Pi.
You can't just let something run, though, because you need to manage system updates. It's something you can easily forget if you have tons of other stuff to do, so the laziness factor also helps defend the *aaS setup.
I don't like serverless, I think it's the next step in more wasteful programming by people who can't or don't want to understand the systems underlying their code. We're at the point where shipping an entire operating system along with an application has somehow become the norm, and I don't like the fact that eventually I too will need to learn this serverless crap.
Indeed, things like video encoding, machine learning, graph traversal, etc, can be pretty expensive.
But then again, our tooling are so powerful these days you can get away with a lot. Timeseries ? Clickhouse is your friends. Need geo calculations ? PostGis is here. Need to extract frames from a video ? ffmpeg will do that in a few cpu cycles. Data analysis ? Say hello to pandas. Validation, caching, expiration, encryption, workflow, pub/sub, logging, reporting... We have amazing solutions for everything that will let you scale up to the millions of users for few hundred dollars.
In your example with the screenshots, one can imagine putting them in a queue (5 minutes setup with python-rq + redis) or even more low tech, a cron, and suddenly your VPS can take one screenshot every 2 seconds, which is 43200 in a day. That's a lot of screenshots.
Your client need the screenshot immediately ? The browser can take a screenshot from JS with html2canvas.
Sometimes it feels we are using $TECH because there is a whole class of devs that can't find solutions to problems:
- don't want to think about your data structure ? Put everything in no sql.
- don't want to think about your deployment ? Put everything in a container.
- don't want to think about your algo ? Put everything in the cloud.
Of course, in the end, you still have to think about all that no matter the tool you use. You just moved the cost somewhere else, usually paying much, much more later.
In fact, even most of the stuff I get paid to do using Django could be done cheaper with wordpress. I'm already overkilling it.
Today I just can’t make a guarantee for a fresh Ubuntu LTS instance that it will run a 15-line pure C or sh code as I would intend to outside of my attendance, regardless of how easy the requirements or the SLA might be.
As much as I hate serverless or easy scripting language trends, they do the job and do it well.
In this case the serverless versions may be better, easier or cheaper. We did not use Python or Ruby by the way. I still think Python is a bad choice for most systems.
Yeah to a point, but Python is so much slower than fast languages that your devs will spend longer trying to optimise it and write parts in C++ that you may as well have just written it in Rust or Go or Java or C# or whatever in the first place.
And I don't buy "development in Python is faster" even ignoring performance. Maybe for tiny programs but once you get to reasonably sized ones the lack of good static typing makes all changes extremely tedious and error-prone. Plus you have to spend a mountain of time writing tests that you wouldn't even have had to think about with stronger typed languages.
I can definitely fix bugs in Typescript or even C++ way quicker than I can in Python.
This really rings true with me, on both sides - I mostly (have) only use(d) python professionally; on semi-mature projects with some buried bodies etc. I spend my days wishing it was Rust (or that the JS was TS) thinking that that would be easier, or that the bug I'm fixing never would have existed. But then when I spend my own time starting something for fun, and so naturally use Rust to avoid that, it annoys me that it takes so much longer to get going and if only I'd decided to use Python, etc.
When you have done the optimisation above, and your bosses keep asking for more features coming out per quarter, and you need to hire more, you're going to opt for the new things everyone is learning, so that you can hire enough without making your life all about hiring.
These are trade-offs like any other, and you probably just haven't been exposed to similar constraints or all of this would make at least some sense.
There may be better ways, of course.
The entire architecture that leads to such a concept is so dumb I have trouble believing anyone ever thought it could be a decent idea.
In particular, the world runs on power laws, and I'm betting most server apps are boring occasional internal stuff at the not-even-1-qps level. Long tails add up to be the typical project. So yeah, if all the worlds internal django tools can do scale-to-zero with fast cold start on shared boxes with 100X more tenancy than today, that's saving a lot of electricity & hw. Sort of a virtualization equivalent of "640K ought to be enough for anybody".
If you wait long enough between requests (~5 minutes), that is what AWS Lambda does, only with a VM instead of a container.
Also it feels to me like FaaS is good when someone else is running the infrastructure (so you really don't have to know about the underlying infrastructure). Why are people self hosting this? Is it for local test platforms before deploying to a managed FaaS?
At one point you do hit a limit on what you can do by cold-starting (almost) everything anyway, right? Let them optimize so they are competitive, and now they've given me a good reason to evaluate them.
That is what Cloudflare Workers do. One v8 isolate thread per request.
From the FAQ:
> Why do I need watchdog anyway?
> Whilst we don’t recommend it, if you’re using a HTTP microservice that conforms to the Workloads spec, then technically you may be able to get away without using it.