javascript 使用 NodeJS 代替 PHP 的缺点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9107268/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disadvantages of using NodeJS instead of PHP
提问by Kory Hodgson
I am thinking of using NodeJS for my website instead of my current PHP + Apache setup. Are there any major disadvatanges/advantages to making this switch?
我正在考虑在我的网站上使用 NodeJS,而不是我当前的 PHP + Apache 设置。进行此转换有什么主要缺点/优点吗?
My site will get lots of small requests and occasional requests that require lots of calculations on the server side.
我的网站会收到很多小请求和偶尔需要在服务器端进行大量计算的请求。
I have a server that I can install anything I want on, so hosting is not a factor in this decision. Although I would like to maximize performance while minimizing memory and processing requirements.
我有一台可以安装任何我想要的东西的服务器,所以托管不是这个决定的一个因素。虽然我想在最大限度地减少内存和处理要求的同时最大限度地提高性能。
I guess my main question is, when is NodeJS an appropriate solution for a website?
我想我的主要问题是,NodeJS 什么时候是网站的合适解决方案?
回答by Ignacio Vazquez-Abrams
- You can't use any of the pre-existing PHP applications and libraries.
- You'll need to learn about event-driven programming.
- 您不能使用任何预先存在的 PHP 应用程序和库。
- 您需要了解事件驱动编程。
Although those may not always be considered disadvantages per se.
尽管这些本身并不总是被认为是缺点。
回答by Ignacio Vazquez-Abrams
PHP is not going to disappear immediately, but its positions are undermined even further by the nascent Node.js.
Node.js is functionally similar to the PHP + Apache or ASP + IIS stacks.
And there are 2 main advantages:
Speed! (Performance)
Node.js is event-driven and non-blocking and very good at handling concurrent requests.
Here is a linkto a benchmarking test for node.js against PHP on Apache.
PHP 不会立即消失,但新生的 Node.js 进一步削弱了它的地位。
Node.js 在功能上类似于 PHP + Apache 或 ASP + IIS 堆栈。
并且有两个主要优点:
速度!(性能)
Node.js 是事件驱动和非阻塞的,非常擅长处理并发请求。
这是针对 Apache 上的 PHP 的 node.js 基准测试的链接。