News for hackers. Stuff that matters.
Re:Amazon RDS Proxy for AWS Lambda by topicseed on Wednesday December 04, 2019 @05:11PM (#21707762)
Long overdue, and now waiting for the PostgreSQL's RDS Proxy as it's the main database we use along with Lambdas... and gosh it's tedious!
Re:Amazon RDS Proxy for AWS Lambda by nzoschke on Wednesday December 04, 2019 @07:32PM (#21708770)
I wonder how this compares to Aurora Serverless Data API. This is an HTTP API that you POST a query to and get results data back.

The result format is a bit clunky but there's all the column information you'd expect.

I found this golang database interface which ended up dropping in as expected with a few tweaks.

https://github.com/Clever/rds/tree/birthday

My bill for Aurora Serverless Postgres last month was less than a dollar.

Re:Amazon RDS Proxy for AWS Lambda by PetahNZ on Wednesday December 04, 2019 @08:09PM (#21709022)
We use Aurora Serverless and this is a sorely needed feature for us. We get large spikes of traffic that also cause large increases in connections to our DB, but Aurora Serverless cannot scale fast enough to cater for this. Unfortunately it doesn't seem we can enable this proxy for serverless clusters.
Re:Amazon RDS Proxy for AWS Lambda by sudhirj on Wednesday December 04, 2019 @08:19PM (#21709102)
Aurora serverless already has a proxy by default - if it can’t scale fast enough it’s likely because your queries are too long and interleaved to find a logical switchover point.

This proxy is probably an offshoot of the serverless proxy.

Re:Amazon RDS Proxy for AWS Lambda by PetahNZ on Wednesday December 04, 2019 @08:40PM (#21709223)
It has a hard limit on max_connections based on the "Aurora Capacity Unit", e.g. for 16 ACU's max_connections it is 2,000. We see spikes of 10x to 100x concurrent users in a matter of minutes (think hug of death style). And although our queries run fast and we see limited increase of CPU on the cluster we almost instantly hit the connection limit.

https://www.jeremydaly.com/aurora-serverless-the-good-the-ba...

Re:Amazon RDS Proxy for AWS Lambda by joecot on Wednesday December 04, 2019 @08:11PM (#21709034)
For anyone else who spent 10 minutes trying to find a link to pricing from this page and failing, here it is: https://aws.amazon.com/rds/proxy/pricing/

Free til the end of 2019, 0.015 per vCPU (of the underlying RDS instance) per hour the proxy is enabled. So it is not scaled down to 0 when not in use. For comparison, a t3.micro (2 vCPU, 1gb ram) is 0.0104 per hour. If you're a big project it might be worth it, but just keep in mind rolling your own proxy or using the RDS serverless APIs are cheaper options.

Re:Amazon RDS Proxy for AWS Lambda by revicon on Wednesday December 04, 2019 @09:47PM (#21709554)
I don't understand why this isn't launching with data api support? AWS specifically built data apis into the Aurora Serverless product for this exact usecase...

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide...

If I'm using Aurora Serverless right now and want to switch over to RDS Proxy I'm going to have to rewrite my calls.

Re:Amazon RDS Proxy for AWS Lambda by crgwbr on Wednesday December 04, 2019 @07:00PM (#21708505)
Does anyone know why RDS Postgres always seems to lag behind their MySQL offering? I can imagine Postgres is that much more difficult to develop a connection pooling service for, especially since PGBouncer and PGPool-II both already exist and are widely used.
Re:Amazon RDS Proxy for AWS Lambda by Aeolun on Wednesday December 04, 2019 @07:15PM (#21708633)
I think both for the reasons you named, and because more people use MySQL maybe?
Re:Amazon RDS Proxy for AWS Lambda by astuyvenberg on Wednesday December 04, 2019 @06:40PM (#21708370)
Finally, this has been a long time coming. Connecting to existing RDS instances from lambda functions has been a pain for users looking to adopt serverless tech into their existing applications.
Re:Amazon RDS Proxy for AWS Lambda by tybit on Wednesday December 04, 2019 @04:46PM (#21707479)
This is really nice, we used lambda for event based ingestion into RDS and MySQL connection limits were such a pain.

However I do wish they’d include how this will evolve alongside last years announced data API.

Re:Amazon RDS Proxy for AWS Lambda by dylanz on Wednesday December 04, 2019 @05:21PM (#21707850)
This is awesome. We were just looking at throwing up PgBouncer in front of RDS in the coming year. Looking forward to PostgreSQL support!
Re:Amazon RDS Proxy for AWS Lambda by ocdnix on Wednesday December 04, 2019 @05:54PM (#21708065)
I really hope it can replace PgBouncer. We've spent way too much time getting it running in ECS, mostly due to us needing a separate PgBouncer service for the primary and replica RDS instances. And then a third ECS service running HAProxy in TCP mode to load balance between the PgBouncer services, to provide a read-only endpoint that balances between the primary and replica. Add issues like: having to patch in HAProxy TCP keep-alive parameter support (it only allows enabling/disabling it, leaving params up to the OS, which you can't control on ECS Fargate, _and_ the AWS NLB having a 350-second TCP flow idle timeout - good luck with long-running queries); AWS NLBs having horrible timing issues when handling target group changes... it was not a great experience.
Re:Amazon RDS Proxy for AWS Lambda by takeda on Wednesday December 04, 2019 @06:16PM (#21708234)
We also set up pgbouncer, but after testing we realized that running it in a container added extra latency so went with ec2 instances behind ASG.

For load blanacing we used ELBv1, we also tried to use NLB, but 350 second timeout, and broken behavior when after timeout it just silently closes the connections was a no-no. ELBv1 doesn't silently close connections, and idle timeout can be set to 1h. After that we configured pgbouncer to close idle connections after 55 minutes. ELBv1 also doesn't have the timing issues with health checks.

IMO NLB is maybe performant, but that's the only good thing about it, in every other category it is crap and for this use case ELBv1 isn't a bottleneck.

If you will plan to revise your setup, be aware that pgbouncer is single threaded so throwing multicore machines at it won't do much good. If CPU ends up being a bottleneck it is better to use a large single core instance and then adding more instances. The only problem with that is that as you're adding more instances you're increasing number of connections to the database, but you could have additional process that could monitor ASG and set the number of instances and dynamically adjust number of server-side connections (doesn't require restarting pgbouncer).

BTW: Since version 1.12.0 you can also run multiple pgbouncer instances listening on the same port so that can help make a better use of extra cores if you chose multicore instances.

Re:Amazon RDS Proxy for AWS Lambda by xyzzy_plugh on Wednesday December 04, 2019 @07:17PM (#21708642)
I, too, am curious how it'll fare compared to DIY PgBouncer. Related, I am building something related that solves a superset of these classes of struggles. I'd love to pick your brain, if you're interested! Do you mind shooting me a message? (email in profile)
Re:Amazon RDS Proxy for AWS Lambda by Znafon on Wednesday December 04, 2019 @07:07PM (#21708558)
Why did you not use ECS with EC2 instead of patching HAProxy? With the Amazon AMI it is pretty straightforward.
Re:Amazon RDS Proxy for AWS Lambda by ocdnix on Thursday December 05, 2019 @07:16AM (#21711719)
If I were to do it again, I'd consider either that or building it directly on EC2, preparing the AMI with Packer or something, and handling scaling with an autoscaling group.
Re:Amazon RDS Proxy for AWS Lambda by arcticfox on Wednesday December 04, 2019 @06:49PM (#21708419)
As an aside, why isn't pgbouncer basically built into Postgres, at least as an option? I'm sure there's a good reason, but as a lay-user, pgbouncer seems to just do connections better than Postgres. It's just a pain to both with it when cloud databases are so easy to launch in comparison.
Re:Amazon RDS Proxy for AWS Lambda by paulryanrogers on Wednesday December 04, 2019 @07:03PM (#21708524)
Culture in Pg community once favored separate, single purpose solutions. This was the replication story for a long time. So here's hoping they'll build-in something to help with the high costs of individual connections.
Re:Amazon RDS Proxy for AWS Lambda by Znafon on Wednesday December 04, 2019 @07:05PM (#21708545)
Some work as started to have a built-in connection poller on January 2019 so it will probably be available in PostgreSQL someday.
Re:Amazon RDS Proxy for AWS Lambda by vpontis on Wednesday December 04, 2019 @04:51PM (#21707546)
This is really cool! I've had to do the same thing with PGBouncer for Postgres + serverless and it's a pain.

Would love to see this come out for Postgres and come to Google Cloud :)

Re:Amazon RDS Proxy for AWS Lambda by beering on Wednesday December 04, 2019 @04:54PM (#21707584)
TL;DR: AWS now has a managed connection pooling service for MySQL on RDS only (public preview right now). The article talks about using it in conjunction with Lambda.
Re:Amazon RDS Proxy for AWS Lambda by jakemal on Wednesday December 04, 2019 @06:57PM (#21708477)
It took me over half the article before I could parse "Amazon RDS Proxy for AWS Lambda" as a coherent sentence rather than a series of semi-related words strung together.
Re:Amazon RDS Proxy for AWS Lambda by dmahanta on Wednesday December 04, 2019 @05:05PM (#21707716)
hahaha JDBC as a service. We really needed this, what has the world come too.
Re:Amazon RDS Proxy for AWS Lambda by JonMR on Wednesday December 04, 2019 @08:23PM (#21709128)
You may already know all this, but I thought I’d add to what you said.

JDBC doesn’t provide connection pooling out of the box. There are connection pooling libraries that layer into JDBC. Most frameworks and application servers do bundle a connection pool out of the box.

Lambda is just a different paradigm than a single monolithic app with a connection pool. I assume that’s what you’re getting at. :)

There are other use cases though. Tools like pgBouncer are fairly useful in a large enterprise where a single database has multiple clients. They provide a single point to coordinate failovers and manage resource limits. I generally prefer a 1:1 relationship between an application and a database, but sometimes you have to play the cards you’re dealt.

Re:Amazon RDS Proxy for AWS Lambda by knodi on Wednesday December 04, 2019 @07:08PM (#21708566)
If you're doing this you're using lambda's wrong.
Re:Amazon RDS Proxy for AWS Lambda by turdnagel on Wednesday December 04, 2019 @07:32PM (#21708772)
Let me guess, you're a DynamoDB fan?
Re:Amazon RDS Proxy for AWS Lambda by revicon on Wednesday December 04, 2019 @11:00PM (#21709863)
What's the right way?
Re:Amazon RDS Proxy for AWS Lambda by PetahNZ on Thursday December 05, 2019 @01:00AM (#21710307)
Not sure the op's case, but typically it's better for queue processing.
Re:Amazon RDS Proxy for AWS Lambda by foo4u on Wednesday December 04, 2019 @09:48PM (#21709557)
The same functionality could have been accomplished by just allowing us to specify the max number of concurrent instances of a function that can be active at a time. With proper request queuing the problem would be solved. As usual, AWS solves a problem they failed to design for by charging for an overly complex solution. Flame me if you want but there are K8s serverless frameworks that address this out of the box.
Re:Amazon RDS Proxy for AWS Lambda by pavelrub on Thursday December 05, 2019 @07:10AM (#21711698)
Specifying the max number of concurrent lambda execution has been possible for years - it's called reserved concurrency.

This does nothing to solve the issue however. There are many use cases where you can't delay handling requests.