Web And App Servers

45
Application/Web Server Sapna Solutions

description

What are application and web servers. What and how to configure application server. Basic fundamental and how it works for me.

Transcript of Web And App Servers

Page 1: Web And App Servers

Application/Web ServerSapna Solutions

Page 2: Web And App Servers

Sapna Solutions

2

One Rails instance handles all requests Rails is single-threaded: There is only one concurrent request

Simple Rails Setup

Page 3: Web And App Servers

Sapna Solutions

3

Rails Setup

Page 4: Web And App Servers

Sapna Solutions

4

Typical Rails Setup

A load-balancer distributes the incoming requests

Some load-balancers will deliver static requests themselves

Several Rails instances handle all requests

Number of concurrent requests equals number of Rails instances

Page 5: Web And App Servers

Sapna Solutions

5

Deployment Questions

Page 6: Web And App Servers

Sapna Solutions

6

Deployment Questions

Page 7: Web And App Servers

SERVERS

Rails Application Server

FastCGI

Mongrel

mod_rails / Phussion Passenger

JRuby + Glassfish & Co.

Proxy/Web Server

Apache2

Nginx

Lighttpd

HA-Proxy

Sapna Solutions

7

Page 8: Web And App Servers

FastCGI

Protocol to communicate with long-running CGI applications

Usage of either mod_fcgi with Apache 1.3 or mod_fcgi with Lighttpd

Proxy local and remote FastCGI instances

Oldest way of deploying Rails

Deprecated and unstable

Hard to debug (FastCGI protocol)

Sapna Solutions

8

Page 9: Web And App Servers

Sapna Solutions

9FastCGI

Page 10: Web And App Servers

Sapna Solutions

10

Page 11: Web And App Servers

Sapna Solutions

11

Mongrel

Page 12: Web And App Servers

Mongrel

Developed by Zed Shaw as an alternative to FastCGI

Complete HTTP-Server that can load arbitrary Ruby-servlets

Built-in Rails support

Sapna Solutions

12

Page 13: Web And App Servers

Sapna Solutions

13Mongrel

Page 14: Web And App Servers

Sapna Solutions

14Mongrel

Page 15: Web And App Servers

Mongrel

Very robust

Strict HTTP parser

Easy to debug (HTTP!)

Used to be defacto deployment setup with Apache 2.2 and mod_proxy_balancer

Can be a bit difficult to setup (mongrel_cluster, ports, Apache)

Not so easy on mass/virtual hosting

Sapna Solutions

15

Page 16: Web And App Servers

Mod_rails a.k.a Phusion Passenger

Sapna Solutions

16

Page 17: Web And App Servers

Mod_rails a.k.a Phusion Passenger

Module for Apache 2.2 (and Nginx)

Allows Apache to control Rails instances

Apache starts and stops application instances depending on the application load

Able to run any Rack-compatible Ruby application (Merb, Sinatra & Co.)

Only manages Rails on one host - no remote instances

Combine with HTTP-Proxy / balancing solution

Sapna Solutions

17

Page 18: Web And App Servers

Install Phusion Passenger Install Apache module

Sapna Solutions

18

Load and activate in Apache

Page 19: Web And App Servers

Customized Phusion Passenger

Sapna Solutions

19

Page 20: Web And App Servers

Control Phusion Passenger

Sapna Solutions

20

Restart after deployment:

Page 21: Web And App Servers

Phusion Passenger

Sapna Solutions

21

Page 22: Web And App Servers

Phusion Passenger

Sapna Solutions

22

Page 23: Web And App Servers

Phusion Passenger

Sapna Solutions

23

Page 24: Web And App Servers

Apache 2.2

Apache 2.2 introduced mod_proxy_balancer

mod_proxy_balancer can speak to multiple backends and balance requests

Apache can acts as a pure proxy or can also serve static files

Sapna Solutions

24

Page 25: Web And App Servers

Reco

mm

ended

Setu

ps

Sapna Solutions

25

Page 26: Web And App Servers

Small Site

Sapna Solutions

26

Page 27: Web And App Servers

Medium Site

Sapna Solutions

27

Page 28: Web And App Servers

Sapna Solutions

28

Page 29: Web And App Servers

Sapna Solutions

29Heavy Static Files

Page 30: Web And App Servers

Sapna Solutions

30

Page 31: Web And App Servers

Sapna Solutions

31Application Server Handler

Page 32: Web And App Servers

Sapna Solutions

32RACK

Page 33: Web And App Servers

Sapna Solutions

33Rack Handler

Page 34: Web And App Servers

Sapna Solutions

34Rack Supports

Page 35: Web And App Servers

Sapna Solutions

35What are we using?

Speedy Rails (vps213 and vps214) (Canada)

Apache2

Ruby Enterprise(1.8)

Phusion Passenger

MySql

Build, Staging and Production Environments

Every RAILS APP log maintained

Page 36: Web And App Servers

Sapna Solutions

36

Where our applications reside?

cd /var/www/apps/

Login to VPS 214

Sudo su - deploy

Page 37: Web And App Servers

Sapna Solutions

37How to debug?

APACHE CONF file (path to app)

Host <domainname>

Checkout ip address serving it

Page 38: Web And App Servers

DEPLOYMENT

Sapna Solutions

38

Page 39: Web And App Servers

Sapna Solutions

39

Page 40: Web And App Servers

We prefer

Sapna Solutions

40

Page 41: Web And App Servers

Sapna Solutions

41How to DEPLOY?

EASIEST AND TRUSTED WAY

CAPISTRANO

CUSTOM TASKS

Page 42: Web And App Servers

Sapna Solutions

42CAPISTRANO Requirements

Page 43: Web And App Servers

Sapna Solutions

43What does Capistrano do?

Page 44: Web And App Servers

Sapna Solutions

44Capistrano Deployment Cycle

Page 45: Web And App Servers

Sapna Solutions

45