ڻ ҳ ѧԺ Լ

ΪʲôҪʹNode.js?

2017-7-27 09:23| Ͷ: lofor |:

ժҪ: JavaScriptи仯WebòҲ˾޴ĸı䡣JavaScriptϣڷϣFlashJava AppletsװɳлУڼǰǺ ...

JavaScriptи仯WebòҲ˾޴ĸı䡣JavaScriptϣڷϣFlashJava AppletsװɳлУڼǰǺġ

Node.js֮ǰҲ֪ʹJavaScript缼ջƣͳһԺݸʽJSONʹŻԴʹáЩNode.jsJavaScriptļջиȷЩDz̫࣬㽫Node.js뵽ջԵơ

άٿNode.jsGoogle V8棬libuvΪƽ̨㣬JavaScriptдĺĿװġˣֵעNode.jsRyan DahlĿǹһʵʱվGmailӦáNode.jsУṩ߹¼I/Oģ͡

˵Node.jsʹWebSocketͼʵʱwebӦдʡΪʲô޴ĸı䣿ھ20״̬ӦģУʵʱȫ˫ͨŵWebӦãͷԳʼӣɵĽݡʹͳĻڿͻ˳ʼӵWebӦģʽԵĶԱȡǶǻWebջHtml, CSS, JS80˿ϡ

Ҳ˵ѾFlashJava AppletsʽʹùܶˡʵֻɳлͨWebЭ鷢͵ͻˣǹڷDZ׼˿ڣܻȨ⡣

ΪЩŵ㣬Node.jsԼĴ˾ļջŹؼԵĽɫNode.jsʵҵΪʲôӦÿʹNode.jsһƪҵ

ƪУҲЩѾʵֵŵ㣬һЩWebӦģͣΪʲôҪʹNode.jsԼΪʲôҪʹNode.js

?

Node.jsҪص㣺ʹ÷¼I/OģʹЧܹܼ͡ʵʱĿƽ̨Ӧá˵Node.jsһWeb෴һƽ̨ЩDZҪģҪʹNode.jsCPUܼҵôˣǰ˵Node.jsŵ㶼ڡNode.jsʺϵǹٵġչӦãܹʤξIJӡ

ʹͳWebȣÿһµ̣߳ϵͳΪÿ̷߳ڴ棬Ϊڴ治͸֧Node.jsڵ̣߳ʹ÷I/OãܹIJӡǺܿóһۣÿһ߳ϵͳΪ2Mڴ棬һ̨8Gڴϵͳ󲢷4000Michael Abernethy¡Just what is Node.js?2011IBM developerWorksҵڲĶˣ߳лĻѣʹôͳWebijNode.jsʵֵĿչԶԶ

Ȼпͻʹͬһ߳ģNode.jsӦõһDZ塣ȣļֱ߳ɡڶһҪעⲻҪ쳣ðݵӦöʹNode.js

쳣ðݵ򶥲ԽصIJʹЩδ쳣ܹNode.jṣɱҪıʵָǰûsessionûа취ָģʹõĹ߾foreverⲿϵͳߣҲֱ

NPM: Node

Node.jsʱҪ˽һNPMNode.jsĹߣװNode.jsʱͻĬϰװNPM˼RubyGemʮƣһɹġõ⣬ֿ߲ͨɰװܹа汾

һЩNPMNPMҵǣʹNPMйصNode.jsĿNPMһ̬ϵͳκ˿ԷԼNPMģ飬NPMҵBeginners Guideҵһݼ飬һݿNPMָNPMָ.

ǾõһЩNPM:

  • express - Express.jsһSinatraNode.jsWebܣǽ󲿷Node.jsӦóʵϵı׼

  • koa - ExpressͬһߣмƵWebܣExpress

  • socket.io - Node.jsʵʱӦõĿܡ

  • request - һHTTPͻ󹤾ߡ

  • async - asyncһJavaScript첽Ĺ߿⡣

  • bluebird - bluebirdʵPromise/A+淶һܷdzõPromise߿.

  • lodash and underscore and Ramda -JavaSciprtչ⣬ṩ˷ḻķ

  • debug - õĵԹߡ

  • forever and nodemon - õĽػߣᵽڿģʽ±Ľ̡

Node.jsʵֵӦ

ǵ͵ʵʱûӦáڵʱIRCͨרкͿŵЭڲ׼Ķ˿ϣNode.js£ǿڱ׼80˿ϣʵЩӦá

˵ӦNode.jsŵõӣӦܼͣʹʱ̣һתնˡҲѧϰNode.jsѵӣ˴һ͵Node.jsӦõģʽ

һιġ

򵥵ӣǵվֻһ췿䣬õûһԶʽϢǵķѾӵû

ڷˣһ򵥵Express.jsӦãʵܣ1.Ŀ¼ʱһϢ壬Ϣİťҳ2.һwebsocket񣬼Ϣ͸ͻˡ

ڿͻˣһ¼ҳ棬һͰť¼ȡеϢͨwebsocket͵ˣһ¼websocketͻϢϢԴûת췿ûҿͻʾϢ

һûϢᾭ¼

  1. ͰťJavaScript¼лȡϢݣwebsocketϢ

  2. webSocketյϢͨʹbroadcastһתӵû

  3. ûͨͻwebsocketյԷ˵Ϣͻ˽õϢ׷ӵҳϢʵλá

򵥵ˣӽ׳ʹRedisĸٻ棬߸߼һ㣬Ϣдͻ˵ϢַҽǿӻƣٽʱӵʧΪѾעûϢǷʵЩܣNode.jsĹǴ¼Ͳӣұ֤ûԡ

ǹϵݿݽӿ

Node.jsʵʱӦĺܳɫͷdzʺϴӷǹϵݿȡݡNode.jsʹJSON洢ݣ迹ʧ䣬Ҫת

ٸӣʹRailsὫJSONתΪݣȻͨHttpЭ鷢͵ҪתΪJSONʽܱBackbone.jsAngular.jsȿܻͨAjaxáʹNode.jsͨREST APIJSONʹá⣬ҲҪڶдݿ⣨MongoDBʱᷢת֮Բڿͻˡݿʹͳһлʽ

Ӧи߲ݣݿΪӦõƿᵽNode.jsɵش߲ӣݿȴIJ£Ǿ鷳ˡǣȽܿͻ˵󣬲ؽȻдݿС

ʹַϵͳڸ߸ص±֤Ӧڿͻ˲ҪȷǷݴ洢ɹ¡͵Ӿǣ־߼¼ûΪݣδҲʹõҪӦFacebookµݣʹNoSQLǿеġ

ͨijֻϢУ磺RabbitMQZeroMQ)Ŷӣȴݿд߳д룬߼ܼ͵ĺ˷дƵΪͨԻ߿ʵ֣ͬӲ£Node.jsָܱߵ

ڴͳWebƽ̨HTTPӦ¼ԴʵǶʵNode.jsùһЩܿԣ磺ǿļϴоͽдʽǿߴʵʱƵı룬ڲͬԴ֮

Node.js״һ˴ԷķʽӡΪͬӦʱķߴӶԴռݡ

ٸӣӦҪ͵ԴͨӶԴȡݣ߽ͼƵԴ洢

רôȷʵڣڴʩȫҪؿĽʱNode.jsʵ֡ڿʱʹNode.js̬ԴͻӦãAPIʹרô磺nginxHAProxyȡ

м

ǻصӦˮƽм˽ռλʵʱ棬ٹƱ۸񣬽м/ͼǻWebʵʱӦõĽɵлվ

Ӧü

һֳijNode.jsʹWebSocketվ߲ʵʱӻǵĽԴûռʵʱͳݣͨ©еһضĵ㣬һ߽ͨͨԵĽӶƶһΡȤȥ˽CANDDiѾ뷨Ʒˣ

ϵͳ

һʩ⡣һ£һSassƽ̨Ҫṩûһҳ棬GitHubs status pageʹNode.js¼ѭƣǿԹһǿϢ壬ط״̬첽ķʽͨWebSocket͵ͻˡ

ڲǹڷ񣬶ּͨʵʱ״̬ǽһƶ뷨ȻһڵӪ̵Network Operations Center (NOC)Ӧã//ṩ̣һЩڻNode.jsWebSocketsջϣjavajavaСӦó

ע⣺ҪͼʹNode.jsӲʵʱϵͳЩҪһӦʱϵͳErlangӦǸõѡ

Node.jsʺģ

webӦó

ʹExpress.jsܿڷϹһͳWebӦãһ˵Node.jsӦģȾHTMLҳ治õô۵ģǵĿ£

޳ɵĹ۵:

  • ӦûCPUܼĴʹNode.js϶µӦãײϵݿ⣨MongoDBĶд˿

  • ץȡһɵHTMLӦҪȵõһҳʹWebSocketӦãSEOѺá

ԵĹ۵:

  • κCPUܼ͵ҵ񽫻Node.jsӦûҵֺ̱߳ܺã෴ģCPUԡ

  • ʹNode.jsʱκιϵݿⶼ൱ʹģģȷҪùϵݿ⣬ԼһæRails,Django,ASP.Net

һCPUܼҵĽһ߿Ϣк̨Node.jsǰ̨ӴԱһ첽ؽܿͻ

Node.jsʺģ

ʹùϵݿWebӦó

Node.jsExpress.jsRuby on RailsбȽϣ˷ʹϵݿɾľ߱Ƚ֧ܵ֡

Node.jsϵݿ⹤߷չڽ׶Σǹ൱ҲѺáһ棬RailsԶṩݷȨDBģʽǨƵֹ֧ߺGemsRailsԵȿܾгġ֤ʵĻ¼ӳݷʲʵ֣ͼԴJavaScriptǣdzξ

㻹Node.js·׼õͷɡǵùעһSequelize  Node ORM2߶죬տܻӭͷϡ

Node.jsǰǿܵģҲټͬʱRails˺ͶԹϵݿļ򵥷ʡ

صķ˼

漰ļ㣬Node.jsDzõƽ̨϶ʹNode.jsһ쳲֮κCPUܼͲʹNode.js¼I/OĵģͱúãΪᱻΪ̱߳ռˡ

Node.jsʹõֻ̲߳ʹõCPU,ڶCPUϲNode.jsŶӿȺģ顣ҲԽNode.jsʵúͨNginxǡ

ʹüȺǣ㻹ӦýصIJŵRabbitMQϢںʵʱó

ĺ̨ͬһ̨УַзdzߵĿԡЩ̨Ժ׵طַworkerǰWebĸء

Ȼƽ̨ʹһNode.jsиߵ/Ѿ̸ΪÿһСķdzٺЧġ

ܽ

Ǵ۵ʵNode.jsĿͱʼͷ塣Node.jsʱΪ֮Դ99%ԭNode.jsɵġ

סNode.jsΪ˽չģΪ˽I/Oչ⣬ⷽĺܳɫ

ΪʲôʹNode.jsʹõCPUܼͲκԴNode.jsĺôٺͿչӦáӭʵʱWebӦá

СƼѧϰԼϵͳά̿Ͱȫȸ߶IT עڻ˺ţƵֵԪITѵ̳ѧ·°빦ùְн



ͶתԻȨԭУվ۵㣬ȨתصȲ֮ϵǴһΪάõĻŬϵʽվҳ½ǡ


ʻ



·

ղ

Ķ

ο 2017-8-3 15:21
topon55x6p</br>
payday loans for bad credit</br>
<a href="http://paydayloans2017.com"> payday loans online</a> </br>
&lt;a href=&quot;http://paydayloans2017.com&quot;&gt; best payday loans&lt;/a&gt; </br>
[url=http://paydayloansonline2017.com]instant payday loans[/url] </br>
usa payday loans

鿴ȫ(1)

ض