Replies: 3 comments 3 replies
-
thanks @dvd3v 🙏 I'll go through your post later but for now this might be of interest stac-utils/stac-fastapi#493 basically mangum will execute start/shutdown on each request while we want it to only be done on Lambda lifecycle 😭 |
Beta Was this translation helpful? Give feedback.
-
A couple RDS Proxy tips that I've learned the hard way:
And client side there are a few things that help too:
The most important thing for performance is reusing the connection pool across lambda invocations. Keep in mind that although lambdas are accessing the database through RDS Proxy the client code (asyncpg) still has to manage its own connections to the proxy. RDS proxy loses a lot of its value if clients aren't reusing connections to some extent. |
Beta Was this translation helpful? Give feedback.
-
Thanks @vincentsarago and @geospatial-jeff, this is super helpful! 🙏 Good to understand why connections are not cached due to the Mangum bug. This also explains why RDS proxy was still opening a lot of connections. Although I'm running a dedicated TiMVT RDS, a t3 instances was indeed very easy to overload. The Aurora cluster performs much better, especially with Until there is a proper way to cache the database pool across Lambda invocations I'm going to change the RDS proxy settings to aggressively drop idle connections using the |
Beta Was this translation helpful? Give feedback.
-
I really love the TiTiler + AWS Lambda setup for its simplicity and scalability. I'm trying to do the same for TiMVT, however due to the database connections there are few more challenges. TiMVT does not seem to be written to work in a serverless setup out of the box as;
As for the registering of the table catalog I've moved it to the LayerParams dependency. As we have access to the
request
parameters inside the LayerParams, we can only registers the schema and table name that is requested;This mitigates the need for registering the whole DB on each invocation and then subsetting the table that is needed. Although I'm not sure if this is the best method. Happy for suggestions.
As for the database connections, the TiMVT Lambda functions can scale easily and create many concurrent connections, meaning the database needs more resources to maintain connections instead of executing queries at some point. I could easily overload the database with a (complex) dataset.
To try and solve this I've fronted the Aurora Serverless V2 database with an RDS proxy.
The Lambda functions now interact with RDS Proxy instead of the database instance and the proxy handles the connection pooling necessary for scaling many simultaneous connections. This allows the TiMVT Lambdas to reuse existing connections, rather than creating new connections for every function invocation. Although I still get quite a few connections on the database, it performs much better than without a proxy.
Interested to hear the opinion on this architecture and what I could do better. Also wondering if TiPG will already have solved these issues.
Happy to share my serverless deployment templates for this setup if anyone is interested!
ps @vincentsarago awesome talk at PostGIS day!
Beta Was this translation helpful? Give feedback.
All reactions