Connecting to a remote mongodb is pretty slow

I have a website that is configured to use a MongoDB instance on compose.io. Everything works fine, except that my connection with compose.io and mongoDB takes about 1.2 seconds to connect. In my opinion, this is pretty slow, especially when multiple queries are running in the database.

What could be a viable tactic to increase connection speed or other tactics such as caching to speed up a web application? Or would it be better to configure the solution with mongoDB on the server?

I am using mongoclient in php to connect to mongoDB on compose.io. I use the following code to connect:

new MongoClient('mongodb://username:password@candidate.6.mongolayer.com:10554,candidate.5.mongolayer.com:10690/database?replicaSet=set-xxxxxxxx');
+4
source share

Source: https://habr.com/ru/post/1607084/


All Articles