Salam (means Hello) :)
I'm trying to improve speed of my nodejs website which depends on some mongodb operations and serving some static files. I'm using node-mongodb-native driver. as far as I know:
- Nodejs is slow on serving static files, nginx or apache are better options for this task.
- Caching a single db object and using it during application run time, is faster than calling
MongoClient.connect()for every database operation.
nginx is not currently an option for me. So using a single db connection along side using apache for static files should be fastest combination, but tests on a semi-production environment don't verify this theory:
file server / db connection : speed nodejs / multiple : 24895ms apache / multiple : 10770ms nodejs / single : 7068ms apache / single : 14995ms
So why when using multiple connections, apache makes my application load faster, and when using a single connection, apache makes my application load slower?