node. JS vs PHP CLI Server simple HTTP server performance test

Source: Internet
Author: User
Environment: 64-bit ubuntu14.04,i5-3230m
PHP5.4.31 with Zendopcache
node. js 0.10.35

//t.js
var http = require (' http ');
Http.createserver (function (req, res) {
Res.writehead ($, {' Content-type ': ' Text/html;charset=utf-8 '});
Res.write (' <title>Node test</title>' +new Date (). GetTime () + '');
Res.end ();
}). Listen (8082, ' 127.0.0.1 ');

To run the program:
Node T.js
To view the system CPU idle rate:
SAR 1
Stress test, concurrent 100, complete 100,000 requests:
ab-c100-n100000 Http://127.0.0.1:8082/t.js
Memory from 11MB to 61MB, System CPU idle rate of 65%, RPS reaches 6049.

tip: Click on the image to see the original.






//t.php

<title>PHP test</title>

To run the program:
Php-s 127.0.0.1:8081-t./
To view the system CPU idle rate:
SAR 1
Stress test, concurrent 100, complete 100,000 requests:
ab-c100-n100000 http://127.0.0.1:8081/t.php
Memory from 19.6MB to 20.0MB, System CPU idle rate of 57%, RPS achieves 11405.






Conclusion: both node. js and PHP CLI server are single-process HTTP requests, with PHP almost twice times more than node. js on RPS, with memory occupied by PHP but only node. js 1/3. node. JS is commendable that the system CPU idle rate is about 8% higher than PHP. In addition, although the HTTP protocol is not supported by PHP-FPM, its performance in handling PHP requests is no worse than PHP CLI server, and PHP-FPM can open multiple worker processes and take full advantage of multicore.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.