hi-nginx-javascript vs node.js
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
hi-nginx-javascript vs node.js的更多相关文章
- 京JS 2013 - A two-day conference in Beijing for the JavaScript and Node.js community
京JS 2013 - A two-day conference in Beijing for the JavaScript and Node.js community 关于技术大会 京JS 2013 ...
- 创业笔记-Node.js入门之JavaScript与Node.js
JavaScript与Node.js JavaScript与你 抛开技术,我们先来聊聊你以及你和JavaScript的关系.本章的主要目的是想让你看看,对你而言是否有必要继续阅读后续章节的内容. 如果 ...
- JavaScript(Node.js)+ Selenium 实现淘宝抢单
JavaScript(Node.js)+ Selenium 淘宝抢单 为了买买买我也是拼了,看了一点selenium的资料,随便写的. 程序写的比较烂,但是够我自己用了,望各路大牛指教. 使用说明: ...
- 基于Debian系统配置Nginx环境的Node.js应用教程
Node.js,是当前比较流行的能够动态的快速响应内容的JavaScript框架,在有些环境下比我们使用的PHP应用都能够提高效率.目 前,Node.js可以与我们常用的Nginx.Apache等服务 ...
- JavaScript(Node.js)+ Selenium自动化测试
Selenium is a browser automation library. Most often used for testing web-applications, Selenium may ...
- nginx反向代理node.js获取客户端IP
使用Nginx做node.js程序的反向代理,会有这么一个问题:在程序中获取的客户端IP永远是127.0.0.1 如果想要拿到真实的客户端IP改怎么办呢? 一.首先配置Nginx的反向代理 proxy ...
- 安装Nginx并为node.js设置反向代理
最近看了反向代理和正向代理的东西,想到自己的node.js服务器是运行在3333端口的,也没有为他设置反向代理,node.js项目的一些静态文件是完全可以部署在Nginx上,以减少对node.js的请 ...
- 在nginx里面部署node.js本地服务器
我一个前端,为啥要搞服务器呢?因为公司就招了一个后端啊,后端忙不过来,就叫我这个萌新前端去搞后端的东西,我太难了. 直接进入正题吧,因为公司需求,要我在nginx服务器上面搭一个node.js服务器, ...
- javaScript 和 node.js 的一些文章收集
这里收集了一些文章的链接,方便自己查询翻看,也避免把别人的成果复制过来再发布,节约时间. ThinkJS 3 正式版发布 我来回答饿了么大前端的问题(1) 一起理解 Virtual DOM 探讨Nod ...
- 用Nginx反向代理Node.js
安装pm2 npm install pm2 -g ln -s /home/download/node-v8.11.1-linux-x64/lib/node_modules/pm2/bin/pm2 /u ...
随机推荐
- React native开发中常见的错误
react native环境搭建请移步:react native环境搭建 这里说说react native创建完成之后,运行中出现的常见问题, 问题1: java.lang.RuntimeExcept ...
- Java之美[从菜鸟到高手演变]之设计模式二
在阅读过程中有任何问题,请及时联系:egg. 邮箱:xtfggef@gmail.com 微博:http://weibo.com/xtfggef 如有转载,请说明出处:http://blog.csdn. ...
- SpriteBuilder中如何固定两个互不接触的物理物体?
如下图: 这个弹簧装置由3部分组成(从上到下): 弹板 弹簧 弹簧金属底座 其中弹板将固定在弹簧上(但并没有接触,如上图),这就引出一个有趣的问题:怎么样才能将两个独立的物理物体(注意:是物理物体)固 ...
- 轻量级网络库libevent概况
Libevent is a library for writing fast portable nonblocking IO. libevent是一个为编写快速可移植的非阻塞IO程序而设计的. lib ...
- RTMPdump(libRTMP) 源代码分析 9: 接收消息(Message)(接收视音频数据)
===================================================== RTMPdump(libRTMP) 源代码分析系列文章: RTMPdump 源代码分析 1: ...
- Linux变量内容的删除、取代与替换
变量内容的删除与取代 范例一:先让小写的 path 自定义变量配置的与 PATH 内容相同 [root@www ~]# path=${PATH} [root@www ~]# echo $path /u ...
- OpenCV——老照片效果
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- PS 图像特效-非线性滤波器
利用非线性滤波器,使图像的色彩凝块,形成一种近似融化的特效. clc; clear all; addpath('E:\PhotoShop Algortihm\Image Processing\PS A ...
- 网络最短路径Dijkstra算法
最近在学习算法,看到有人写过的这样一个算法,我决定摘抄过来作为我的学习笔记: <span style="font-size:18px;">/* * File: shor ...
- Leetcode(59)-Count Primes
题目: Description: Count the number of prime numbers less than a non-negative number, n. 思路: 题意:求小于给定非 ...