Replies: 3 comments 3 replies
-
Can you give any more details on how you have eoAPI configured / deployed? By default, Postgres is not going to handle large numbers of connections well at all - which is particularly an issue when you are dealing with Lambda. When using Lambda, you should make sure the database configuration for stac-fastapi and tipg are set to only use a single connection - with Lambda, there is no benefit to pooling. You should definitely look at your database settings, particularly MAX_CONNECTIONS, SHARED_BUFFERS, and WORK_MEM. You are definitely not going to be able to have more Lambdas than the MAX_CONNECTIONS setting without using a separate pooler. You should also make sure that MAX_CONNECTIONS * WORK_MEM is less than what you have set for SHARED_BUFFERS. If you need more connections than allows that to happen (generally SHARED_BUFFERS should be about 1/4 of the total system memory), you may want to consider bumping up database instance sizes. It can definitely be a good idea to put a connection pooler between the Lambdas and the database. I have not worked much with RDS Proxy, so I am not entirely sure if everything works with that, but pgBouncer definitely works well. |
Beta Was this translation helpful? Give feedback.
-
@bitner thank you so much for your advice!
I have two eoAPI deployments (production and staging), I used the default settings for everything when I deployed it using the AWS CDK app. They are both running pgstac==0.7.10. This week I have been experimenting with RDS Proxy in my staging deployment to see if that can help control the proliferation of connections.
The raster, stac, and vector services are all running as Lambda functions with the default
Out of the box, the RDS db.t3.medium (2 vCPU, 4GB RAM) is configured like this:
Indeed, I have definitely not tried sending 403 simultaneous connections to the STAC endpoint (probably 40 at most), but when I watch the CloudWatch metrics, the freeable memory drops down to zero and the cpu utilization gets maxed out despite not being close to the MAX_CONNECTIONS limit. During my testing today I tried upgrading the DB instance to a t3.2xlarge (8 vCPU, 32GB) just to see what would happen and so far it has handled 16 concurrent queries without a problem. Maybe that's a reasonable solution, but I still wonder why the smaller database instance can't keep up!
I tried adding an RDS Proxy to the eoAPI CDK stack today and it did not solve my particular problem, but I think that is because I am not even close to approaching the MAX_CONNECTIONS threshold with my usage. |
Beta Was this translation helpful? Give feedback.
-
@ranchodeluxe @bitner @sunu @ividito @vincentsarago ; Is database parameter configuration something we could factor into https://github.com/developmentseed/eoapi-cdk, https://github.com/developmentseed/eoapi-k8s, and maybe future work on SAM deployment? |
Beta Was this translation helpful? Give feedback.
-
I have been using eoAPI to serve my organization's STAC API for several months and everything has been working pretty well! However, when we have tried running workflows that make more than ~8 concurrent requests to the STAC API endpoint, the service fails.
Here is the python script that I am using to test the concurrent requests:
This runs fine on four cores, but if I increase it beyond that I get this error:
The STAC Lambda function logs show that the function hits the timeout (20 seconds) but doesn't show a specific error (that I can find so far). I tried increasing the timeout to 60 seconds but am still running into the same issue.
The Postges database logs show messages like this:
Are there any configuration tweaks I might make to handle concurrent requests better?
The Postgres logs suggest that the query
SELECT * from all_collections()
is causing the error. Could there be something wrong with my collection-level metadata that is causing this query to be really heavy?Any suggestions you have for configuring the eoapi stack for higher traffic would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions