109 points · by LaSombra · 6y ago · 65 comments
Lambda VM time has a massive markup compared to regular compute. It only makes sense where usage does not exceed some threshold the BBC absolutely certainly do.
There are plenty of alternative options, even on AWS, that don't suffer from such huge markup without requiring any additional ops input. The thing that runs in Lambda is practically a container image already. Does it really cost tangible budget to have CI build a full image rather than a ZIP file that already contains a few million lines of third party JS/Python deps?
IMHO this is the epitome of serverless gone wrong.
Lets assume - 2000 calls/sec - each call is 1 sec duration - 0.128 GB/sec/call - db, storage iops will be the same if deployed as K8s - 5x9s SLA (imples a three region deployment)
requests per year = 2000 * 3600 * 24 * 365 = 63072000000 request costs = 0.2 * 63072000000 / 1000000 = 12,614 USD
GB/sec per year = 0.128 * 2000 * 3600 * 24 * 365 = 8073216000 GB/sec costs = 8073216000 * 0.0000166667 = 134,553.87
Total cost = 12614 + 134553.87 = 147,167.87 USD
The equivalent K8s would be - three clusters - 2000 cores (more likely 10% more = 2200) - 256GB memory
Three clusters will require 3000 cores to cater for region loss - 3000 cores on 32 core machines => 94 machines - round up to 99 machines to give vm level redundancy => 33 machines per cluster
Azure D32a_v4 (32 core, 128 GiB, 800 GiB storage) = $1.84/hour PAYG; $0.5704/hour Spot
DS32a_v4 at spot pricing = 99 * 0.5704 * 24 * 365 = 494673.696 USD
Plus FTE support (e.g. n FTEs @ 100k USD)
With 2 FTEs total is 694,673 USD
Summary: AWS Lambda is 4.7x cheaper than a Kubernetes solution
You should redo the calculations with 1gb of memory for Lambda and like 30 machines would be generous
Concurrency is key. Requests don't cost much when they're just waiting for other things, but Lambda continues to pile costs on for every increase in concurrency.
APIs should maybe use a tiny fraction actual real CPU time. Perhaps BBCs are different - In order to make an actual fair comparison and properly predict what they would need in servers, greater detail is needed than what you have available to you, but I think your estimations are off by a significant amount.
Price-perf ratio between Lambda and EC2 is obscene, even before accounting for Lambda's 100ms billing granularity, per-request fees, provisioned capacity or API Gateway. Assuming one request to a 1 vCPU, 1,792MB worker that lasted all month (impossible, I know), this comes to around $76, compared to (for example) a 1.7GB 1 vCPU m1.small at $32/mo or $17.50/mo partial upfront reserved.
Let's say we have a "50% partial-reserved" autoscaling group that never scales down, this gives us a $24.75/mo blended equivalent VM cost for a single $76 Lambda worker, or around 3x markup, rising to 6x if the ASG did scale down to 50% its size the entire month. That's totally fine if you're running an idle Lambda load where no billing occurs, but we're talking about the BBC, one of the largest sites in the world...
The BBC actually publish some stats for 2020, their peak month was 1.5e9 page views. Counting just the News home page, this translates to what looks like 4 dynamic requests, or 2,280 requests/sec.
Assuming those 4 dynamic requests took 250ms each and were pegging 100% VM CPU, that still only works out to 570 VMs, or $14,107/mo. Let's assume the app is not insane, and on average we expect 30 requests/sec per VM (probably switching out the m1.medium for a larger size taking proportionally increased load), now we're looking at something much more representative of a typical app deployment on EC2, $1,881/mo. on VM time. Multiply by 1.5x to account for a 100% idle backup ASG in another region and we have a final sane figure: $2,821/mo.
As an aside, I don't know anyone using 128mb workers for anything interactive not because of memory requirements, but because CPU timeslice scales with memory. For almost every load I've worked with, we ended up using 1,536mb slices as a good latency/cost tradeoff.
Edit: another thing is the amount of RAM used by functions. The CPU speed you get is proportional to RAM so if your code fits in the RAM but has poor performance, doubling the RAM is what you have to do. Another hidden cost.
The GB/sec calc is there My assumption was that even with k8s there'll be an API gateway, GTM etc
Comparing AWS Lamda = 147,167.87 USD to K8s with autoscaling:
DS32a_v4 at spot pricing = 66 * 0.5704 * 24 * 365 = 329782.46 USD With 2 FTEs @ 100k total is 529782.46 USD Caveat application can tolerate autoscaling delays
Summary: AWS Lambda is 3.5x cheaper than a Kubernetes solution
In as much as maintaining infrastructure can ever be 'solved', doesn't paying someone else who does a good job of it to provide you with the infra count as solving the problem? Otherwise you'd be down the mines picking ore out of the ground so you can build your chips right, rather than relying on intel/AMD to do it for you and assuming it'll be alright.
The question is then: is it just cheaper in the long run to deal with the hassle of your own infra (we are still talking about the cloud, btw, the thing that supposedly already solved it) or would it be ok to follow the practices and changes in the providers offering?
As a side note, the new HTML is way more complicated and much harder to parse than before - I know the aim isn't to help parsing for content, but I was still saddened to see how it's ended up (a bit of a mess imo - hard to distinguish actual article content from other things).
If anyone knows a reliable and public way to access the content before the "web rendering" layer, that'd be very handy!
It’s kind of where we started in the early 2000s and gone full circle. CSS was created to remove the intended style of the site being crafted by the structure of the content. We now have CSS frameworks that dictate how you define the content for layout to take effect.
Is CSS Garden still even a thing these days?
I also know they have a moderately public Nitro API for their media programming (the iPlayer offerings) so it's possible they have a similar one for their web content
i.e. This: https://www.bbc.co.uk/news/amp/health-54795657 vs This: https://www.bbc.co.uk/news/health-54795657
I'm working on a similar thing at moment (BBC html -> markdown) so also exploring the best way to do it.
I'll see if I can figure out if all newer pages will have permanent amp versions, or whether all amp versions drop away over time.
But the RSS feeds are just the headlines. And also don't contain every article ever - only the latest ones with a limit. So not much use to News Sniffer.
[0] https://medium.com/bbc-design-engineering/powering-bbc-onlin...
Frankly I giggled a little with the image showing a spot the difference. Well done, you spent tens of millions and the website looks identical.
> The BBC’s site is made up of several services (such as iPlayer, Sounds, News and Sport). For them all, we need to ensure they use the latest and best technology. That’s the only way to ensure they’re the best at what they do.
"We need to use new shiny because new shiny is the best!"
Realistically 99% of their back end at the time was bits of sticky tape, perl and ftp. They just changed those components out for modern versions of sticky tape, perl and ftp...
Previously they mostly used a typical lamp stack in the front end. The php apps pulled data from Java backend services. They had a strict separation policy.
The different parts of the bbc where essentially different apps with a proxy in front doing path based routing.
You’d generate a RPM with your php app / Java app and that got deployed.
That had a few drawbacks mostly around process, it was a pain to get releases out as had to go through a single team who could deploy your rpm. You also had the inflexibility of a fixed sized pool of servers in a dc you manage.
When they first started using cloud that mostly remained the same but streamlined process. You provide a rpm using the current lamp/Java stack, a build process baked that in to an ami you could deploy. That made deployments more flexible in you was not constrained by the current physical hardware available and removed the dependency having a specific team do the deployment manually on a shared host.
I imagine the hosting started to get expensive with the dedicated hosts per service. Im guessing slowly the more they used aws services and trialing things they ended up where they are which sounds super complex.
I’m not familiar with where they are now other than the article but I’d bet going back to an app such as php, Java, ruby whatever on the fronted and binpacking them with kubernetes would be simpler than dealing with thousands of lambdas on a black box runtime. Most of the stuff at the bbc hits the edge proxies/cache anyway so the remotes are fairly idle.
Especially as cancellations of TV licenses gather steam.
This is a classic example of the iron law of bureaucracy, that work expands to meet the number of people to do it.
https://www.bbc.co.uk/blogs/aboutthebbc/entries/37e4e3f6-fbd...
https://i.postimg.cc/yNKT82sp/Screenshot-20201104-102848.png
This is part of their online news service so shouldn't need TV license.
I'm slightly sad to read about the change. In many ways, I'd rather the perl duck tape & php approach, running on real computers that the BBC owns. Maybe that officially makes me old.
You imply that Amazon/AWS doesn't employ any staff in the UK, which is wrong.
> Amazon will not pay any tax within the UK
Amazon must certainly pay taxes in the UK, or at least the tax ends up being paid on Amazon share price increases from employees share vesting.
Also: they still can’t get two parts of the same page to consistently show the same live football result. This seemed to break about 10 years ago and no one seems to care enough to fix it.
Asking for a yearly spend on AWS and self managed dc’s since 2014 might help as they only started using AWS around then.
Is this official BBC tech blog?
If yes, I am surprised they are using medium. I would think that an org of this reputation, history & size would host their own blogs.
Possibly it's a sensible way of bringing it to a wider audience, since usually their blog content will be specific to UK-based BBC content consumers.
They made a big mistake riding first class on the hype train.
1. Tap on Most Read
2. Tap on any story
3. Tap back in the browser
It'll go back to the Most Read tab, then after a second switch to the Latest Stories tab.Drives me nuts, it seems to reload the page as you go back into it.
There's no option to filter, or sort the results, making non-super-specific searching almost impossible.
I know I could do site:bbc.co.uk/news in Google, but uh, it's Google, so I'd rather not.