When Lambda goes full Omega and why distributed architectures matter

When Lambda goes full Omega and why distributed architectures matter

Today’s Best Band Ever™ is Dead Pioneers.

Native American punk. Honest, sharp, angry, inspiring.

Difficulty: Hurt me plenty


The world

Trump is still "winning" his blitzkrieg against Iran, Putin's 3-day war is in its fifth year, Naza was released and Israel countered it with "Naza, Triumph of the Will The Real Story". It's interesting, because when one is accused of a crime and presented plenty of evidence, they don't usually engage in social media campaigns or try to dismantle the very court that is accusing them.

To everybody's surprise, the tech companies that massively profit from their dominant position are suggesting to the EU that seeking alternatives will be expensive.

In related news, several hundred French supermarkets were hacked, and their freezers were turned to +50 °C, causing millions of euros in losses. This has little to do with digital sovereignty. It has everything to do with incompetence: companies knew about vulnerabilities for at least a year. The bottom line is that this was "first cyberattack to have a physical effect on a nation's food supply chain."

Ukraine has started attacking Putin's datacenters. It's not yet clear whether this will reduce election interference, but the upcoming votes in Brazil, Canada and the USA might show some surprising results. (I started writing this several days ago. Looks like Canadians in Alberta voted with love, not fear.) What is already clear is that the founding principles of ARPANET, which eventually grew into the internet we know today, still stand. Decentralization and thus the resilience to partial failures, is an essential tool in fighting tyranny and authoritarianism. The right time for the EU to create CADA was eight years ago. It's not too late yet, but the margin for error is much smaller.


The tech

I realize it's ironic to claim this part to be finally about tech after what I wrote above. Let's say it's somewhat purer, akin to how computer scientists often distance their work from computers. As Edsger Dijkstra famously said: "Medical researchers are not required to suffer from the diseases they investigate."

This year's re:Invent is upon us, and new features are coming. What caught my attention is the announcement that AWS Lambda now supports running web applications.

First I was curious. The more I thought about it, though, the less I liked it. For one, people were already doing this, so it's not very revolutionary. But then I remembered the little assessment tool I proposed. Here it is:

A cloud native solution
- runs only parts that are needed at the moment (on demand)
- runs them only for as long as they are needed (just in time)
- runs in the most cost-efficient way (cost centric)

AWS Lambda introduced the concept of serverless and is the essence of cloud native - pick only what's needed and delegate running it in the most efficient way to the platform. The new web applications feature, on the other hand, only fits the second criterion - when there's no incoming traffic the function will scale to zero.

Does it matter? Let's go over the rules one by one.

Run only parts that are needed at the moment (on demand)

This is the lesson we've learned from monoliths. When you have one big thing, you need a big and "hot" space to store it. And that space is occupied whether you're using the thing. It's all or nothing.

It's fine if you have all the space in the universe and can instantly travel to any location. Lucky you.

When you don't, the only alternative is to split the big thing into smaller ones, store them somewhere they don't get in the way and pull only those that are currently needed. Just like in your kitchen: you don't keep all utensils immediately within a hand's reach.

The obvious downside of distributed architectures is that those many parts all need to be managed. But we've been dealing with kitchens full of things for a while - it's not that hard. Cloud and software in general, are no different.

Lambda web functions break the first rule.

In the kitchen analogy, it's like a knife that is permanently glued to the blender and all other utensils. You can still cut that apple, but operating a tool that is an agglomeration of everything ... must be awkward.

Run them only for as long as they are needed (just in time)

Staying with the kitchen analogy, this rule suggests that you switch that blender off when the smoothie is done. A usual monolithic solution takes time to start, so it's usually started once and then kept up (a server). This is akin to running a blender 24/7 because people sometimes make smoothies. It's noise, wasted electricity and unnecessary wear on the device.

💡
Beware. AWS warns that only already started (warm) functions will respond quickly.

Lambda web functions are hybrid monoliths which scale to zero, so, even if awkwardly, this rule still stands.

Run in the most cost-efficient way (cost centric)

This rule is tricky because both previous rules already touched on cost - wasted space and wasted resource.

The truth about cost and cloud is that everything in the cloud is about cost, either maximizing profit or minimizing expenses. Here's an example break-down using the pillars of the Well-Architected Framework.

💡
Operational Excellence
This pillar focuses on doing most work with the least effort.

Security
Nobody needs security. We invest in it because breaches cost more.

Reliability
Reliability is about making sure the shop is operational when the customer comes in.

Performance Efficiency
While this pillar is about using the right tool for the job, the underlying need for that is cost. Bigger tools are more expensive to use.

Cost Optimization
Duh.

Sustainability
Surprisingly, sustainability-tuned solutions are cheaper to run. ARM processors are good enough for many workloads and are more power-efficient. Similarly, AWS famously supports older generations of EC2 by emulating their hardware on the newer ones: one cannot replace hardware that is out of production. Such emulation overhead is ... well, overhead, which is wasted money in the end.
After a wild roundabout, why not immediately have another?
💡
The cost perspective is the only criterion (even though a complex one) one should use when considering private vs public cloud. Private cloud is fundamentally more expensive: you spend the money first and then justify the cost. With the Public cloud you could pay less if you delete resources you don't need.

So Private cloud is only justified if it's somehow cheaper or the cost of the risk of using Public cloud is too high.

Thus, governments should go private, but companies should calculate the risk.

Having "cost centric" as a separate rule is redundant, but it helps to make things more explicit.

The first rule already hinted at this: when one puts multiple functions into one Lambda, the consequence is that one will need a bigger Boat Lambda: more memory and likely more CPU to accommodate the bigger package.

One could argue that despite the package size, most of the code will not execute and memory will not be requested. But according to AWS, web functions are implemented in such a way that a function's runtime serves multiple concurrent requests (up to 128). This means multiple paths might be taken. Consequently, the function should be big enough to process any of the 128 paths. The only completely safe approach to that is to identify 128 of the most CPU- and memory-hungry functions and allocate enough capacity to run all of them at the same time.

The purpose of this feature is to reduce the number of things to manage. A smartphone that has a camera is fine. A blender conjoined with all your knives, forks and spoons is not.

Two rules out of three broken. AWS Lambda Web Functions are not cloud native.


Stay tuned, stop aggressors and fight Nazis no matter what they pretend to be or the country they come from.


PS. This blog is still stubbornly 100% GPT-free.