Live data from Hacker News

In The Works – Amazon Aurora Serverless

aws.amazon.com

21–30 of 34 posts

Re: In The Works – Amazon Aurora Serverless

#21

Really wish "serverless" also meant that it can work with AWS Lambda efficiently. As is, each function would try to open a connection, making the overall overhead extremely high and stressing DBs.

Are you sure? That is, do you have specific knowledge of the implementation? Because:

> The endpoint is a simple proxy that routes your queries to a rapidly scaled fleet of database resources.

That doesn’t seem to preclude a multiplexing proxy a la PgBouncer.

Re: In The Works – Amazon Aurora Serverless

#22
post #20

Last week I created a small framework called lambdaphp[1]. My aim was to host a Wordpress or Laravel site on aws lambda without paying any monthly hosting charges. I got everything running (sessions, fs, request, etc) except of course I still had to use RDS and I think this takes care of it too. So now I can expect to run a full site which is only billed by the amount of resources consumed. Of course my project was j…

AWS will likely add PHP support, yes but they absolutely will not do what this project does: Running a NodeJS http server that launches a PHP binary and runs local scripts.

That's just one way to make it happen until we get proper support. I wrote to AWS support and they said that they will consider PHP support for AWS lamba as many people have requested it too (did not give me an ETA though).

The funny thing is the response time is quite good despite running it through a NodeJS server that launches a PHP binary (340ms, faster than 98% of the sites as per pingdom[1]).

[1] https://tools.pingdom.com/#!/ex9izm/https://www.lambdaphp.ho...

Re: In The Works – Amazon Aurora Serverless

#23
post #20

Earlier quoted context omitted.

AWS will likely add PHP support, yes but they absolutely will not do what this project does: Running a NodeJS http server that launches a PHP binary and runs local scripts.

That's just one way to make it happen until we get proper support. I wrote to AWS support and they said that they will consider PHP support for AWS lamba as many people have requested it too (did not give me an ETA though). The funny thing is the response time is quite good despite running it through a NodeJS server that launches a PHP binary (340ms, faster than 98% of the sites as per pingdom[1]). [1] https://tools.…

I understand your options are limited until AWS adds first-class PHP support but there are still plenty of superior ways you could arrange this. You're running the PHP CLI as opposed to using a persistent process daemon and speaking to it over one of the other SAPIs (e.g. FastCGI). You're also completely defeating the inherent async properties of NodeJS too by launching a synchronous PHP process, and you're completely missing the benefit of "pre-warming" servers. Only the NodeJS aspect gets to pre-warm but a PHP process must launch from cold for every single request.

340ms is not a good response time at all. You need to elevate your expectations.

Re: In The Works – Amazon Aurora Serverless

#24

Really wish "serverless" also meant that it can work with AWS Lambda efficiently. As is, each function would try to open a connection, making the overall overhead extremely high and stressing DBs.

Are you sure? That is, do you have specific knowledge of the implementation? Because: > The endpoint is a simple proxy that routes your queries to a rapidly scaled fleet of database resources. That doesn’t seem to preclude a multiplexing proxy a la PgBouncer.

I don't think it is, just wishing it was.

Re: In The Works – Amazon Aurora Serverless

#25
post #17
post #15

Earlier quoted context omitted.

Can't you open the connection outside of the function? So as long as the function is hot, it won't reconnect.

That's right. Make connections to databases (and most other things) the first time your Lambda handler runs, and stash them in a static/global variable for re-use on future runs. That allows you to amortize the cost of forming the connection over many executions of your function, which improves latency, reduces cost, and reduces load on the backend.

Haven't heard of this approach yet. Do you have a write up I could reference to try it out?

Re: In The Works – Amazon Aurora Serverless

#26
post #23

Earlier quoted context omitted.

That's just one way to make it happen until we get proper support. I wrote to AWS support and they said that they will consider PHP support for AWS lamba as many people have requested it too (did not give me an ETA though). The funny thing is the response time is quite good despite running it through a NodeJS server that launches a PHP binary (340ms, faster than 98% of the sites as per pingdom[1]). [1] https://tools.…

I understand your options are limited until AWS adds first-class PHP support but there are still plenty of superior ways you could arrange this. You're running the PHP CLI as opposed to using a persistent process daemon and speaking to it over one of the other SAPIs (e.g. FastCGI). You're also completely defeating the inherent async properties of NodeJS too by launching a synchronous PHP process, and you're completel…

You can't launch a persistent process on AWS Lambda.

Re: In The Works – Amazon Aurora Serverless

#27
post #26
post #23

Earlier quoted context omitted.

I understand your options are limited until AWS adds first-class PHP support but there are still plenty of superior ways you could arrange this. You're running the PHP CLI as opposed to using a persistent process daemon and speaking to it over one of the other SAPIs (e.g. FastCGI). You're also completely defeating the inherent async properties of NodeJS too by launching a synchronous PHP process, and you're completel…

You can't launch a persistent process on AWS Lambda.

You most definitely can. Lambda freezes the state of the container and thaws it for the next request (assuming the next request is relatively soon, otherwise it deletes the frozen instance entirely -- This is the entire premise behind keeping lambda functions "warm") including any background processes that might be running.

It's not persistent in that it exists between requests, but for the use case here it's exactly what is needed. He would save significant response time by having php-fpm already running, code parsed, opcodes cached and just issuing a new FCGI request to php-fpm instead of relaunching the PHP CLI each and every time.

Re: In The Works – Amazon Aurora Serverless

#28
post #17

Earlier quoted context omitted.

That's right. Make connections to databases (and most other things) the first time your Lambda handler runs, and stash them in a static/global variable for re-use on future runs. That allows you to amortize the cost of forming the connection over many executions of your function, which improves latency, reduces cost, and reduces load on the backend.

Haven't heard of this approach yet. Do you have a write up I could reference to try it out?

I never read anything official, but some stuff by framework makers (serverless/apex up)

edit: https://medium.com/@tjholowaychuk/aws-lambda-lifecycle-and-i...

Re: In The Works – Amazon Aurora Serverless

#29
Given the existing architecture of Aurora, the independent scaling of CPU and storage seems pretty straightforward. What is much harder to scale up and (especially) down is a warmed-up buffer pool which is critical for consistent query performance. I wonder if that is what they mean in the article when they say that scaling happens on a "pool of 'warm' instances". If so, I'd be very interested in more details on how that works.

Re: In The Works – Amazon Aurora Serverless

#30
post #23

Earlier quoted context omitted.

That's just one way to make it happen until we get proper support. I wrote to AWS support and they said that they will consider PHP support for AWS lamba as many people have requested it too (did not give me an ETA though). The funny thing is the response time is quite good despite running it through a NodeJS server that launches a PHP binary (340ms, faster than 98% of the sites as per pingdom[1]). [1] https://tools.…

I understand your options are limited until AWS adds first-class PHP support but there are still plenty of superior ways you could arrange this. You're running the PHP CLI as opposed to using a persistent process daemon and speaking to it over one of the other SAPIs (e.g. FastCGI). You're also completely defeating the inherent async properties of NodeJS too by launching a synchronous PHP process, and you're completel…

That's quite insightful. I see you really know what you're talking about and any examples or snippets will be helpful. You are also welcome to collaborate with me on the project for fun if you want (it was a great challenge for me). I'll probably look into it again next weekend to implement your suggestions.

How much do you reckon we can get the response time with these optimizations? Right now the 340ms is nodejs + php-cli + my wrapper script (that inits s3, etc) + the actual content script (another php file) and request for the css framework from a CDN.

Post reply on HN