SlideShare a Scribd company logo
1 of 36
Download to read 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 を使います
➲
質問

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to Rails Deployment with NginX and NginX Configuration

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回龍一 田中
 

Similar to Rails Deployment with NginX and NginX Configuration (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
 

More from 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
 

More from 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)
 

Recently uploaded

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Rails Deployment with NginX and NginX Configuration

  • 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 を使います ➲