Monthly Archives: اسفند 1392

Why serving files with nodejs is faster than apache when I use a single mongodb connection? [closed]

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:

  1. Nodejs is slow on serving static files, nginx or apache are better options for this task.
  2. 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?

[NasserTorabzade] در میانه‌های راه، نقاش آنچه میکشید رو احمقانه یافت. میدونست که نباید ادامه‌ش بده. ازش دست کشید اما، طرح دیگه‌ای هم نداشت. شد نقاش ِ ایستاده.

ناصر تراب زاده @NasserTorabzade
در میانه‌های راه، نقاش آنچه میکشید رو احمقانه یافت. میدونست که نباید ادامه‌ش بده. ازش دست کشید اما، طرح دیگه‌ای هم نداشت. شد نقاش ِ ایستاده.