node.js学习简介
来源:互联网 发布:网络教育统考查询 编辑:程序博客网 时间:2024/05/21 09:45
什么是node.js
编写高性能网络服务器的JavaScript工具包(用js开发服务端程序)
单线程(轮询) 异步 事件驱动
特点:快 耗内存多
异步消耗内存测试:网上一个百万级并发测试,未优化的情况下1M的连接消耗了16G的内存
Node.js vs php
优点:性能高(机制问题) 开发效率高(省不少优化的事) 应用范围广(可以开发桌面系统、electron框架)
缺点:新、人少 中间件少 IDE不完善orm
Node.js的劣势和解决方案
默认不支持多核,但用cluster可以解决
默认不支持服务器集群,node-http-proxy可以解决
使用nginx做负载均衡,静态的由nginx处理,动态的由node.js处理
Forever或node-cluster实现灾难恢复
框架选择
比较热门的:express、kos、Hapi以及express基础上的sails
express:完善、稳定、文档全、社区大
koa:超前、正在完善中
Hapi:复杂(一个简单的hello,world都要做很多堆砌)适合复杂的大型项目
学习路径
node.js基础
express框架
sails框架
项目:sails+vue.js sails+react
编辑器(IDE):
记事本(Editplus)
Webstorm
Atom或sublime
多看文档
摸索测试
Hello,world
var http = require('http');//导入httphttp.createServer(function(request,response){//创建一个服务 请求、响应response.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});//http协议头,编码格式if(request.url!="/favicon.ico"){//清除第二次访问console.log('访问');response.write('hello,world');//书写内容response.end('你好,世界');//不写没有http协议尾,写了会有2次访问}}).listen(8000);//监听8000端口console.log('Server running at http://192.168.0.1:8000');
阅读全文
0 0
- node.js学习简介
- Node.js学习笔记(1、简介)
- Node.js简介
- Node.js 简介
- Node.js简介url
- Node.js 入门简介
- Node.js简介
- Node.js简介
- Node.js简介
- node.js简介
- Node.js简介
- Node.js简介
- Node.js简介
- node.js简介
- Node.js简介
- Node.js简介
- Node.js入门简介
- Node.js简介
- linux上的tomcat8.5通过账号密码登录查看
- 51nod 1081 子段求和
- 指针函数和函数指针
- python学习笔记4—可变参数和关键字参数
- shader实例(四)物体描边【自发光】
- node.js学习简介
- PHP 函数
- D
- JS中常用Math对象常用方法的整理
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: It is not a Java .class file 的解决方法
- Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupLis
- React Native
- 树状数组模板
- 04 模块 Prism For WPF