ãã®èšäºã§ã¯ãåå¿è ã®Webããã°ã©ããŒãšNode.jsã®åŠç¿ãèããŠãã人ã ã«ãšã£ãŠæãéèŠãªè³ªåãã€ãŸã以äžãæ€èšããŸãã
- Node.jsäœæ¥ç°å¢ãã³ã³ãã¥ãŒã¿ãŒã«ã€ã³ã¹ããŒã«ããæ¹æ³ã
- ã³ãŒãã®æžãæ¹ã
- ãããã°æ¹æ³ã
- ãªã¢ãŒããµãŒããŒã§çºçããããšãå±éããæ¹æ³ã
Node.jsã¯ããããã¯ãŒã¯ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããããã®ã€ãã³ãé§ååJavascriptãã¬ãŒã ã¯ãŒã¯ã§ãã äž»ãªã¢ã€ãã¢ã¯ãã³ãŒãã®å®è¡äžã¯äœããããã¯ãããªããšããããšã§ããããŒã¿ã®è»¢éããŠãŒã¶ãŒã®å ¥åãæ¥ç¶ã®ç¢ºç«ãªã©ãäœããåŸ æ©ããæäœã¯ãããŸããã ãã¹ãŠã¯ãåææäœãåŸ æ©ããŠããéå§æã«çºçããã€ãã³ãã«åºã¥ããŠæ§ç¯ãããŸãã ããã«ãããå€ãåæã·ã¹ãã ã«æ¯ã¹ãŠãæã«ã¯æ°ååã®éèŠãªããã©ãŒãã³ã¹äžã®å©ç¹ãåŸãããŸãã 2011幎11æã«ãªãªãŒã¹ãããããŒãžã§ã³0.6.0以éãNode.js for Windowsã®ã¢ã»ã³ããªã¯å®å®ããŠãããšå®£èšãããŸããã
äœæ¥ç°å¢ãèšå®ãã
ãŸãã Web Platform InstallerãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããèµ·åãã[ãªãã·ã§ã³]ãã¯ãªãã¯ãã[è¿œå ã·ããªãªã衚瀺]ãã£ãŒã«ãã«Helicon Zoo Feedãžã®ãªã³ã¯ãè¿œå ããå¿ èŠããããŸã ïŒ http : //www.helicontech.com/zoo/feed/
ãã®åŸãWeb Platform Installerã«Zooã¿ãã衚瀺ãããŸãã
Node.jsãã€ã³ã¹ããŒã«ãã
Zoo-> Enginesã¿ãã«ã¯ãNode.jsãå«ãå©çšå¯èœãªãã¹ãŠã®Webãšã³ãžã³ã®ãªã¹ãããããŸãã ãã ããNode.jsããã±ãŒãžãã€ã³ã¹ããŒã«ããããšããå§ãããŸããNode.jsããã±ãŒãžã«ã¯ãããŒãèªäœã«å ããŠãããã«äŸ¿å©ãªã¢ãžã¥ãŒã«ãããã€ãå«ãŸããŠããããã Zoo->ããã±ãŒãž-> Node.js Hosting Packageãéžæã ã[è¿œå ]ã[ã€ã³ã¹ããŒã«]ãã¯ãªãã¯ããŸãã
Helicon Zooã®ã£ã©ãªãŒã§ãçŸåšå©çšå¯èœãªãã¹ãŠã®Webãã¬ãŒã ã¯ãŒã¯ãšã¢ããªã±ãŒã·ã§ã³ã確èªã§ããŸãã ã©ã€ã»ã³ã¹å¥çŽã«åæãããšãIISïŒãŸã ã€ã³ã¹ããŒã«ãããŠããªãå ŽåïŒãHelicon Zoo Moduleãããã³Windowsèªäœã®node.exeã®ããŠã³ããŒããšã€ã³ã¹ããŒã«ãéå§ãããŸãã
ã·ã¹ãã ã®éèŠãªã³ã³ããŒãã³ãã¯ããŒãããã±ãŒãžãããŒãžã£ãŒïŒnpmïŒã§ãè¿œå ã®ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã æ®å¿µãªãããWindowsäžã®npmã®çŸåšã®ããŒãžã§ã³ã¯äžå®å®ã§ãã ãããã察å¿ãããã®ããããŸã-ryppi.pyãŠãŒãã£ãªãã£ã¯ãnpmãšåãæ¹æ³ã§äœ¿çšã§ããŸãã ryppi.pyã¯Pythonã§èšè¿°ãããŠãããããNode.jsãã¹ãã£ã³ã°ããã±ãŒãžãã€ã³ã¹ããŒã«ãããšpythonãæç»ãããŸãã å°æ¥ãWindowsã§npmãå®å®ããŠåäœããå Žåãryppi.pyãããã«çœ®ãæããŸããããã«ãããPythonãã€ã³ã¹ããŒã«ããããã«80MBã®ãã£ã¹ã¯ã¹ããŒã¹ãç¯çŽãããŸãã
WebMatrixãã³ãã¬ãŒããã€ã³ã¹ããŒã«ãã
ãã®ãããNode.jsãã€ã³ã¹ããŒã«ããŸããããã®ã¢ããªã±ãŒã·ã§ã³ãäœæããããã«ãWebMatrixã®ãã³ãã¬ãŒãã䜿çšã§ããŸãã ãããã®ãã³ãã¬ãŒãã䜿çšãããšã空ã®ç©ºã®ã¢ããªã±ãŒã·ã§ã³ãäœæããŠããããªãéçºã«äœ¿çšã§ããŸãã
ããããã€ã³ã¹ããŒã«ããã«ã¯ã Zoo->ããã±ãŒãž-> WebMatrixãã³ãã¬ãŒããéžæããŸãã
WebMatrixãã€ã³ã¹ããŒã«ãããŠããªãå Žåã¯ãåé¡ã§ã¯ãããŸãããWebMatrixã¯ããã³ãã¬ãŒãã®ã€ã³ã¹ããŒã«äžã«èªåçã«ããŠã³ããŒãããã³ã€ã³ã¹ããŒã«ãããŸãã ã€ã³ã¹ããŒã«åŸãWebMatrixãå®è¡ããã¡ã€ã³ã®ãã³ãã¬ãŒããã [ ãµã€ã]ãéžæããŸãã
ã¹ã¯ãªãŒã³ã·ã§ãããèŠããšãããããã«ãWebMatrixãã³ãã¬ãŒããå©çšã§ãããã¬ãŒã ã¯ãŒã¯ã¯Node.jsã ãã§ã¯ãããŸããã
Node.jsãµã€ããäœæããåŸãæå®ãããURLã«ç§»åãããããå®è¡ããã¯ãªãã¯ãããšãåçŽãªãHelloãWorldïŒãã衚瀺ãããŸãã
ããã©ã«ãã§ã¯ãæ°ããäœæããããµã€ãã«ã¯ãWebã¢ããªã±ãŒã·ã§ã³ãç°¡åã«äœæããããã®ãšã¯ã¹ãã¬ã¹ãã¬ãŒã ã¯ãŒã¯ãå«ãŸããŠããŸãã 圌ãšãã®äŸåé¢ä¿ã¯ããµã€ãã®äžã®node_modulesãã£ã¬ã¯ããªã«ãããŸããããã¯ããªã¢ãŒããµãŒããŒã«ã¢ããªã±ãŒã·ã§ã³ããããã€ããã®ã«äŸ¿å©ã§ãã
ãããªãã¯ãã£ã¬ã¯ããªã¯ãéçãã¡ã€ã«ãæ ŒçŽããããã®ãã®ã§ãã ãã®ãã£ã¬ã¯ããªã«é 眮ããããã¡ã€ã«ã¯ãNode.jsã®åŒã³åºãã«ã€ãªããããšãªããIISã«ãã£ãŠéçãã¡ã€ã«ãšããŠçŽæ¥åŠçãããŸãã ããã¯ããµãŒããŒã§èª€ã£ãŠclient * .jsãã¡ã€ã«ãå®è¡ããªãããã«ããããã«ç¹ã«éèŠã§ãã
web.configãã¡ã€ã«ã«ã¯ãç¹ã«éçãã¡ã€ã«ã®URLæžãæãã«ãŒã«ãå«ãŸããŠããŸãã æåã«ããããªãã¯ãã£ã¬ã¯ããªã«ãã®ãããªéçãã¡ã€ã«ãååšãããã©ããã®èŠæ±ããã§ãã¯ãããŸãã ããã¯ãéçãªãœãŒã¹ãšåçãªãœãŒã¹ã1ã€ã®ãã£ã¬ã¯ããªïŒéåžžã¯ã«ãŒãïŒã«æ··åšããããWebã¢ããªã±ãŒã·ã§ã³ã«å¿ èŠã§ãã ã¢ããªã±ãŒã·ã§ã³ããã®æçœã«æªè³ªãªæ £è¡ã®å¯Ÿè±¡ã§ãªãå Žåãweb.configãã¡ã€ã«ããMicrosoft URL Rewriteã®ã«ãŒã«ãåé€ãããããªãã¯ãã¡ã€ã«ãæ瀺çã«æå®ããŠéçãã¡ã€ã«ãåç §ããŸãã
web.configãã¡ã€ã«ã«ã¯ããã®ãµã€ãã§Node.jsããã³Helicon Zoo Moduleãå®è¡ããããã«å¿ èŠãªæ§æãã£ã¬ã¯ãã£ããå«ãŸããŠããŸãã
ç§ãã¡ã¯æåã®ã¢ããªã±ãŒã·ã§ã³ãæžããŠããŸã
Node.jsã®å©ç¹ã®1ã€ã¯ãJavaScriptãWebéçºã§åºã䜿çšãããŠããæåãªèšèªã§ããããšã§ãã ããã¯ããšãã£ã¿ãŒã®éžæã«åé¡ããªãããšãæå³ããŸãã ç§ãã¡ã®å Žåãç¡æã®WebMatrixã¯éå§ããã®ã«é©ããå Žæã§ãã
éåæWebãã¬ãŒã ã¯ãŒã¯ã®æ©èœã瀺ãããã«ãéåžžã¯æåã«ãã£ãããäœæããŸãã ãã®ãããNode.jsã§æãæåãªãã¢ã¢ããªã±ãŒã·ã§ã³ã¯ã httpïŒ//chat.nodejs.org/ã®ãã£ããã§ãããã®ãœãŒã¹ã³ãŒãã¯åŠç¿ã«å©çšã§ããŸãã
ãŸãããœãŒã¹ãhabrããŒãžã«å®å šã«åãŸãããã«ããã£ãããã§ããã ãã·ã³ãã«ã«ããããšã決å®ããŸããã ãŠãŒã¶ãŒãã»ãã·ã§ã³ãã¹ã¯ããŒã«ããã©ãŒãããã¡ãã»ãŒãžã¯ãããŸããããã³ã°ããŒãªã³ã°ã®åäœã瀺ãããã®æãåçŽãªéåæã¡ãã»ãŒãžã®ã¿ãæž¡ãããŸãã
äœæ¥ã«ã¯ã以åã«äœæããNode.jsãµã€ãã䜿çšããŸãã server.jsããã³index.htmlãã¡ã€ã«ãç·šéããå¿ èŠããããŸãã
server.jsãã¡ã€ã«ã®ãœãŒã¹ã³ãŒãã¯æ¬¡ã®ãšããã§ãã
var express = require('express'); var callbacks = []; // function appendMessage(message){ var resp = {messages: [message]}; while (callbacks.length > 0) { callbacks.shift()(resp); } } // express var app = module.exports = express.createServer(); app.use(express.bodyParser()); // index.html app.get('/', function(req, res){ res.sendfile('index.html'); }); // app.post('/send', function(req, res){ var message = { nickname: req.param('nickname', 'Anonymous'), text: req.param('text', '') }; appendMessage(message); res.json({status: 'ok'}); }); // app.get('/recv', function(req, res){ callbacks.push(function(message){ res.json(message); }); }); // app.listen(process.env.PORT);
ããã³index.html
<html> <head> <title>Node.js Zoo Chat</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> // $(document).ready(function(){ $('form#send').submit(onSend); longPoll(); $('#nickname').focus(); }); // Submit function onSend(eventData){ eventData.preventDefault(); var msgArr = $(this).serializeArray(); var message = { nickname : msgArr[0].value, text : msgArr[1].value }; $.post('/send', message, function (data){ $('#text').val('').focus(); }, 'json'); } // function longPoll(data){ if (data && data.messages) { for (var i = 0; i < data.messages.length; i++) { var message = data.messages[i]; $('<p><b>'+message.nickname+':</b><span>'+message.text+'</span></p>').hide().prependTo('#messages').slideDown(); } } // , $.ajax({ cache: false, type: "GET", url: "/recv", success: function(data){ longPoll(data); } }); } </script> </head> <body> <h1>Node.js Zoo Chat</h1> <form action="/send" method="post" id="send"> <label for="nickname">Nickname:</label> <input name="nickname" size="10" id="nickname" /> <label for="text">Message:</label> <input name="text" size="40" id="text" /> <input type="submit"> </form> <div id="messages"></div> </body> </html>
å€æŽãé©çšããã«ã¯ããåèµ·åããã¯ãªãã¯ããŠãããå®è¡ããã¯ãªãã¯ããŸãã
ããã§ã2ã€ã®ç°ãªããã©ãŠã¶ã§ãã£ãããèµ·åããŠããã£ãããæ©èœããŠããããšã確èªã§ããŸãã
ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ãã
Webãã¬ãŒã ã¯ãŒã¯ã®å ŽåãããããæãéèŠãªæ©èœã¯ãããŸããŸãªã¢ãžã¥ãŒã«ã®å¯çšæ§ãšãµãŒãããŒãã£ãã¯ãããžã®äœ¿çšã§ãã çŸåšã®å®è£ ã§ã¯ãWindowsã®ããŒãããã±ãŒãžãããŒãžã£ãŒïŒNode PackageManagerïŒã¯äžå®å®ã§ãããWindowsã®ãµããŒãã¯æ¢ã«çºè¡šãããŠãããè¿ãå°æ¥ç¶æ³ãå€ããå¯èœæ§ããããŸãã çŸæç¹ã§ã¯ãPythonã§èšè¿°ãããããã±ãŒãžãããŒãžã£ãŒ-ryppi.pyã䜿çšã§ããŸãã ããã§èŠããŠããã¹ã埮åŠãªç¹ã1ã€ãããŸã-ryppi.pyã¯åžžã«ãåŒã³åºãããçŸåšã®ãã£ã¬ã¯ããªã®node_modulesãã£ã¬ã¯ããªã«ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããŸãã ã€ãŸã ã¢ãžã¥ãŒã«ããµã€ãã®äžã«é 眮ããã«ã¯ããµã€ãã®ãã£ã¬ã¯ããªã«ç§»åããŠãããã§ã³ãã³ããåŒã³åºãå¿ èŠããããŸãã
C:\>cd "C:\My Web Sites\Node.js Site" C:\My Web Sites\Node.js Site>ryppi.py install mongodb Installing http://registry.npmjs.org/mongodb/-/mongodb-0.9.7-0.tgz into .\node_modules\mongodb ... Checking dependencies for mongodb ... All done.
ãŸããæ¢åã®ã¢ãžã¥ãŒã«ã®ãã¹ãŠãWindowsã§åäœããããã§ã¯ãªãããšã«ã泚æããŠãã ããã ãããã£ãŠãããšãã°ãç§ã®æèŠã§ã¯ãhabrovchan octaveã«ãã£ãŠäœæãããããŒãåæã©ã€ãã©ãªã¯ãWindowsã§ã¯åäœããŸããã ãã®ã©ã€ãã©ãªã«ãããå€ãã®å ŽåãNodeã®éåææ§ã倱ãããšãªããé¢åãªã³ãŒã«ããã¯ãã©ãã€ã ãåãé€ãããšãã§ããŸãããWindowsã«ç§»æ€ãããŠããªãnode-fibersã®å®è£ ã«åºã¥ããŠããŸãã ä»åŸããã¡ã€ããŒã®ãµããŒããNode.jsã«çŽæ¥çµã¿èŸŒãŸããããšãé¡ã£ãŠããŸãã
ããã§ããã»ãšãã©ã®ã¢ãžã¥ãŒã«ã¯Windowsäžã§å®å®ããŠåäœããŸãã
CoffeScript
Node.jsã§å€ããå°ãªãã倧èŠæš¡ãªãããžã§ã¯ããæžãå§ãããšãé ããæ©ãããJavaScriptã¯ããŸããã¬ã³ããªãŒãªèšèªã§ã¯ãªããšããäºå®ã«æ°ä»ãã§ãããã äžæ¬åŒ§ã®çŸ€ããå€ãã®äžå¿ èŠãªæ§é -ãããã¯ãã¹ãŠããã°ã©ã ã®å¯èªæ§ãå¢ããã®ã§ã¯ãªããã³ãŒãã®ãããªãäœæ¥ãè€éã«ããŸãã 幞ããªããšã«ãããã«æåã«ééããã®ã¯ããªãã§ã¯ãªããåé¡ã¯ãã§ã«è§£æ±ºãããŠããå¯èœæ§ããããŸãã ãã®ãããJavaScriptã«åºã¥ããããŸãã¯æ¡åŒµããå€ãã®æŽŸçèšèªããããŸãã ããšãã°ãåç §çšã®çããªã¹ãã次ã«ç€ºããŸããhttp ïŒ //altjs.org/
çŸæç¹ã§æã人æ°ã®ããCoffeeScriptã䜿çšã§ããŸãã CoffeeScriptã³ãŒãã¯ããã·ã³ãã«ã§èªã¿ãããã§ãã ãã®ã³ãŒãã¯ããã¬ãŒã³ãªJavaScriptã«ã³ã³ãã€ã«ãããŠå®è¡ãããŸãã éã«ãJavaScriptã³ãŒãã¯CoffeeScriptã«å€æã§ããŸãã ããšãã°ãCoffeeScriptãã£ããã®server.jsã¹ã¯ãªããã¯æ¬¡ã®ããã«ãªããŸãã
express = require("express") callbacks = [] // appendMessage = (message) -> resp = messages: [ message ] callbacks.shift() resp while callbacks.length > 0 // express app = module.exports = express.createServer() app.use express.bodyParser() // index.html app.get "/", (req, res) -> res.sendfile "index.html" // app.post "/send", (req, res) -> message = nickname: req.param("nickname", "Anonymous") text: req.param("text", "") appendMessage message res.json status: "ok" // app.get "/recv", (req, res) -> callbacks.push (message) -> res.json message // app.listen process.env.PORT
CoffeeScriptã®è©³çŽ°ïŒ http : //jashkenas.github.com/coffee-script/
CoffeeScriptã®ã€ã³ã¹ããŒã«ïŒ rippy.py install coffe-script
Node.jsã¢ããªã±ãŒã·ã§ã³ã®ãããã°
Node.jsã§ã¢ããªã±ãŒã·ã§ã³ããããã°ããã«ã¯ãããŒãã€ã³ã¹ãã¯ã¿ãŒãšããåªããããŒã«ããããŸãã Node.jsãµã€ããã³ãã¬ãŒãã«ããnode_modulesãã£ã¬ã¯ããªã«æ¢ã«å«ãŸããŠããŸãã ããŒãã€ã³ã¹ãã¯ã¿ãŒã¯æ¬¡ã®ããã«æ©èœããŸãã
- ãããã°ããå¿ èŠãããã¢ããªã±ãŒã·ã§ã³ããããã°ã¢ãŒãã§èµ·åãããŸãïŒ--debugãŸãã¯--debug-brkãªãã·ã§ã³ãæå®ããŠnode.exeãåŒã³åºããŸãïŒã
- æ¬è³ªçã«ã¯Webã¢ããªã±ãŒã·ã§ã³ã§ãããããŒãã€ã³ã¹ãã¯ã¿ãŒãèµ·åãããŸãã
- WebSocketãããã³ã«ã䜿çšããŠãããã2ã€ã®ã¢ããªã±ãŒã·ã§ã³ã¯äºãã«éä¿¡ããŠãããã°ããŒã¿ã転éããŸãã
- ãããã°ãããã¢ããªã±ãŒã·ã§ã³ãå«ãããŒãžããã©ãŠã¶ãŒã§éããŸãã
- Webkitäºæãã©ãŠã¶ã§ããããã°æ å ±ãå«ãããŒãã€ã³ã¹ãã¯ã¿ã€ã³ã¿ãŒãã§ã€ã¹ãéããŸãããã®ã€ã³ã¿ãŒãã§ã€ã¹ã¯ãGoogle ChromeãŸãã¯Safariã®Webã€ã³ã¹ãã¯ã¿ã«äŒŒãŠããŸãã
ãã³ãã¬ãŒãã®node.jsãµã€ãã®ã«ãŒããã£ã¬ã¯ããªã«ã¯ãçŸåšã®ã¢ããªã±ãŒã·ã§ã³ã®ãããã°ãéå§ãããããã°çšã«ãã©ãŠã¶ãŒã§ããŒãžãéãstart_debug.cmdãã¡ã€ã«ããããŸãã
ãã©ãŠã¶ãŒã®ãããã¬ãŒã¯æ¬¡ã®ããã«ãªããŸãã
ãµãŒããŒå±é
ããã§ãWebã¢ããªã±ãŒã·ã§ã³ãäœæããããããããã¯ãŒã¯ã«é 眮ããããšèããŠããŸãã ãããè¡ãã«ã¯ãµãŒããŒãå¿ èŠã§ãããNode.jsã§åäœããããã«WindowsãµãŒããŒãã»ããã¢ããããããšã»ã©ç°¡åãªããšã¯ãããŸããã äœæ¥ç°å¢ãå±éããããã«è¡ã£ãèšäºã®æåããããã€ãã®æé ãç¹°ãè¿ãå¿ èŠããããŸãã ã€ãŸããMicrosoft Web Platform Installerãã€ã³ã¹ããŒã«ããããã«Helicon Zooãã£ãŒããè¿œå ããŠãZooãªããžããªãŒããNode.js Hosting Packageãã€ã³ã¹ããŒã«ããŸãã ããã ãã§ã-ãµãŒããŒã¯ã¢ããªã±ãŒã·ã§ã³ãåãå ¥ããæºåãã§ããŠããŸãã ãµãŒããŒãã©ãããã©ãŒã ããã¯ãWindows 2008ããã³2008 R2ã32ãããããã³64ãããããŒãžã§ã³ããµããŒããããŸãã
ããã§ããã¹ãããŠããå Žåã¯ãIISãããŒãžã£ãŒãŸãã¯ãã¹ãã£ã³ã°ããã«ã䜿çšããŠãµãŒããŒäžã«ç©ºã®Webãµã€ããäœæããFTPãŸãã¯WebDeployãä»ããŠã¢ããªã±ãŒã·ã§ã³ããµã€ãã«ã³ããŒããã ãã§ãã WebDeployã®å Žåãå¿ èŠãªãã©ã«ããŒæš©éãé åžãããŸãã GitãŸãã¯å¥ã®ããŒãžã§ã³ç®¡çã·ã¹ãã ã䜿çšããããšãã§ããŸãããããã¯ãã®èšäºã®ç¯å²å€ã§ãã
Helicon Zoo Moduleã¯ãããšããšãã¹ãã£ã³ã°ãœãªã¥ãŒã·ã§ã³ã®æ§æãèæ ®ããŠèšèšãããŸããã ãã®ããããã®äžã®ãã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ã¯åå²ãããéè€ããŸããã ããã©ã«ãèšå®ã®ã¢ãžã¥ãŒã«ã¯èªåçã«åäœããè² è·ãå°ãããšãã«1ã€ã®ã¯ãŒã«ãŒïŒããã»ã¹ããã»ããµïŒãäœæããããã³ã¢ã®æ°ãŸã§ã¯ãŒã«ãŒãè¿œå ããŠãã¢ããªã±ãŒã·ã§ã³ã®è² è·ãå¢å ããå Žåã«æ倧ã®ããã©ãŒãã³ã¹ãæäŸããŸãã
Helicon Zooã¯ããšã³ãžã³ãšã¢ããªã±ãŒã·ã§ã³ã®æŠå¿µã䜿çšããŠããŸãã ãã®ããããšã³ãžã³ã§ã¯ãäœãã©ã®ããã«ãã©ã®ãããã³ã«ã§ãã©ã®ããŒãã§ãèš±å¯ãããæå°ããã³æ倧ã¯ãŒã«ãŒæ°ãšapplicationHost.configãã¡ã€ã«ã§ã°ããŒãã«ã«èšå®ãããåæ§ã®ã°ããŒãã«èšå®ã«ãã£ãŠæ±ºå®ãããŸãã 次ã«ããµã€ãã®äžã§ãç¹å®ã®ãšã³ãžã³ã䜿çšããã¢ããªã±ãŒã·ã§ã³ãäœæãããã®ã¢ããªã±ãŒã·ã§ã³ãæ©èœããããã«å¿ èŠãªãã©ã¡ãŒã¿ãŒãæž¡ãããšãã§ããŸãã ããã«ããããã¹ãã£ã³ã°ç®¡çè ã®äœæ¥ãã¯ã©ã€ã¢ã³ãããåé¢ããã¯ã©ã€ã¢ã³ããäºãã«åé¢ããããšãã§ããŸãã
Node.jsããã©ãŒãã³ã¹ãã¹ã
ãµãŒããŒãšããŠã®ãã¹ããã·ã³ã¯ãCore 2 Quad 2.4 Ghzã8 Gb RAMãã®ã¬ããããããã¯ãŒã¯ã§ãã è² è·ãçæããããã«ãã³ãã³ããab.exe -n 100000 -c 100 -kããšãšãã«ããã匷åãªã³ã³ãã¥ãŒã¿ãŒãšApache Benchmarkã䜿çšãããŸããã Apacheããã³Nginxã®ãã¹ãã«ã¯ãUbuntu 11.04 Server x64ã䜿çšãããŸããã IIS 7ãã¹ãã¯ãWindows Server 2008 R2ã§å®è¡ãããŸããã virtualoksã¯ãããŸãã-æ£çŽãªéã
3ã€ã®ãã¹ããå®è¡ãããŸããã æåã®æ®µéã§ã¯ãNode.jsã¯çŸåšã®æå»ãé«è§£å床ã§ããŒãžã«è¡šç€ºããã ãã§ããã åçããã£ãã·ã¥ããéä¿¡ãããªãããã«ããããã®æéãå¿ èŠã§ãã 2çªç®ã®ãã¹ãã¯MySQLããŒã¿ããŒã¹ããèªã¿åãã3çªç®ã®ãã¹ãã¯ããŒã¿ããŒã¹ã«æžã蟌ã¿ãŸãã
çµæã¯æ¬¡ã®ãšããã§ãïŒã°ã©ãã®å€ã¯1ç§ãããã®ãªã¯ãšã¹ãæ°ã§ãïŒã
å°è±¡çã§ããã ãããã®ãã¹ãã枬å®ãããã®ã®å°ãã®èª¬æã ç°ãªãããã»ããµã枬å®ããŠããããã§ã¯ãªããããããããããã©ãŒãã³ã¹ãã¹ããšåŒã¶ããšã¯ããããå®å šã«çå®ã§ã¯ãããŸããã ããã»ããµã®ããã©ãŒãã³ã¹ã¯åäžããå¯èœæ§ããããŸãããWebãµãŒããŒã§ã¯éã®çµæãã€ãŸãåãªã¯ãšã¹ãã«ã©ãã ãã®ããã»ããµæéãè²»ããããå¯èœæ§ããããŸãã
ãã®ãããæåã®ãã¹ãã§ã¯ãç¹å®ã®WebãµãŒããŒããšã«ãªã¯ãšã¹ããåŠçããæ£å³ã®ãªãŒããŒããããšãããã»ããµãªãœãŒã¹ã䜿çšããèœåã枬å®ãããŸãã ãã®ããã»ããµäžã®ãã®äžé£ã®ãã¯ãããžãé«éåããŠããçããè¿ãããšãã§ããŸããã ãã®ãã¹ãã§ã¯ãNginxã¯ãã®ã·ã¹ãã äžã®åãªã¯ãšã¹ãã§ããã¯ãšã³ããžã®æ°ããæ¥ç¶ãéããããWindowsäžã®Nginxã¯ã¯ããã«é ããŠããŸãã ããããWindowsäžã®Apacheã¯ãå察ã«ãæ¥ç¶ããŒãªã³ã°ãšå®éã®ã¹ã¬ããã«æºè¶³ããŠããŸãã
2çªç®ãš3çªç®ã®ãã¹ãã¯ããªã¯ãšã¹ãã®ãéã¿ãã®å¢å ã«äŒŽãããªã¯ãšã¹ããåŠçããããã®WebãµãŒããŒãªãŒããŒãããã®å²åãã©ã®ããã«å€åãããã瀺ããŠããŸãã ãã ãããã¡ã€ã«ã·ã¹ãã ãããŒã¿ããŒã¹ãã©ã€ããŒãããŒã¿ããŒã¹èªäœã®ããã©ãŒãã³ã¹ãªã©ãä»ã®å€ãã®èŠå ã«ãã圱é¿ã倧ãããªããŸããã å®éšã§ã¯ãMongoãšã®éãã確èªããããã«ãWindows + Zoo + MongoDBã®æããã¹ãããŸããã ãã®çµæã¯ãèªã¿åãã§6793ç§/ç§ãæžã蟌ã¿ã§2906ç§/ç§ã§ãã å°è±¡çãªãç¹ã«æžã蟌ã¿é床ã
å¥ã®èå³æ·±ãäºå®ã¯ããããã®ãã¹ãã§äœ¿çšããããœãããŠã§ã¢ããã³ããŒããŠã§ã¢ããŒã¹ã¯ã ãã®èšäºã® Djangoããã¹ããããšããšåãã§ãã ãããã£ãŠããããã®ãã¹ãã®çµæãæ¯èŒã§ããŸãã ãã¡ãããNode.jsã¹ã¯ãªããã¯ã¯ããã«è»œéã§ããããã³ãã¬ãŒããORMãªã©ã¯äœ¿çšããŸããã§ããã ãããããŸã èããçç±ããããŸãã
èªè ã®ãªã¯ãšã¹ãã«å¿ããŠã詳现ãªãã£ãŒããæ²èŒããŸãã WebãµãŒããŒèªäœã®ãªãŒããŒãããã確èªããããšãæåã§ãããããåçŽãªæéåºåãããæåã®ãã¹ãã®ã¿ãå枬å®ãããŸããã èšå®ãã¡ã€ã«ãšãã¹ãæžã¿ã®jsã¹ã¯ãªããã¯ã ããã«ãããŸã ã ã€ã³ã¯ã«ãŒãã®ã¿ããããä»ã¯ãã¹ãŠããã©ã«ãã§ãã æ°Žå¹³ã¹ã±ãŒã«-ãªã¯ãšã¹ããåçŽ-ããªç§åäœã®å¿çæéã
WindowsãIIS7 + ZooããæéåºåãïŒ
UbuntuãApacheããæéåºåãïŒ
UbuntuãNginxããæéåºåãïŒ
çµè«
Node.jsã¯éåžžã«ææãªãã¯ãããžãŒã ãšæããŸãã åªããããã©ãŒãã³ã¹ãšæè»æ§ãåããŠããŸãã Node.jsãUnixãšWindowsã®äž¡æ¹ã§åçã«åªããŠããããããã®ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ããããã«é©åãªæè¡çãœãªã¥ãŒã·ã§ã³ã䜿çšããŠããããšã¯ç¹ã«çŽ æŽãããããšã§ããããã¯ãã¹ãçµæããæããã§ãã
ãŸããªãHelicon Zooã«ErlangãšJavaã®ãµããŒããè¿œå ããäºå®ã§ãã ãããã®ãã¯ãããžãŒã®ããã©ãŒãã³ã¹ãæ¯èŒããããšã¯èå³æ·±ãã§ãããã ãããŸã§ã®éãNode.jsã¯ããµããŒããããŠããWebãã¬ãŒã ã¯ãŒã¯ã®äžã§ã¹ããŒãã®æ確ãªãªãŒããŒã§ãã
PSïŒãã®èšäºã®å ¬éã«ååããŠãããrukebaãšXaocCPSã«æè¬ããŸãã