Node.js について学び直そうと思った

ポッドキャスト rebuildfm で Matz が Node.js について言及していて
うっかりこんな風につぶやいたところ @yosuke_furukawa さんからこんな
ツッコミをいただきました。

あらためて調べてみたところこちらの記事がとても良くまとまっていました。

Node.jsの問題点、デメリットと解決方法まとめ - Qiita

その中でも紹介されている大津さんの記事で cluster の導入でマルチプロセス
が可能になったことが書かれています。

注目のサーバサイドJavaScript実行環境「Node.js」 | 最新の技術・取り組み | IIJ

マルチプロセスについての情報も 探してみると結構ありました。

node.js multi process - Google 検索

ただシングルスレッドのイベント駆動 だから CPU を使い切れない部分はある
んじゃないかなとは思います。ちょっと負け惜しみっぽいですが。

おまけ

調べていたら Isolates なんて懐かしい機能も出てきました。
マルチスレッドを実現する機能だったんですね。

Node v0.7.0の新機能Isolates(マルチスレッド)を試す - y-kawazの日記

記事中にあるようにこの機能はすでに削除されています。

終わりに

せっかくなので Node.js の利点が公式サイトに載っているので
そちらを紹介したいと思います。

About | node.js

This is in contrast to today's more common concurrency model where OS threads are employed. Thread-based networking is relatively inefficient and very difficult to use. Furthermore, users of Node are free from worries of dead-locking the process—there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop scalable systems.


Just because Node is designed without threads, doesn't mean you cannot take advantage of multiple cores in your environment. You can spawn child processes that are easy to communicate with by using our child_process.fork() API. Built upon that same interface is the cluster module, which allows you to share sockets between processes to enable load balancing over your cores.

というわけで時間を作ってもう少しきちんと理解していきたいと
思っています。

そして LL Diver で furukawa さんがどんな話をしてくれるか楽しみですっ!

プログラム | LL Diver

チケットもまだまだ買えますね!

チケット | LL Diver

参考:

http://mew.org/~kazu/material/2011-server.pdf