hi-nginx-javascript vs node.js
2018-06-18 01:09:53来源:未知 阅读 ()
hi-nginx-1.4.9已经支持javascript,这意味着把javascript应用于后端开发,将不再只有nodejs这唯一的途径和方法。由于java本身对javascript的极好支持,使得在hi-nginx中,可以直接在javascript脚本中使用java——相当于把java嵌入了javascript。因此,你随时可以用java写个库或者类,然后在javascript中随便玩。这比用c/c++写node.js扩展舒服多了。
那么,hi-nginx-javascript VS node.js,如何呢?来个node.js (6.12.0)helloworld比较下。
fedora 25,4g,2core,i5,笔记本
node.js:
var http = require('http'); http.createServer(function (request, response) { // 发送 HTTP 头部 // HTTP 状态值: 200 : OK // 内容类型: text/plain response.writeHead(200, {'Content-Type': 'text/plain'}); // 发送响应数据 "Hello World" response.end('Hello World'); }).listen(8888); // 终端打印如下信息 console.log('Server running at http://127.0.0.1:8888/');
hi-nginx-javascript:
location / { hi_need_cache off; hi_cache_expires 5s; hi_need_kvdb on; hi_kvdb_size 10; hi_kvdb_expires 5s; hi_need_cookies on; hi_need_headers on; hi_need_session on; hi_session_expires 300s; hi_javascript_lang javascript; hi_javascript_extension js; #hi_javascript_script javascript/index.js; hi_javascript_content "hi_res.content='hello,world';hi_res.status=200;"; }
使用ab作为压力测试工具:ab -c 1000 -n 500000。从最终稳定结果RPS来看,n=500000对nodejs来说是越不过去,
Completed 50000 requests Completed 100000 requests Completed 150000 requests apr_socket_recv: Connection reset by peer (104) Total of 162214 requests completed
而hi-nginx-javascript均值在14000多左右:
Server Software: nginx/1.14.0 Server Hostname: 127.0.0.1 Server Port: 8086 Document Path: / Document Length: 11 bytes Concurrency Level: 1000 Time taken for tests: 34.366 seconds Complete requests: 500000 Failed requests: 0 Total transferred: 139000000 bytes HTML transferred: 5500000 bytes Requests per second: 14549.43 [#/sec] (mean) Time per request: 68.731 [ms] (mean) Time per request: 0.069 [ms] (mean, across all concurrent requests) Transfer rate: 3949.94 [Kbytes/sec] received
把n降低至100000,nodejs偶尔能完成测试,RPS的最好成绩是8900多,其值在6000至9000间徘徊:
Server Software: Server Hostname: 127.0.0.1 Server Port: 8888 Document Path: / Document Length: 11 bytes Concurrency Level: 1000 Time taken for tests: 11.114 seconds Complete requests: 100000 Failed requests: 0 Total transferred: 11200000 bytes HTML transferred: 1100000 bytes Requests per second: 8997.62 [#/sec] (mean) Time per request: 111.141 [ms] (mean) Time per request: 0.111 [ms] (mean, across all concurrent requests) Transfer rate: 984.11 [Kbytes/sec] received
而hi-nginx-javascript则依然表现出众,与n=500000是差不多:
Server Software: nginx/1.14.0 Server Hostname: 127.0.0.1 Server Port: 8086 Document Path: / Document Length: 11 bytes Concurrency Level: 1000 Time taken for tests: 7.038 seconds Complete requests: 100000 Failed requests: 0 Total transferred: 27800000 bytes HTML transferred: 1100000 bytes Requests per second: 14208.52 [#/sec] (mean) Time per request: 70.380 [ms] (mean) Time per request: 0.070 [ms] (mean, across all concurrent requests) Transfer rate: 3857.39 [Kbytes/sec] received
结论:
hi-nginx-javascript 完胜 nodejs。
hi-nginx github: https://github.com/webcpp/hi-nginx
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:Java多线程--锁的优化
- 构造函数中的this()和super() 2020-06-10
- Java框架之Hibernate实战篇 2020-06-09
- Hibernate --主键生成策略 2020-05-24
- 技术大佬:我去,你竟然还不会用 this 关键字 2020-05-24
- 如何用Spring Boot整合Shiro+JWT?这里教大家一最最简单的方 2020-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash