SlideShare a Scribd company logo
12 Factor App
Best Practices for JRuby Deployment
Joe Kutner
@codefinger
JVM Platform Owner
@Heroku
Joe Kutner
deployment, deployment, deployment, deployment
This book is wrong now!
.war
Traditional Deployment
.jar
Modern Deployment
Make JAR
Not WAR
2005 2015
WAR files JAR files
App Servers Microservices
Hot Deploy Continuous Deploy
Server in a closet Heroku/AWS/etc
12-factor-jruby
12 Factor App
a methodology
Scalability
Maintainability
Portability
• Immutable
• Ephemeral
• Declarative
• Automated
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Thank You!
Goodbye!
(just kidding)
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Use Version Control
12-factor-jruby
12-factor-jruby
BAD
BAD
App #1 App #2
Submodules
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Never rely on implicit
existence of system-wide
packages
Explicitly declare
and isolate
dependencies
Don’t check JAR files into Git
12-factor-jruby
JBundler
Jarfile
jar 'org.yaml:snakeyaml'
jar 'org.slf4j:slf4j-simple', '>1.1'
$ gem install jbundler
...
$ jbundle install
...
$ jbundle console
...
server.rb
require 'jbundler'
java_import 'org.slf4j.Logger'
$ jbundle install --vendor
...
$ tree vendor/jars/
vendor/jars/
!"" io
#   $"" netty
#   $"" netty-all
#   $"" 4.0.28.Final
#   $"" netty-all-4.0.28.Final.jar
$"" jbundler.rb
4 directories, 2 files
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
• Resource handles to the database,
Memcached, and other backing services
• Credentials to external services such as
Amazon S3 or Twitter
• Per-deploy values such as the canonical
hostname for the deploy
Anything that changes between
deployment environments:
(does not include things like config/routes.rb)
Configuration is…
Configuration should
be strictly separated
from code
Don’t check passwords into Git
12-factor-jruby
Can you make your app open source
at any moment, without compromising
any credentials?
Litmus Test
Configuration belongs
in the environment,
not in the application
database.yml
dev:
username: everyone
password: 1234567
…
test:
username: everyone
password: 1234567
…
production:
username: admin
password: 89haiusdf90fasd
...
BAD
database.yml
production:
url: <%= ENV['DATABASE_URL']%>
GOOD
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
12-factor-jruby
database.yml
production:
url: <%= ENV['DATABASE_URL']%>
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
build, release, run
$ jrubyc ...
$ rake assets:precompile
$ warble executable war
$ ./gradlew build
build
$ heroku deploy:jar -j myapp.war
$ mvn heroku:deploy
$ scp myapp.war prod-server:~
$ docker push ...
release
$ java -jar myapp.war
$ bundle exec puma ...
run
$ /var/tomcat/start.sh
$ service tomcat start
$ torquebox start
$ git push heroku master
build,
release,
& run
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
DEMO!
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Processes should be stateless
sticky sessions
😞
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
The twelve-factor app
is completely self-contained
The web app exports HTTP
as a service by binding to a port
.war
Traditional Deployment
.jar
Modern Deployment
Dropwizard
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
GIL
RELAX BRO, I GOT THIS…
Scale Up
Scale Out
web.1
web.2
worker.1 clock.1
Workload Diversity
NumberofProcesses
worker.2
worker.3
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Graceful shutdown
Quick startup
Resilience to failure
Servers are not pets
Servers are cattle
Application Servers are
not disposable
Microservices are
disposable
Easy to replace
Decoupled from
external infrastructure
Easy to modify
Microservices
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
dev
sqlite
postgres
stage
mysql
postgres
prod
postgres
postgres
=
≠
=
=
≠
=
dev
webrick
puma
stage
puma
puma
prod
unicorn
puma
=
≠
=
=
≠
=
disposable
reproducible
parity
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Admin tasks should be
run in isolated processes
$ heroku run jirb
Running `rails console` attached to terminal... up, run.1594
Loading production environment (Rails 4.1.4)
irb(main):001:0>
web1
web2
web3
admin
The 12 Factors
• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
http://12factor.net
http://jkutner.github.io
warble executable war1.
gem install jbundle2.
Remove all passwords3.
Kill your app. Then restart it. Time it.4.
What next?
Joe Kutner
@codefinger
JVM Platform Owner
@Heroku
http://www.slideshare.net/jkutner/12-factor-jruby
12-factor-jruby
12-factor-jruby

More Related Content

PDF
12 Factor Scala
PDF
4 JVM Web Frameworks
PPTX
12 Factor Apps and Cloud Foundry - Twin Cities Code Camp
PDF
JavaOne 2015: 12 Factor App
PPTX
Expect the unexpected: Anticipate and prepare for failures in microservices b...
PPTX
Alfresco DevCon 2019 Performance Tools of the Trade
PPTX
#JavaOne What's in an object?
PDF
5 steps to take setting up a streamlined container pipeline
12 Factor Scala
4 JVM Web Frameworks
12 Factor Apps and Cloud Foundry - Twin Cities Code Camp
JavaOne 2015: 12 Factor App
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Alfresco DevCon 2019 Performance Tools of the Trade
#JavaOne What's in an object?
5 steps to take setting up a streamlined container pipeline

What's hot (20)

PPTX
Hybrid Mobile Development with Apache Cordova and
PDF
Integrating Alfresco @ Scale (via event-driven micro-services)
 
PDF
Continuous integration and delivery for java based web applications
PPTX
Developing in the Cloud
PDF
Camel oneactivemq posta-final
PDF
The Dark Side of Single Page Applications
PPTX
Why Play Framework is fast
PPTX
Integrating Microservices with Apache Camel
ODP
Developing Microservices with Apache Camel
PDF
Kafka Needs No Keeper
PDF
Grails 3.0 Preview
PDF
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
PPTX
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
PPTX
Essential Camel Components
PDF
Java Serverless in Action - Voxxed Banff
PDF
CQRS and Event Sourcing
PDF
Slaying Monoliths with Node and Docker
PPTX
Java script nirvana in netbeans [con5679]
PDF
Jelastic - DevOps for Java with Docker Containers - Madrid 2015
PPTX
Scala in the Wild
Hybrid Mobile Development with Apache Cordova and
Integrating Alfresco @ Scale (via event-driven micro-services)
 
Continuous integration and delivery for java based web applications
Developing in the Cloud
Camel oneactivemq posta-final
The Dark Side of Single Page Applications
Why Play Framework is fast
Integrating Microservices with Apache Camel
Developing Microservices with Apache Camel
Kafka Needs No Keeper
Grails 3.0 Preview
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Real-world #microservices with Apache Camel, Fabric8, and OpenShift
Essential Camel Components
Java Serverless in Action - Voxxed Banff
CQRS and Event Sourcing
Slaying Monoliths with Node and Docker
Java script nirvana in netbeans [con5679]
Jelastic - DevOps for Java with Docker Containers - Madrid 2015
Scala in the Wild
Ad

Similar to 12-factor-jruby (20)

PDF
12 Factor App: Best Practices for JVM Deployment
PDF
TDC2017 | São Paulo - Trilha Cloud Computing How we figured out we had a SRE ...
PDF
12 factor app
PDF
Creating Scalable JVM/Java Apps on Heroku
PPTX
12 Factor App Methodology
PDF
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
PPTX
Microservices
PPTX
Docker12 factor
PDF
The Twelve Factor App - Pivotal Tracker
PDF
Twelve factor apps
PDF
jdays 2015
PPTX
12 factor app
PDF
Twelve-Factor App: Software Application Architecture
PPTX
Hello cloud 6
PDF
Hosting Ruby Web Apps
PDF
Learn how to Leverage Kubernetes to Support 12 Factor for Enterprise Apps
PDF
Cloud Native Development
PDF
PDF
PDF
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
12 Factor App: Best Practices for JVM Deployment
TDC2017 | São Paulo - Trilha Cloud Computing How we figured out we had a SRE ...
12 factor app
Creating Scalable JVM/Java Apps on Heroku
12 Factor App Methodology
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
Microservices
Docker12 factor
The Twelve Factor App - Pivotal Tracker
Twelve factor apps
jdays 2015
12 factor app
Twelve-Factor App: Software Application Architecture
Hello cloud 6
Hosting Ruby Web Apps
Learn how to Leverage Kubernetes to Support 12 Factor for Enterprise Apps
Cloud Native Development
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Ad

More from Joe Kutner (19)

PDF
Fantastic Buildpacks and Where to Find Them
PDF
2019 Texas Star Party
PDF
10 Mistakes Hackers Want You to Make
PDF
NASA Space Apps Expo
PDF
NASA Space Apps
PDF
Why Heroku Loves JHipster
PDF
What the Struts?
PDF
Async and Non-blocking IO w/ JRuby
PDF
I can't believe it's not a queue: Kafka and Spring
PDF
Deploying JHipster Microservices
PPTX
Measuring doubles with 8&quot; neaf copy
PDF
Java 20
PDF
Programming JVM Bytecode with Jitescript
PDF
Programming JVM Bytecode
PDF
DevLink: Healthy Programmer
PDF
Build a Bigger Brain
KEY
Deploy, Scale and Sleep at Night with JRuby
KEY
Deploying JRuby Web Applications
KEY
Deploying with JRuby
Fantastic Buildpacks and Where to Find Them
2019 Texas Star Party
10 Mistakes Hackers Want You to Make
NASA Space Apps Expo
NASA Space Apps
Why Heroku Loves JHipster
What the Struts?
Async and Non-blocking IO w/ JRuby
I can't believe it's not a queue: Kafka and Spring
Deploying JHipster Microservices
Measuring doubles with 8&quot; neaf copy
Java 20
Programming JVM Bytecode with Jitescript
Programming JVM Bytecode
DevLink: Healthy Programmer
Build a Bigger Brain
Deploy, Scale and Sleep at Night with JRuby
Deploying JRuby Web Applications
Deploying with JRuby

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
KodekX | Application Modernization Development
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
cuic standard and advanced reporting.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KodekX | Application Modernization Development
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
cuic standard and advanced reporting.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?

12-factor-jruby