【发布时间】:2016-05-06 00:27:35
【问题描述】:
我对 nodejs 知之甚少。我所知道的是,它适用于单线程模型,该模型为I/O 任务切换到多个线程。例如,
Request A ----> nodejs (Single Thread)
// Finds out that it the requires requires I/O operation
nodejs ----> underlying OS (Starts An Independent Thread)
// nodejs is free to serve more requests
这是否意味着对于1000 concurrent requests,在处理完所有999 请求后会有一个请求被处理?如果是,这似乎是一个低效的系统!我将运行php 称为apache 更适合(在上述情况下)。带有 PHP 的 Apache 保持启动 1000 并发线程的能力,因此没有处理队列和零等待时间。
我可能在这里遗漏了一个重要概念,但这真的是 nodejs 的工作方式吗?
【问题讨论】:
标签: php node.js multithreading asynchronous concurrency