سؤال

I just traced my nodejs server's performance by using: siege -b -t10s -q http://mynodejsserver

I found that when there was no "url.parse(req.url)"

Transaction rate was about 4300 trans/sec

but when i used url.parse, transaction rate was about 3600-3700 trans/sec

The other code is the same.

I tried them many times, and the result was stable.

Does the url.parse really have the performance problem?

هل كانت مفيدة؟

المحلول

YES

Yes, in the techempower benchmarks node.js went from 20k/s to 30k/s when removing url.parse.

The implementation is very slow like most node.js modules (I have rewritten 3x-75x speed improvements on several "de facto standard" node modules, just check my github profile).

I have actually planned a url.parse rewrite too. But yes, if you can avoid it then you should avoid it.


Update

This fixes the performance problem: https://npmjs.org/package/fast-url-parser . It has exactly same api and semantics but it is 25-30x faster and would not affect the transaction rate at all in your example.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top