This document provides an overview of deploying Rails applications with NginX. It discusses using Mongrel as a web server for Rails and how NginX can be used as a reverse proxy for load balancing across Mongrel instances. The document also covers NginX configuration options and optimizations for serving static files, caching, and balancing requests across backends.
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/
●
12. 動的リクエスト
Mongrel != Rails
➲
Mongrel IS thread safe
➲
Rails IS NOT thread save (CGI.rb)
➲
Giant Mutex Lock around the Dispatcher
➲
Mongrel は時間単位で 1 リクエストを提供
➲
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;
...
}