At this year’s Scottish Ruby Conference, I gave a talk about EventMachine, slides are available. Amidst the hype around Node.js it’s too easy to forget that Ruby has had evented I/O libraries for years. EventMachine, libebb, rev, cool.io, to name a few. As a general introduction I recommend reading Dan Kegel’s article on the C10K problem, the problem of handling 10000 server connections on a singl
I have been using Sinatra for sometime now and I would like to add some realtime features to my web-app by pushing the data via websockets. I have successfully used the gem 'em-websocket' on its own, but have not been able to write one ruby file that has a sinatra web server AND a web-socket server. I've tried spinning the run! or start! methods off in separate threads with no success. Has anyone
並列1000コネクションに耐える! Ruby のイベント駆動ライブラリ Rev と EventMachine の HTTPクライアント こんにちは、takada-at です。 Rubyのイベント駆動型ネットワークプログラミングフレームワーク Rev と EventMachine で HTTPクライアントを動かしてみました。 イベント駆動型ネットワークプログラミングフレームワークとは何か説明しだすと難しいですが、一言で言うと、以下のようになります。 # ふつうのフロー駆動型プログラム Net::HTTP.start(host, port){|http| res = http.get(path) #この処理が終わってから } puts "done" #この次の処理が実行される # イベント駆動型プログラム client = Rev::HttpClient::connect(host, port
Photo by pnoeric いま、PhotoShareで使うために、高速なEvent Driven方式のネットワークライブラリ、EventMachineを調べています。 このEventMachine、ほとんどの場合はサーバを作るときに使われていますが、HTTPクライアントの機能も実装されており、実はクローラの様な物を作るときにも利用することができます。 今回はこっちを使いたかったのですが、ググってもほとんど情報が出てこなかったので、Seattle.rbで相談したところ、Aaronさん(RubyKaigi 2008でプレゼンしているのをustで見てコンタクトしました)からサンプルが貰えたので、それを元に、同時接続する様にしてみました。 このコードだけだと役には立ちませんが、情報が少なかったので参考に上げておきます。 require 'rubygems' require 'eventma
By Ilya Grigorik on May 20, 2010 Any web application that reaches some critical mass eventually discovers that separation of services, where possible, is a great strategy for scaling the service. In fact, oftentimes a user action can be offloaded into a background task, which can be handled asynchronously while the user continues to explore the site. However, coordinating this workflow does requir
By Ilya Grigorik on December 22, 2009 WebSockets are one of the most underappreciated innovations in HTML5. Unlike local storage, canvas, web workers, or even video playback, the benefits of the WebSocket API are not immediately apparent to the end user. In fact, over the course of the past decade we have invented a dozen technologies to solve the problem of asynchronous and bi-directional communi
Twitter の ChirpUserStreams を WebSocket で垂れ流して閲覧できるアプリを作りました!WebSocket 対応ブラウザ(Chrome 等)でお楽しみください!WebSocket すごい!ユーザ体験が変わる! ChirpUserStreams => WebSocket ボク @june29 と @kei_s から見た世界を体験できるようにしてあります。ChirpUserStreams については、以前にエントリを書きました。 TwitterのChirpUserStreamsをごくごくしてみた 本家の API がベータ版であり、まだまだ不安定なので、たまにスクリプトの再起動をかけたりしながら動かしています。見てみたいけど「なんにも表示されないよ?」って方がいたら、@june29 や @kei_s に話しかけてみてください。対応できるかもしれません。 User
という題で、RubyKansai勉強会#43で発表させていただきました。 使用したスライドは以下です。 Async Programming on Ruby View more presentations from Kazki Matsumoto. 発表でも紹介しましたが、非同期WebフレームワークであるCrampがすごく使い易い。使い方については以下のチュートリアルが参考になります。 http://m.onkey.org/2010/1/7/introducing-cramp また、非同期Webフレームワーク上から利用するための、ロックしないGearmanクライアントをEventMachine上で実装しています。 http://github.com/KazkiMatz/em-gearman-client ひどく荒削りな状態ですが、お役に立てば。
Twitterには、ストリーミングAPIという、プッシュでリアルタイムに情報を受け取ることのできるAPIが用意されています。 これを使えば、定期的にポーリングをしたりすることなく、誰かが発言した時点で即座にメッセージを受け取れます。 しかし、これを使うためには、TCP接続をTwitterに対して張りっぱなしにしておく必要があり、Webアプリなどで使うのに敷居が高いと感じている人もいるのではないでしょうか。 今回は、「そんなことないよ、超簡単だよ」ということを、Rubyベースのサンプルで示したいと思います。 なぜそんなことが簡単にできるのか、その秘密を先に種明かしすると、Ruby用のWebサーバとして急速に人気を獲得し、デファクトの座をとりつつある「Thin」というWebサーバが、内部的にEventMachineという非同期サーバを使用しているので、その機能を使うことで、今までのWebアプリ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く