Hi guys i need urgent help. My app has around 1000 to 2000 searches (normal read write operations) in 1 minute.
Now i am using flutter as the app framework and nodejs + express as backend api server which is deployed on Railway.app paid plan.
Now when i use the client.connect method in each file (get_users.js, get_data.js etc) the app is slow and sometimes when req comes and code tries client.connect it gives error as:
MongoTopologyClosedError: Topology is closed OR attempted to check out a connection from closed connection pool.
So i read on many places to use one connection and return this in every file and we dont use client.close too and it is fast too.
So i used one connection in app.listen but now my memory and cpu spikes to 2gb (and crashes) after few seconds only. whereas it never spike when i use client.connect in each file but gets connection error in this method. Whats going on?