3 ms·
I actually ran into an issue recently with CPU intensive tasks blocking my web server. It turns out that "querystring" (used to parse request bodies in web appl
by cddotdotslash 11y ago
I actually ran into an issue recently with CPU intensive tasks blocking my web server. It turns out that "querystring" (used to parse request bodies in web applications) is an asynchronous, blocking request. You'd never notice much slowness, until your request bodies are massive (think 50 nested JSON objects and some base64 image data for good measure) and you have multiple per second. Now, every request is blocked until the previous one is processed. I'm still trying to figure out a solution, after looking into worker threads, etc.
- spion 11y agoI always use the following replacements written by petkaanotonov, the author of bluebird :) https://www.npmjs.com/package/querystringparser https://www.npmjs.com/package/querystringparser for query string parsing. Depending on content, you may get massive improvements (5x-20x) https://www.npmjs.com/package/fast-url-parser https://www.npmjs.com/package/fast-url-parser for url parsing (the built in url parser is the main reason why node is so far behind on the TechEmpower benchmark - with this replacement the benchmark shows about 60-80% improvement in served req/s) https://www.npmjs.com/package/cookieparser https://www.npmjs.com/package/cookieparser For very large post bodies, I use JSON in conjunction with OboeJS - http://oboejs.com/ http://oboejs.com/ . Its not too much slower than native JSON.parse (about 5-7 times) however its non-blocking. Still haven't found a solution that is close enough in speed to native JSON.parse
- cddotdotslash 11y agoThese look promising, thanks!
- kapv89 11y agoThis comment in itself is probably more valuable than the OP