What optimizations for not hitting connection limit in serverless functions?

I could potentially use webhooks in Realm and then call them from my lambda functions yes, but that would require me to refactor almost every lambda function to call a webhook. Furthermore I would need to either create webhooks specifically for the intended usecase, or make general webhooks for quering/inserting/updating that could be reused by multiple lambda’s.

If I do the above, then would it decrease my performance in query time?

I have tried to fetch a large collection of documents (like scan) and that took 4 seconds.
But i’m trying with a real case where I have a lambda that gets all documents from a collection - there is only 2 documents and with 5 properties each / very small documents - and that takes around 400 ms.

The same query directly with the normal mongodb driver takes 24 ms.

So i’m wondering if I have setup something wrong with my Realm? Or is that just a penalty of using Realm where data needs to go over HTTP?