Top Banner
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.
37

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

Dec 26, 2015

Download

Documents

Jean Berry
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Deploying on Windows (it’s actually possible!) Brian Hogan New Auburn Personal Computer Services LLC Contents copyright © 2007 Brian P. Hogan. Do not reproduce.

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.

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

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

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

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

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

Deployment StrategiesDeployment Strategies

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

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

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.

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

Deploying with MongrelDeploying with Mongrel

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

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

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

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

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

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

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

Deploying with MongrelDeploying with Mongreland Penand Pen

Add some load balancing!Add some load balancing!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Deploying with MongrelsDeploying with Mongrelsand Apacheand Apache

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

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

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

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\

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

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

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

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.

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

Deploying behind IISDeploying behind IIS

Hiding your Rails appsHiding your Rails apps

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

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

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

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

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

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

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

Other StrategiesOther Strategies

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

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.

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

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

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

ConsiderationsConsiderations

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

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

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

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

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

RecommendationsRecommendations Large internal applicationLarge internal application

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

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

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

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

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

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

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.

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

Questions?Questions?

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