Node.js的单线程模型有点傻
Node.js的单线程模型有点傻
By lincanbin
at 2018-06-22
0人收藏 • 2288人看过
var http = require('http');
function fibonacci(n) {
if(n === 0 || n === 1)
return n;
return fibonacci(n-1) + fibonacci(n-2);
}
http.createServer(function (request, response) {
console.log('收到一个request');
fibonacci(10000);
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(1234);
console.log('Server running at http://127.0.0.1:1234/');真的是一点CPU密集的工作都不能接啊。
- 登录后方可回帖
3 个回复 | 最后更新于 2018-06-25
回复#2 @学神之女 :
不是这个问题,是有CPU密集型工作时,会阻塞进程导致后面无法再接收新请求。