After mongodb serverless does not query data for a period of time, it takes 1 minute for the next query to return data

I am using mongodb atlas serverless product. I found that when I was developing locally, if I did not request the database to fetch data for a period of time (such as 10 minutes), the next request to query the database will take a very long time, up to It takes 60~70s to return data.
It feels like the connection to the database was unilaterally closed by you When no data is queried for a period of time. because that The same code, I tried your free version (shared), it is normal, there is no request for more than 10 minutes, the query data can be returned quickly.
This problem can be reproduced on nestjs/mongoose and mongodb.

This problem can be reproduced on nestjs/mongoose and mongo shell.

Hi @zeling_guo - Welcome the community.

This problem can be reproduced on nestjs/mongoose and mongo shell.

Would you be able to detail the exact steps on how to reproduce this issue via mongosh? I will attempt these against on my own serverless environment.


first, i exec ‘mongosh “mongodb+srv://” --apiVersion 1 --username bt’ ,Then I try to query the data, which is normal (eg: db.users.find({})).
Wait for 10 minutes and execute the query statement again. There will be a problem here. It often takes 1 minute to return the result, and sometimes it is directly stuck and nothing is returned.

Hi @zeling_guo - Sorry for the delay.

I wasn’t able to reproduce this issue. I tried a few things:

  1. Performed a .find().
  2. Waited 5,10,15,30 minutes.
  3. Repeated steps 1 and 2 two more times with mongosh once more and MongoDB Compass.

All time periods noted in 2. did not produce a delayed response. However, I did on one occasion get a “connection closed” error but was not able to reproduce this again in future.

One thing I did note that was different was the MongoDB version in use (my testing was done using 6.0.1). I was not able to test using 6.0.0 noted in your screenshot.