Live data from Hacker News

A bank runs serverless with PHP and AWS Lambda

bref.sh

61–70 of 132 posts

Re: A bank runs serverless with PHP and AWS Lambda

#61

Earlier quoted context omitted.

That ballpark is not even close to the park. My company spends ~$500/month on AWS Lambda and we're doing about 2M/req/day with Bref. There's still 12B 940M requests to account for

Thank you, and sorry about that! How come Lambda is so expensive for you? At 13000M invocations/mo, that's $2600 in requests. Is it the GB-seconds duration charge that get you?

The GB-second is the relevant cost of AWS Lambda. # of invocations is pretty irrelevant.

60'000'000 requests

1536MB RAM

300ms response avg

(calculation includes free tier):

Request costs: $11.80/month

Execution costs: $443.42/month

Total AWS Lambda costs: $455.22/month

Re: A bank runs serverless with PHP and AWS Lambda

#62
post #12

Earlier quoted context omitted.

Did I get voted down because I actually agreed with keeping PHP rather than changing languages? I don't care about the karma points, just curious if someone thought I was attacking PHP because they didn't read the whole comment.

it would be nice if HN had a random "explain your vote" mode where voters had to choose from, eg., agree, helpful, insightful, etc. vs. disagree, unhelpful, provocative

If only there was some other famous tech forum with a descriptive voting system that we could learn from...

(https://slashdot.org/faq/mod-metamod.shtml)

Re: A bank runs serverless with PHP and AWS Lambda

#63

I've been elbow deep in PHP for well over a decade, and I was genuinely surprised when I first saw this on Twitter. (Insert swaggy p meme here) I have immense respect for the author, but I'm perplexed about the decision to build a bank on this stack. Especially considering that the person who created Laravel Vapor (a serverless Laravel service) has since discussed the advantages of moving a large project from Lambda…

That's for a large, fairly consistently loaded project.

For a smaller site with bursty traffic, Lambda may be very relevant still.

Re: A bank runs serverless with PHP and AWS Lambda

#64

I always love a story about a successful strangler pattern migration. I do wonder how they came to Lambda though. I love it for small workloads and highly variable demand services, but something like Treezor you'd think has relatively flat and high demand. The cloud cost for Lambda would be much higher than running the equivalent compute, even with something also highly scalable like ECS.

This was my thought. Lambda works well for infrequent tasks. But hosting an API? That seems like it could get expensive pretty fast.

Lambda is $0.0000166667 for every GB-second, which works out to ~$43.20 for 30 days. For a little more ($49/month), you could get a c6g.large and get two dedicated CPU cores (ie, not the shared burstable t2/t3) and 4 GB of RAM.

So yes, very expensive fast if you get much traffic at all. That c6g.large should easily be able to handle dozens (if not hundreds) of requests in parallel, especially if many of those requests are going to have to wait for results from a database.

If you have more than ~800 hours of Lambda execution time per month (30 days being 720 hours), then you're better off with the c6g.large. The only reason to choose the Lambda is if your traffic is extremely bursty and the c6g.large can't handle the load.

Of course, this is all assuming you're using a 1 GB Lambda. Likely, your Lambda needs less, in which case the amount of traffic needed to make the EC2 more worthwhile higher.

Re: A bank runs serverless with PHP and AWS Lambda

#65
post #4

I don't know which surprises me more: that they continued to use PHP in their move to serverless/microservices or that nobody else on HN has questioned this point yet. I totally get why they would keep PHP: they have the language/platform experience already and AWS supports it (which is really more than enough to silence the "You should have switched to {other_language}!" partisans). Plus, I imaging non-trivial amoun…

Perhaps we're finally at a point on HN where people realize there's no need to question the use of PHP. it's a robust, capable language that's just as, or more, suitable for the majority of use cases as any other language.

Just a perspective:

PHP 7+ (the language) was wonderful, especially compared to Javascript's woefully inadequate standard library. It had so many helper functions that made even working with JSON and big data objects much easier.

But having to manage its buildchain wasn't fun (meaning needing to containerize a web server, PHP-FPM, etc. for every trivial deployment). Then needing to support an OS behind it with updates and such, even Dockerized.

For serverless in particular, the availability of V8 isolates (like in CF Workers) or other "just run this snippet of code and don't bother me about the infra" services (like Lambda) or "I can host my serverless in a file alongside my other frontend stuff" (like on Vercel/Netlify) means that JS functions are pretty much zero-config 1-click deploys.

Is there anything like that in the PHP world? For Bref, for example, you have to set up a lot of stuff before the serverless will run: https://bref.sh/docs/setup

For Google Cloud Run (which supports auto-scaling containerized PHP, not true serverless but closer to it than a full VM), you have to manage docker: https://cloud.google.com/run/docs/quickstarts/build-and-depl...

Maybe the closest one I know of is a Google Cloud Function (https://cloud.google.com/functions/docs/create-deploy-http-p...) which comes close to the "function as a service" of JS serverless, but you still at a minimum have to deal with a tiny folder structure (index.php + composer.json).

Is there anything similar on AWS or elsewhere?

Re: A bank runs serverless with PHP and AWS Lambda

#66
post #35
post #14

Earlier quoted context omitted.

I mean, it's not like that sentiment is totally baseless. I've used PHP years ago and both language and core libraries were not well-designed and came with many footguns. I've heard that modern PHP with frameworks like Laravel fixed a bunch of this, so presumably it's quite capable these days. But PHP certainly wouldn't be anywhere near the top of my go-to list at this point.

Eh, at this point can we just stop with the echoing of old memes? I used PHP4 and have used it continuously up to the modern day. If it's not your choice of language that's fine - language choice is pretty unimportant in the grant scheme of things... that said, it can do everything you need it to do (outside of low level memory control). If you need bit-efficient data structures it isn't going to be a good fit... but…

It's alright. I'll be busy getting some easy WordPress work that's fun to do (especially if you use Laravel with it with the roots.io ecosystem) while people are trying to get their obscure Rust blog with leptos/X to compile to WASM so they can deploy it to fly.io and use their remote hosted database for 5 users/month.

Re: A bank runs serverless with PHP and AWS Lambda

#67

Earlier quoted context omitted.

Thank you, and sorry about that! How come Lambda is so expensive for you? At 13000M invocations/mo, that's $2600 in requests. Is it the GB-seconds duration charge that get you?

The GB-second is the relevant cost of AWS Lambda. # of invocations is pretty irrelevant. 60'000'000 requests 1536MB RAM 300ms response avg (calculation includes free tier): Request costs: $11.80/month Execution costs: $443.42/month Total AWS Lambda costs: $455.22/month

I see, thank you for the explanation! Sorry for my mistaken assumptions.

Re: A bank runs serverless with PHP and AWS Lambda

#68
post #28

I have no clues about what's better but as a french I'm amazed by the idea to delegate banking operations to a cloud provider. Last time I worked in bank IT political requirement and good practices were using their own private physical network infrastructure over all the country and data storage server rooms were literally bunkers with armed security. Is it that common around the world and 'we' just happen to have be…

I heard it used to be similar in ING but they slowly migrate some services to Azure for quite some time now.

I bet they will never fully migrate (and they don't want to).

Not affiliated with ING in any way, its just what I heard.

Re: A bank runs serverless with PHP and AWS Lambda

#69

Earlier quoted context omitted.

A lot of swiss government data is also stored in AWS, made a few headlines during covid because we "delegate our data to the americans"

We have your data, you have our money, sounds fair =)

They don't though. Swiss tax wealth (though its a tiny fraction). IRS makes it a massive PITA to hold substantial financial stakes in foreign companies. See FATCA and GILTI. And many tax deferred foreign retirement funds are not treated as being tax deferred by the IRS. It only gets more complicated from here. It's by far easier to earn and hold cash in America.

Re: A bank runs serverless with PHP and AWS Lambda

#70

Earlier quoted context omitted.

Perhaps we're finally at a point on HN where people realize there's no need to question the use of PHP. it's a robust, capable language that's just as, or more, suitable for the majority of use cases as any other language.

Just a perspective: PHP 7+ (the language) was wonderful, especially compared to Javascript's woefully inadequate standard library. It had so many helper functions that made even working with JSON and big data objects much easier. But having to manage its buildchain wasn't fun (meaning needing to containerize a web server, PHP-FPM, etc. for every trivial deployment). Then needing to support an OS behind it with update…

your container running the web server and php-fpm should only need to be deployed once. the point of PHP is that to update your code you just... replace the file. this sounds like a poorly designed CI pipeline that is of no fault of PHP.
Post reply on HN