SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
Rails Deployment with NginX



                完全な rails スタックの探求
自己紹介


    名前: Stoyan Zhekov
➲
    ブルガリア人
➲
    子供は男三人
➲
    web: http://zhekov.net/
➲
Deploying Rails

    Deployment て何?
➲
    Too many changes last years
➲
    お金の話
➲
        EngineYard: $299/mo per slice
    ●
        RailsMachine: $245/mo + $60 setup
    ●
奇本が変わらない


    フロントエンドの web サーバ
➲
        静的リクエストの処理
    ●
    バックエンドのアプリケーションサーバ
➲
        動的リクエストの処理
    ●
    デタベース
➲
奇本が変わらない (2)




image by Ezra Zygmuntowicz
History Lesson

    Apache + CGI
➲
    Apache + FastCGI
➲
    Lighttpd + FastCGI
➲
    Lighttpd + SCGI
➲
    Litespeed
➲
    etc. etc. (mod_fcgi, mod_ruby)
➲
    Mongrel
➲
Enter Mongrel
Mongrel て何 ?

 Mongrel は犬の雑種




image by Ezra Zygmuntowicz
Mongrel て何 ? (2)
               Mongrel は犬の雑種




flickr image
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/
    ●
Why Mongrel (and HTTP)?


    HTTP は良く知られているプロトコル
➲
    Mongrel はセットアップが容易
➲
    高速
➲
    管理が容易 (monit)
➲
    Scale が容易 (TCP/IP)
➲
動的リクエスト


    Mongrel != Rails
➲
    Mongrel IS thread safe
➲
    Rails IS NOT thread save (CGI.rb)
➲
    Giant Mutex Lock around the Dispatcher
➲
    Mongrel は時間単位で 1 リクエストを提供
➲
Mutex Lock around the Dispatcher




image by Ezra Zygmuntowicz
どうしよう?
プロセスとともに拡張


    mongrel_cluster
➲
    ロードバランサ
➲
ロードバランサ


    pen (no SSL)
➲
    pound (restart to reload the config)
➲
    balance
➲
    HAproxy
➲
    LiteSpeed ロードバランサ ($1299)
➲
一般的な問題は?


    静的ファイルを提供しない
➲
    ロードがバックエンドにシフトする (bad)
➲
静的リクエスト


    JavaScript – bigger and bigger (AJAX)
➲
    Multimedia – video, images
➲
    Rails caching - .html
➲
    Distributed assets - assets%i.dot.com
➲
フロントエンドの web サーバ


    Apache – VPS の RAM は不十分
➲
    Lighttpd – 高負荷ではメモリリーク
➲
    Litespeed – 同時リクエスト数上限は 300
➲
NginX: from Russia with love


    名前: nginx [engine x]
➲
    HTTP サーバ and IMAP/POP3/SMTP proxy
➲
    ロシアの 20% は NginX でできてる
➲
    fastmail.fm
➲
    EngineYard
➲
問題


    単独プロジェクト
➲
    ロシア語を読み書きできるか
➲
    CGI サポートなし
➲
なぜ NginX?

    パフォーマンスがいい
➲
    稼働時のメモリ使用量が小さい (VPS)
➲
    proxy でメモリリークは無い
➲
    名前ベース、 IP ベースのバーチャルサーバ
➲

    PUT, DELETE, MKCOL, COPY and MOVE
➲
    Modular
➲
    FLV streaming もできる
➲
パフォーマンスがいい


    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)
    ●
High availability

    unix による管理
➲
        kill -HUP – reload the config
    ●
        kill -USR2 – BINARY RELOAD
    ●
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;
  }
...
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
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
Config: OS tuning



user www-data;
worker_processes   1;

events {
  worker_connections    1024;
  use epoll;
}
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 {
      ...
}
Config: server block
server {
  listen 80;
  name s1.example.com;

    location / {

    }
}

server {
  listen 80;
  name s2.example.com;
  ...
}
Config: location blog



location / {
  ...
  proxy_pass   http://mybackends;
  ...
}
おもろいもの

    Virtual SSI
➲
        <!--# include virtual=”/foo” -->
    ●

    Mirror on demand
➲
    memcached module
➲
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;
  }
}
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/
これから

    組合せ
➲
        nginx + Litespeed backends
    ●
    バックエンドの最適化
➲
        Swiftiply Proxy: http://swiftiply.swiftcore.org/
    ●
        Evented Mongrel (eventmachine)
    ●

    Edge Side Includes (ESI):http://www.esi.org/
➲
    Rails の替わりに Merb を使います
➲
質問

Mais conteúdo relacionado

Mais procurados

Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.jsFred Chien
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Данил Иванов
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL serverMarian Marinov
 
A3 sec -_msr_2.0
A3 sec -_msr_2.0A3 sec -_msr_2.0
A3 sec -_msr_2.0a3sec
 
Genkidama:実装と課題
Genkidama:実装と課題Genkidama:実装と課題
Genkidama:実装と課題Takuya ASADA
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglKilian Valkhof
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22Yuya Takei
 
Django and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheDjango and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheAnton Pirker
 
Basics of html5, data_storage, css3
Basics of html5, data_storage, css3Basics of html5, data_storage, css3
Basics of html5, data_storage, css3Sreejith Nair
 
Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)dreamwing.org
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPerrin Harkins
 
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...OWASP Russia
 
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionWebtrends
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Tatsuhiko Miyagawa
 
marko_go_in_badoo
marko_go_in_badoomarko_go_in_badoo
marko_go_in_badooMarko Kevac
 

Mais procurados (20)

Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
 
Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)Varnish Cache and Django (Falcon, Flask etc)
Varnish Cache and Django (Falcon, Flask etc)
 
Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL server
 
A3 sec -_msr_2.0
A3 sec -_msr_2.0A3 sec -_msr_2.0
A3 sec -_msr_2.0
 
Genkidama:実装と課題
Genkidama:実装と課題Genkidama:実装と課題
Genkidama:実装と課題
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Django and Nginx reverse proxy cache
Django and Nginx reverse proxy cacheDjango and Nginx reverse proxy cache
Django and Nginx reverse proxy cache
 
Basics of html5, data_storage, css3
Basics of html5, data_storage, css3Basics of html5, data_storage, css3
Basics of html5, data_storage, css3
 
Revisited
RevisitedRevisited
Revisited
 
Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)Nginx常见应用技术指南(Nginx Tips)
Nginx常见应用技术指南(Nginx Tips)
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to Profiling
 
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
 
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injectionStHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
StHack 2013 - Florian "@agixid" Gaultier No SQL injection but NoSQL injection
 
5 things MySql
5 things MySql5 things MySql
5 things MySql
 
Wrapper to use Japanse font with vcd::mosaic and build it as pakcage
Wrapper to use Japanse font with vcd::mosaic and build it as pakcageWrapper to use Japanse font with vcd::mosaic and build it as pakcage
Wrapper to use Japanse font with vcd::mosaic and build it as pakcage
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data Collection
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
marko_go_in_badoo
marko_go_in_badoomarko_go_in_badoo
marko_go_in_badoo
 

Destaque

Microblogging via XMPP
Microblogging via XMPPMicroblogging via XMPP
Microblogging via XMPPStoyan Zhekov
 
Push the web with HTML5
Push the web with HTML5Push the web with HTML5
Push the web with HTML5Stoyan Zhekov
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)Stoyan Zhekov
 
Webhooks - glue for the web (japanese)
Webhooks - glue for the web (japanese)Webhooks - glue for the web (japanese)
Webhooks - glue for the web (japanese)Stoyan Zhekov
 
Alliance Day 2007: Philadelphia Cultural List Cooperative
Alliance Day 2007: Philadelphia Cultural List CooperativeAlliance Day 2007: Philadelphia Cultural List Cooperative
Alliance Day 2007: Philadelphia Cultural List Cooperativecatet
 

Destaque (6)

Microblogging via XMPP
Microblogging via XMPPMicroblogging via XMPP
Microblogging via XMPP
 
Push the web with HTML5
Push the web with HTML5Push the web with HTML5
Push the web with HTML5
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)
 
Ruby cooking
Ruby cookingRuby cooking
Ruby cooking
 
Webhooks - glue for the web (japanese)
Webhooks - glue for the web (japanese)Webhooks - glue for the web (japanese)
Webhooks - glue for the web (japanese)
 
Alliance Day 2007: Philadelphia Cultural List Cooperative
Alliance Day 2007: Philadelphia Cultural List CooperativeAlliance Day 2007: Philadelphia Cultural List Cooperative
Alliance Day 2007: Philadelphia Cultural List Cooperative
 

Semelhante a Rails Deployment with NginX

yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909Yusuke Wada
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)Stoyan Zhekov
 
Hp Linux
Hp LinuxHp Linux
Hp Linuxtelab
 
Working With Rails
Working With RailsWorking With Rails
Working With RailsDali Wang
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPAtsuhiro Kubo
 
High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)Stoyan Stefanov
 
MySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイントMySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイントK H
 
Spring基础教程
Spring基础教程Spring基础教程
Spring基础教程Shilong Sang
 
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFBe Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFMark Stanton
 
Transfer to kubernetes data platform from EMR
Transfer to kubernetes data platform from EMRTransfer to kubernetes data platform from EMR
Transfer to kubernetes data platform from EMR창언 정
 
HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08Jesse Young
 
20090323 Phpstudy
20090323 Phpstudy20090323 Phpstudy
20090323 PhpstudyYusuke Ando
 
Web技術勉強会 第19回
Web技術勉強会 第19回Web技術勉強会 第19回
Web技術勉強会 第19回龍一 田中
 

Semelhante a Rails Deployment with NginX (20)

yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
SEASR Installation
SEASR InstallationSEASR Installation
SEASR Installation
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
Hp Linux
Hp LinuxHp Linux
Hp Linux
 
Working With Rails
Working With RailsWorking With Rails
Working With Rails
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHP
 
Grails紹介
Grails紹介Grails紹介
Grails紹介
 
High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)
 
MySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイントMySQL Clusterで高性能システムを構築する際のポイント
MySQL Clusterで高性能システムを構築する際のポイント
 
spring_jiaocheng
spring_jiaochengspring_jiaocheng
spring_jiaocheng
 
Spring基础教程
Spring基础教程Spring基础教程
Spring基础教程
 
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRFBe Afraid. Be Very Afraid. Javascript security, XSS & CSRF
Be Afraid. Be Very Afraid. Javascript security, XSS & CSRF
 
Transfer to kubernetes data platform from EMR
Transfer to kubernetes data platform from EMRTransfer to kubernetes data platform from EMR
Transfer to kubernetes data platform from EMR
 
HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08
 
20090323 Phpstudy
20090323 Phpstudy20090323 Phpstudy
20090323 Phpstudy
 
Web技術勉強会 第19回
Web技術勉強会 第19回Web技術勉強会 第19回
Web技術勉強会 第19回
 
Seize The Cloud
Seize The CloudSeize The Cloud
Seize The Cloud
 

Mais de Stoyan Zhekov

Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraStoyan Zhekov
 
Deployment on Heroku
Deployment on HerokuDeployment on Heroku
Deployment on HerokuStoyan Zhekov
 
Foreman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsForeman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsStoyan Zhekov
 
Social Network for spare parts
Social Network for spare partsSocial Network for spare parts
Social Network for spare partsStoyan Zhekov
 
Using XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationUsing XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationStoyan Zhekov
 
Websockets with ruby
Websockets with rubyWebsockets with ruby
Websockets with rubyStoyan Zhekov
 
Webhooks - glue for the web
Webhooks - glue for the webWebhooks - glue for the web
Webhooks - glue for the webStoyan Zhekov
 
Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Stoyan Zhekov
 

Mais de Stoyan Zhekov (12)

Multirotors
MultirotorsMultirotors
Multirotors
 
ZeroMQ
ZeroMQZeroMQ
ZeroMQ
 
Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
Sequel
SequelSequel
Sequel
 
Deployment on Heroku
Deployment on HerokuDeployment on Heroku
Deployment on Heroku
 
Foreman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsForeman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple components
 
Social Network for spare parts
Social Network for spare partsSocial Network for spare parts
Social Network for spare parts
 
Using XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationUsing XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking information
 
Websockets with ruby
Websockets with rubyWebsockets with ruby
Websockets with ruby
 
EventMachine
EventMachineEventMachine
EventMachine
 
Webhooks - glue for the web
Webhooks - glue for the webWebhooks - glue for the web
Webhooks - glue for the web
 
Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Rails Deployment with NginX

  • 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 サーバ ➲ 静的リクエストの処理 ● バックエンドのアプリケーションサーバ ➲ 動的リクエストの処理 ● デタベース ➲
  • 6. History Lesson Apache + CGI ➲ Apache + FastCGI ➲ Lighttpd + FastCGI ➲ Lighttpd + SCGI ➲ Litespeed ➲ etc. etc. (mod_fcgi, mod_ruby) ➲ 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
  • 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 を使います ➲