1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
0
The duration of each function invocation should not be affected by the number of total invocations, unless the function itself is using some other service, e.g., a database, that can't handle the load and takes longer to respond, and therefore making the total function duration higher. Could it be that that is your situation?
To analyze where the higher duration is coming from I would recommend to use X-Ray.
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata un anno fa
I have used MongoDb where max pool limit is 500 . There was db connection max pool reached issue during execution. Does limiting lambda timeout to 2 sec solve the problem since all requests are of 500 ms in normal traffic?
For every request , new db connection is initiated. Can we use already connected database to other requests? I have used mangum python package for handler
You should create your connection to the database outside the function handler so that a single connection will be used for all invocations of the function in the same execution environment (an execution environment handles a single request at a time as is reused by subsequent invocations). Do not close the connection. The connection will be closed automatically by the database after the execution environment will be destroyed.
Limiting the function to 2 seconds might be problematic if it takes MongoDB to answer more than 2 seconds.
You should not use a connection pool inside Lambda Lambda function has no shared memory between different execution environments, so a pool will not help.