I have an website which is set up to use a MongoDB instance on compose.io. Everything is working ok, except for that my connection to compose.io and mongoDB takes about 1.2 seconds to connect. In my opinion this is quite slow, especially when several queries are fired on the database.
What would be viable tactics to increase the connection speed, or other tactics like caching to speed up the web app? Or would a setup with mongoDB installed on the server be a better solution?
I am using mongoclient on 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');