jdays 2015
-
Upload
joe-kutner -
Category
Internet
-
view
308 -
download
0
Transcript of jdays 2015
12 Factor AppBest Practices for JVM Deployment
12 Factor AppBest Practices for JVM Deployment
Java doesn’t suck when you do things this way
XML sucks
10 page wikis to set up your app suck
Incongruent environments suck
DEV ≠ PROD
Apps that take more than 30 seconds to start up suck
Recompiling your entire codebase after fixing a typo sucks
Monolithic apps suck
The Java language sucks
But Java doesn’t suck
What does modern Javadevelopment look like?
Joe Kutner@codefinger
JVM Languages Owner@Heroku
Joe Kutner
12 Factor Appa methodology
ScalabilityMaintainability
Portability
12 Factor Appa methodology
ContinuousDelivery
12 Factor Appa methodology
Sleepingat
Night
Continuous Delivery
Slee
p
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
Graceful shutdown
Quick startup
Resilience to failure
| Disposability |
| Disposability |
Application Servers are not disposable
Application Servers are not disposable
| Disposability |
| Disposability |
Microservices are disposable
| Disposability |
Easy to replace
Decoupled from external infrastructure
Easy to modify
| Disposability |
Microservices
JavaGroovy
ScalaClojure
Scala Scala
Standalone ➤ Disposable
| Disposability |
Bootable ➤ Disposable
| Disposability |
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
=
≠
=
=
≠
=
| Disposable | Parity |
dev
jetty
jetty
stage
tomcat
jetty
prod
jboss
jetty
=
≠
=
=
≠
=
| Disposable | Parity |
| Disposable | Parity |
dev
jetty
{}
stage
tomcat
{}
prod
jboss
{}
=
≠
=
=
≠
=
.war
Traditional JVM Deployment
.jar
Modern JVM Deployment
Reproducible ➤ Parity
| Disposable | Parity |
Reproducible ➤ Disposable
| Disposable | Parity |
The 12 Factors• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
Configuration belongs in the environment, not in the application
Configuration should be strictly separated from code
| Disposable | Parity | Config |
Linux
Tomcat
WAR
server.xml
context.xml
web.xml
/etc/...
| Disposable | Parity | Config |
Environment
Java Application
PATH
DATABASE_URL
AWS_ACCESS_TOKEN
JAVA_OPTS
| Disposable | Parity | Config |
Containerless ➤ Separation
| Disposable | Parity | Config |
Containerless ➤ Parity
| Disposable | Parity | Config |
Containerless ➤ Disposable
| Disposable | Parity | Config |
Containerless ➤ 12 Factor App
| Disposable | Parity | Config |
Containerless Containerless Containerless
| Disposable | Parity | Config |
Dropwizard
@Configuration@EnableAutoConfiguration@ComponentScanpublic class Main { public static void main(String[] args) { SpringApplication.run(Main.class, args); }}
import org.eclipse.jetty.server.Server;import org.eclipse.jetty.servlet.*;
public class Main { public static void main(String[] args) throws Exception { Server server = new Server(); ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS); context.setContextPath("/"); server.setHandler(context); context.addServlet(new ServletHolder(new App()), "/*"); server.start(); server.join(); }}
(defn -main [& [port]] (jetty/run-jetty (site #'app) {:port port :join? false}))
// Play example does not require any code
The 12 Factors• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
| Disposable | Parity | Config | Concurrency |
Scale Up
Scale Out
| Disposable | Parity | Config | Concurrency |
web.1
web.2
worker.1 clock.1
Workload Diversity
Num
ber o
f Pro
cess
es
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
| Disposable | Parity | Config | Concurrency | Admin |
Admin tasks should be run in isolated processes
web1
web2
web3
admin
| Disposable | Parity | Config | Concurrency | Admin |
The 12 Factors• Codebase
• Dependencies
• Config
• Backing services
• Build, release, run
• Processes
• Port binding
• Concurrency
• Disposability
• Dev/prod parity
• Logs
• Admin processes
TODOList
Install the JDK
Three Steps to Setup Your App
Clone the SCM repo
Run the app
Get it under 30 seconds
Time your app’s startup
Get a stopwatch
Make Your App Startup Quick
Deploy or Scale Your App in One Step
Handle requests
Deploy the app
Provision a new environment
http://12factor.net
Java Doesn’t Suck
Java Doesn’t Suck(if you use it the right way)
Joe Kutner@codefinger
JVM Languages Owner@Heroku
http://www.slideshare.net/jkutner/jdays-2015