When I made a 20 or 30 requests in a minute, the computation time is fast for free tier Mongodb. But when I made 400 requests concurrently , then query time is very slow and impacts AWS lambda billed duration. In first scenario, lambda duration is only 500 ms ffor single api request average. On large traffic , lambda duration is 51000 ms for same api request . I consult with AWS expert and they mention its due to Mongodb and not from AWS lambda. How can I reduce query time for large traffic in Mongodb so that all requests executes in 500 ms (average). I have used motor as Mongodb driver.
Does shifting to Mongodb serverless solve this problem ?