My first Stackoverflow question: I have a webshop where users can search for products. I am using Angular, NodeJS (express) and MongoDB. Infrastructure is this: Front-end on some norwegian hosting service. Backend Heroku (server.js) MongoDB on MongoDB.com
The webpage only does read operations towards the database, there is no write, delete, modify operations, and the user does not have to sign in. What I have noticed is that when the user opens the page for the first time, the first query take some time, around 4sec (connection is being established, I checked in Postman, times goes to "Transfer Start"). After that everything runs smood (response time less than 1 sec.). I also see that there is a new connection for each different user. Since the backend is running on heroku, connecting to mongodb with a specific user (in connection string), my assumtion is that it should be possible to re-use this connection for all users of the webpage, by keeping the connection alive. Is my assumption right? The reason for the current infrastructure / setup is that I wanted to learn some new stuff while creating the page.
Summary: Webpage -> Api call -> Heroku (server.js) -> query (Mongo.com)