Rails Deployment with NginX

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Rails Deployment with NginX - Presentation Transcript

    1. Rails Deployment with NginX 完全な rails スタックの探求
    2. 自己紹介 名前: Stoyan Zhekov ➲ ブルガリア人 ➲ 子供は男三人 ➲ web: http://zhekov.net/ ➲
    3. Deploying Rails Deployment て何? ➲ Too many changes last years ➲ お金の話 ➲ EngineYard: $299/mo per slice ● RailsMachine: $245/mo + $60 setup ●
    4. 奇本が変わらない フロントエンドの web サーバ ➲ 静的リクエストの処理 ● バックエンドのアプリケーションサーバ ➲ 動的リクエストの処理 ● デタベース ➲
    5. 奇本が変わらない (2) image by Ezra Zygmuntowicz
    6. History Lesson Apache + CGI ➲ Apache + FastCGI ➲ Lighttpd + FastCGI ➲ Lighttpd + SCGI ➲ Litespeed ➲ etc. etc. (mod_fcgi, mod_ruby) ➲ Mongrel ➲
    7. Enter Mongrel
    8. Mongrel て何 ? Mongrel は犬の雑種 image by Ezra Zygmuntowicz
    9. Mongrel て何 ? (2) Mongrel は犬の雑種 flickr image
    10. Mongrel て何 ? (3) HTTP サーバ and library by Zed Shaw ➲ Almost pure Ruby (HTTP parser in C) ➲ Modular = can have my own handlers ➲ Library = can have my own framework ➲ Merb: http://merb.rubyforge.org/ ● Ramaze: http://ramaze.rubyforge.org/ ●
    11. Why Mongrel (and HTTP)? HTTP は良く知られているプロトコル ➲ Mongrel はセットアップが容易 ➲ 高速 ➲ 管理が容易 (monit) ➲ Scale が容易 (TCP/IP) ➲
    12. 動的リクエスト Mongrel != Rails ➲ Mongrel IS thread safe ➲ Rails IS NOT thread save (CGI.rb) ➲ Giant Mutex Lock around the Dispatcher ➲ Mongrel は時間単位で 1 リクエストを提供 ➲
    13. Mutex Lock around the Dispatcher image by Ezra Zygmuntowicz
    14. どうしよう?
    15. プロセスとともに拡張 mongrel_cluster ➲ ロードバランサ ➲
    16. ロードバランサ pen (no SSL) ➲ pound (restart to reload the config) ➲ balance ➲ HAproxy ➲ LiteSpeed ロードバランサ ($1299) ➲
    17. 一般的な問題は? 静的ファイルを提供しない ➲ ロードがバックエンドにシフトする (bad) ➲
    18. 静的リクエスト JavaScript – bigger and bigger (AJAX) ➲ Multimedia – video, images ➲ Rails caching - .html ➲ Distributed assets - assets%i.dot.com ➲
    19. フロントエンドの web サーバ Apache – VPS の RAM は不十分 ➲ Lighttpd – 高負荷ではメモリリーク ➲ Litespeed – 同時リクエスト数上限は 300 ➲
    20. NginX: from Russia with love 名前: nginx [engine x] ➲ HTTP サーバ and IMAP/POP3/SMTP proxy ➲ ロシアの 20% は NginX でできてる ➲ fastmail.fm ➲ EngineYard ➲
    21. 問題 単独プロジェクト ➲ ロシア語を読み書きできるか ➲ CGI サポートなし ➲
    22. なぜ NginX? パフォーマンスがいい ➲ 稼働時のメモリ使用量が小さい (VPS) ➲ proxy でメモリリークは無い ➲ 名前ベース、 IP ベースのバーチャルサーバ ➲ PUT, DELETE, MKCOL, COPY and MOVE ➲ Modular ➲ FLV streaming もできる ➲
    23. パフォーマンスがいい Serious Web servers use event loops ➲ http://www.kegel.com/c10k.html ● 各 OS に最適化されてる (async) ➲ BSD – kqueue ● Linux 2.6 – epool ● Solaris 10 – EventPorts (Joyent.com) ●
    24. High availability unix による管理 ➲ kill -HUP – reload the config ● kill -USR2 – BINARY RELOAD ●
    25. Coding style if (m[1] == 'O') { if (m[0] == 'P' && m[2] == 'S' && m[3] == 'T') { r->method = NGX_HTTP_POST; break; } if (m[0] == 'C' && m[2] == 'P' && m[3] == 'Y') { r->method = NGX_HTTP_COPY; break; } ...
    26. NginX のインストール Two versions: 0.5.x (stable) and 0.6.x (devel) (Debian/Ubuntu) # apt-get install libssl-dev http://zhware.net/code/shell/mk_nginx.sh.txt
    27. NginX Configuration Ezra Zygmuntowicz (merb, BackgroundDRb): http://brainspl.at/nginx.conf.txt http://pastie.caboo.se/84928 # gem install nginx_config_generator # generate_nginx_config –example > config.yml # generate_nginx_config config.yml nginx.conf
    28. Config: OS tuning user www-data; worker_processes 1; events { worker_connections 1024; use epoll; }
    29. Config: HTTP block http { include conf/mime.types; include conf/optimize.conf; upstream mybackends { server b1.example.com weight=5; server b2.example.com:8080; server unix:/tmp/backend3; } server { ... }
    30. Config: server block server { listen 80; name s1.example.com; location / { } } server { listen 80; name s2.example.com; ... }
    31. Config: location blog location / { ... proxy_pass http://mybackends; ... }
    32. おもろいもの Virtual SSI ➲ <!--# include virtual=”/foo” --> ● Mirror on demand ➲ memcached module ➲
    33. NginX Rails config location / { # static files if (-f $request_filename) { break; } # rails caching if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://mongrel; break; } }
    34. Links 英語 : http://nginx.net/ ➲ wiki: http://wiki.codemongers.com/ ➲ my notes: http://wiki.zhekov.net/nginx ➲ links: http://del.icio.us/zh/nginx ➲ chat: #nginx on FreeNode, ➲ http://www.lingr.com/room/nginx/
    35. これから 組合せ ➲ nginx + Litespeed backends ● バックエンドの最適化 ➲ Swiftiply Proxy: http://swiftiply.swiftcore.org/ ● Evented Mongrel (eventmachine) ● Edge Side Includes (ESI):http://www.esi.org/ ➲ Rails の替わりに Merb を使います ➲
    36. 質問

    + Stoyan ZhekovStoyan Zhekov, 3 years ago

    custom

    6492 views, 0 favs, 0 embeds more stats

    The quest for the perfect Rails stack

    More info about this document

    CC Attribution License

    Go to text version

    • Total Views 6492
      • 6492 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 87
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories