Use SWR on Vercel with MongoDB : high number of connections #980
Unanswered
ErnestBrandi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've just deployed on Vercel the example code using Mongodb with Mongoose : https://github.com/vercel/next.js/tree/canary/examples/with-mongodb-mongoose
On the index page, I have substituted the
getServerSideProps
call for auseSWR
hook.With that one API call only, I was able to reached a number of 35 opened connections on my MongoDB Atlas cluster... (it was 4 with the use of
getServerSideProps
).Is there any way I can reduce that number ? I guess setting flags like
revalidateOnFocus
tofalse
would reduce the number of calls but that's not what I consider a good solution.I have read many threads about the subject, but none of them deal with the use of SWR.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions