deploying on windows (it’s actually possible!) brian hogan new auburn personal computer services...

37
Deploying on Windows Deploying on Windows (it’s actually possible!) (it’s actually possible!) Brian Hogan Brian Hogan New Auburn Personal Computer Services LLC New Auburn Personal Computer Services LLC Contents copyright © 2007 Brian P. Hogan. Do not Contents copyright © 2007 Brian P. Hogan. Do not reproduce without permission. reproduce without permission.

Upload: jean-berry

Post on 26-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Deploying on WindowsDeploying on Windows(it’s actually possible!)(it’s actually possible!)

Brian HoganBrian HoganNew Auburn Personal Computer Services LLCNew Auburn Personal Computer Services LLC

Contents copyright © 2007 Brian P. Hogan. Do notContents copyright © 2007 Brian P. Hogan. Do notreproduce without permission.reproduce without permission.

OverviewOverview Deploying with MongrelDeploying with Mongrel Deploying with PenDeploying with Pen Deploying with Apache and MongrelDeploying with Apache and Mongrel Deploying behind IISDeploying behind IIS Other methodsOther methods PerformancePerformance

Why??Why??

You have no choiceYou have no choice It’s your “foot in the door”It’s your “foot in the door” You’re just stubbornYou’re just stubborn

Deployment StrategiesDeployment Strategies

MongrelMongrel Mongrel and PenMongrel and Pen Mongrel and ApacheMongrel and Apache Hiding behind IISHiding behind IIS Other optionsOther options

Before we beginBefore we begin

Get Ruby and Ruby on Rails installed Get Ruby and Ruby on Rails installed on your serveron your server

Get any other gems you needGet any other gems you need Make sure your app works in Make sure your app works in

production mode!production mode!– Demo app at Demo app at

http://svn.napcsweb.com/public/guestboohttp://svn.napcsweb.com/public/guestbook/k/

Hope, pray, or perform some sort of Hope, pray, or perform some sort of dance.dance.

Deploying with MongrelDeploying with Mongrel

Deploying with MongrelDeploying with Mongrel Install MongrelInstall Mongrel Install the Mongrel Service gemInstall the Mongrel Service gem Set it up as a serviceSet it up as a service

– Mongrel_rails service:install –n Mongrel_rails service:install –n “guestbook_4001” –p 4001 –e production“guestbook_4001” –p 4001 –e production

Set the service to start automaticallySet the service to start automatically

Deploying with MongrelDeploying with Mongrel

ProsPros– Easy to set upEasy to set up– Easy to maintainEasy to maintain– Great for a small application during Great for a small application during

development or demonstrationdevelopment or demonstration

Deploying with MongrelDeploying with Mongrel

ConsCons– No page cachingNo page caching– Does not scaleDoes not scale– Mongrel serves CSS, images, and Mongrel serves CSS, images, and

JavaScriptJavaScript

Deploying with MongrelDeploying with Mongreland Penand Pen

Add some load balancing!Add some load balancing!

Deploying with Mongrel and Deploying with Mongrel and PenPen

Install Mongrel and mongrel_serviceInstall Mongrel and mongrel_service Set it up as a service for each appSet it up as a service for each app

– Mongrel_rails service:install –n Mongrel_rails service:install –n “guestbook_4001” –p 4001 –e production“guestbook_4001” –p 4001 –e production

– Mongrel_rails service:install –n Mongrel_rails service:install –n “guestbook_4002” –p 4002 –e production“guestbook_4002” –p 4002 –e production

Set the services to start Set the services to start automaticallyautomatically

Deploying with Mongrel and Deploying with Mongrel and PenPen

Install Pen and Cygwin1.dll to c:\penInstall Pen and Cygwin1.dll to c:\pen– PenPen: :

http://siag.nu/pub/pen/pen-0.17.1a.exehttp://siag.nu/pub/pen/pen-0.17.1a.exe

– Cygwin1Cygwin1http://www.dll-files.com/dllindex/dll-files.shtml?cygwin1http://www.dll-files.com/dllindex/dll-files.shtml?cygwin1

Deploying with Mongrel and Deploying with Mongrel and PenPen

Install Pen as a serviceInstall Pen as a service– Download resource kit and install to c:\Download resource kit and install to c:\

reskitreskit– http://www.microsoft.com/downloads/dethttp://www.microsoft.com/downloads/det

ails.aspx?familyid=9d467a69-57ff-4ae7-ails.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd96ee-b18c4790cffd

Install Pen as serviceInstall Pen as service– C:\reskit\instsrv Pen c:\reskit\srvany.exeC:\reskit\instsrv Pen c:\reskit\srvany.exe

Deploying with Mongrel and Deploying with Mongrel and PenPen

Set Service propertiesSet Service properties– Open RegeditOpen Regedit– Go to HKLM\System\CurrentControlSet\Go to HKLM\System\CurrentControlSet\

Services\PenServices\Pen– Add a new key called PropertiesAdd a new key called Properties– Add three String values to Add three String values to ParametersParameters

keykey Application = c:\penApplication = c:\pen AppParameters = -f 4000 localhost:4001 AppParameters = -f 4000 localhost:4001

localhost:4002localhost:4002 AppDirectory = c:\penAppDirectory = c:\pen

Deploying with Mongrel and Deploying with Mongrel and PenPen

Start ServiceStart Service– net start pennet start pen

Remove ServiceRemove Service– sc delete pensc delete pen

Deploying with Mongrel and Deploying with Mongrel and PenPen

ProsPros– Free and simple load balancingFree and simple load balancing– Relatively quick setupRelatively quick setup– Performs moderately wellPerforms moderately well– Can balance over multiple machinesCan balance over multiple machines

Deploying with Mongrel and Deploying with Mongrel and PenPen

ConsCons– Still serving assets and cached pages Still serving assets and cached pages

with Mongrelwith Mongrel– Cumbersome if you have lots of appsCumbersome if you have lots of apps

Deploying with MongrelsDeploying with Mongrelsand Apacheand Apache

Deploying with Mongrel and Deploying with Mongrel and ApacheApache

Install ApacheInstall Apache– http://www.eng.lsu.edu/mirrors/apache/hhttp://www.eng.lsu.edu/mirrors/apache/h

ttpd/binaries/win32/apache_2.2.4-win32-ttpd/binaries/win32/apache_2.2.4-win32-x86-no_ssl.msix86-no_ssl.msi

– Install to c:\apacheInstall to c:\apache– Do Do NOTNOT install as a service – install on install as a service – install on

80808080

Deploying with Mongrel and Deploying with Mongrel and ApacheApache

Edit configurationEdit configuration– C:\apache\conf\httpd.confC:\apache\conf\httpd.conf

Uncomment these linesUncomment these linesLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule proxy_http_module modules/mod_proxy_http.soLoadModule rewrite_module modules/mod_rewrite.so LoadModule rewrite_module modules/mod_rewrite.so

– Add this to the bottomAdd this to the bottom Include conf/guestbook_proxy.confInclude conf/guestbook_proxy.conf

– Copy the apache configuration from Copy the apache configuration from http://svn.napcsweb.com/public/guestbook/cohttp://svn.napcsweb.com/public/guestbook/config/apache/guestbook_proxy.confnfig/apache/guestbook_proxy.conf to c:\apache\conf\ to c:\apache\conf\

Deploying with Mongrel and Deploying with Mongrel and ApacheApache

ProsPros– Best option for WindowsBest option for Windows

Super stableSuper stable Assets and cached pages served by Apache – Assets and cached pages served by Apache –

fastfast High-quality balancerHigh-quality balancer Almost identical configuration to LinuxAlmost identical configuration to Linux

Deploying with Mongrel and Deploying with Mongrel and ApacheApache

ConsCons– More difficult to configure and More difficult to configure and

understandunderstand If security is important, you’d better learn If security is important, you’d better learn

more about Apache before you deploy!more about Apache before you deploy!

– Uses more resourcesUses more resources– Apache may be a “no-no” for some Apache may be a “no-no” for some

reason.reason.

Deploying behind IISDeploying behind IIS

Hiding your Rails appsHiding your Rails apps

Deploying behind IISDeploying behind IIS Install ISAPI_RewriteInstall ISAPI_Rewrite

– Configure the rewriter (httpd.ini)Configure the rewriter (httpd.ini) RewriteProxy /RewriteProxy /guestbookguestbook(.*) http\://localhost:(.*) http\://localhost:80808080$1 [I,U]$1 [I,U]

Install the reverse_proxy_fix pluginInstall the reverse_proxy_fix plugin– ruby script/plugin install ruby script/plugin install

http://svn.napcsweb.com/public/reverse_proxy_fix/http://svn.napcsweb.com/public/reverse_proxy_fix/

Configure the pluginConfigure the plugin– Give it your forward-facing URL prefixGive it your forward-facing URL prefix

http://www.mydomain.com/myapphttp://www.mydomain.com/myapp

Start your Rails appStart your Rails app– Start Apache and your Mongrel instancesStart Apache and your Mongrel instances

Deploying behind IISDeploying behind IIS ProsPros

– Seamlessly graft many apps onto your Seamlessly graft many apps onto your main web servermain web server

– Use existing SSL certificates from IISUse existing SSL certificates from IIS– Use your existing authentication schemeUse your existing authentication scheme

Deploying behind IISDeploying behind IIS ConsCons

– Not freeNot free– Requires that all URLs are generated Requires that all URLs are generated

with url_forwith url_for– It’s an extra piece that can breakIt’s an extra piece that can break

Other StrategiesOther Strategies

Apache and FastCGIApache and FastCGI Don’t even bother.Don’t even bother.

– It’s slowIt’s slow– Not good for multiple appsNot good for multiple apps– It’s buggy too.It’s buggy too.

IIS and FastCGIIIS and FastCGI Microsoft is working on a new FastCGI Microsoft is working on a new FastCGI

adapter!adapter!– MayMay be built into the next IIS be built into the next IIS– No official plans to support RailsNo official plans to support Rails

But it does work!But it does work!

Other IIS and FastCGI methods are not Other IIS and FastCGI methods are not worth your time.worth your time.– Not made for multiple appsNot made for multiple apps– Not flexibleNot flexible– The non-MS FastCGI is not actively The non-MS FastCGI is not actively

maintainedmaintained

ConsiderationsConsiderations

Is Ruby Slower on Is Ruby Slower on Windows?Windows?

Much slowerMuch slower– 3-30 Requests / Second on Windows3-30 Requests / Second on Windows– 50-100 Requests / Second on Linux50-100 Requests / Second on Linux

Dual core Intel and AMD 64 chips Dual core Intel and AMD 64 chips speed things upspeed things up– Nowhere near Mac or Linux speedsNowhere near Mac or Linux speeds

RecommendationsRecommendations Small applicationSmall application

– Internal use, mostly read-onlyInternal use, mostly read-only– Small group of usersSmall group of users– 50,000 requests per day50,000 requests per day– Use a single Mongrel and cache your Use a single Mongrel and cache your

pagespages

RecommendationsRecommendations Large internal applicationLarge internal application

– Many concurrent usersMany concurrent users– Lots of transactionsLots of transactions– Use Pen and MongrelUse Pen and Mongrel

RecommendationsRecommendations Public-facing applicationPublic-facing application

– Many concurrent usersMany concurrent users– Mostly read-onlyMostly read-only– Use Apache and Mongrel with page Use Apache and Mongrel with page

cachingcaching

RecommendationsRecommendations Prepare to move to LinuxPrepare to move to Linux

– You’ll want the performanceYou’ll want the performance– Move your app servers to LinuxMove your app servers to Linux

Use Pen or Apache to balance on WindowsUse Pen or Apache to balance on Windows Use ISAPI_Rewrite, and Reverse_proxy_fix to Use ISAPI_Rewrite, and Reverse_proxy_fix to

hide your apps behind IIShide your apps behind IIS

Reasons to move to LinuxReasons to move to Linux You get to use automated deploymentYou get to use automated deployment

– Capistrano is *nix onlyCapistrano is *nix only You get a speed boostYou get a speed boost

– It’s just going to perform betterIt’s just going to perform better You can use Nginx and mongrel_clusterYou can use Nginx and mongrel_cluster

– Nginx is a simple web server and load Nginx is a simple web server and load balancerbalancer

You will eventually run out of resources You will eventually run out of resources on Windows.on Windows.– You need more Mongrel instances on Windows You need more Mongrel instances on Windows

to handle the load since Ruby runs slower.to handle the load since Ruby runs slower.

Questions?Questions?

Email Email [email protected]@napcs.com Google chat: Google chat: [email protected]@gmail.com