java tech & tools | deploying java & play framework apps to the cloud | sandeep bhanot

31
Deploying Java and Play! Apps on Heroku Sandeep Bhanot @cloudysan

Upload: jax-london

Post on 15-May-2015

2.517 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Deploying Java and Play!

Apps on Heroku

Sandeep Bhanot

@cloudysan

Page 2: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Proprietary & Confidential

Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such

uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ

materially from the results expressed or implied by the forward-looking statements we make. All statements other than

statements of historical fact could be deemed forward-looking, including any projections of product or service availability,

subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of

management for future operations, statements of belief, any statements concerning new, planned, or upgraded services

or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and

delivering new functionality for our service, new products and services, our new business model, our past operating

losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting,

breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible

mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to

expand, retain, and motivate our employees and manage our growth, new releases of our service and successful

customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger

enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc.

is included in our annual report on Form 10-Q for the most recent fiscal quarter ended April 30, 2011. This documents

and others containing important disclosures are available on the SEC Filings section of the Investor Information section of

our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not

currently available and may not be delivered on time or at all. Customers who purchase our services should make the

purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and

does not intend to update these forward-looking statements.

Page 3: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Once upon a time….

Tim wanted to develop a Java app……

Page 4: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

So he got to work….

• Acquire and provision all the H/W (Servers, Load Balancers, Routers etc.)

• Install, configure and tune the entire S/W stack (OS, Web/App Server, DB etc.)

• Configure env. for Application services like Routing, Clustering, Load Balancing,

• Patch and upgrade the H/W and S/W stack

Cost

DR, Caching, DB Replication etc ($$$)

Agility

Page 5: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

One day….

Tim decided to try this ‘Cloud’ thingy……

Page 6: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

So he tried an IAAS provider…. • NO H/W to buy/install/configure!

• Still has to configure and tune the entire S/W stack (OS, Web/App Server, DB etc.)

• Still has to configure (and sometime code) env. for Application services like

• Patch and upgrade the S/W stack

Scaling, Routing, Clustering, Load Balancing, DR, DB replication etc

Cost

Agility

Page 7: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Finally….

Tim heard of Heroku

Page 8: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

When Tim met Heroku…. • NO Servers

• Managed S/W stack (OS, Web/App Server, DB etc.)

• Application services like Routing, Load Balancing and DR built-in

• Elastic scaling

• git push heroku master

Focus on your Code. Period.

Cost

Agility

Page 9: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Heroku = Polyglot Cloud Platform

402,550+ Apps Running on Heroku

Page 10: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

$ heroku create –s cedar

$ git push heroku master

Page 11: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Create more web processes:

$ heroku scale web=2

What processes are running:

$ heroku ps

Page 12: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Check the logs:

$ heroku logs

Page 13: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

View releases:

$ heroku releases

Rollback:

$ heroku rollback

Page 14: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Run a process:

$ heroku run "your bash command"

Page 15: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot
Page 16: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Environment (Runtime, configuration, etc)

Ingredients (Dependencies, app, services, etc)

Process (Build, assemble, start, etc)

Environment + Ingredients + Process = web 1!

Environment + Ingredients + Process = web 2!

Deploying web apps...

Page 17: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

$ heroku config

DATABASE_URL = postgres://blah:[email protected]/blah

JAVA_OPTS = -Xmx384m -Xss256k -XX:+UseCompressedOops

MAVEN_OPTS = -Xmx384m -Xss256k -XX:+UseCompressedOops

PATH = .maven/bin:/usr/local/bin:/usr/bin:/bin

REDISTOGO_URL = redis://redistogo:[email protected]:9291/

REPO = /app/.m2/repository

Externalize Environment Variables

Page 18: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Ingredients defined (pom.xml)

<dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>${jetty.version}</version> </dependency> <dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jsp-2.1-glassfish</artifactId> <version>2.1.v20100127</version> </dependency> <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.0-801.jdbc4</version> </dependency>

Page 19: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

web: sh target/bin/webapp

Process defined (Maven + Procfile)

Page 20: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Don't Share-Something

Page 21: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Move state to the isolated & independent edges

- UI state -> client

- Permanent state -> external data stores

Share-Nothing

Page 22: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Deploy an app on Heroku

1. Create a Java Web App

2. Add a Procfile

3. Commit to a git repo

4. Create an app on Heroku

5. “git push” to Heroku

6. Scale and monitor on Heroku

Page 23: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Connect to a Database

• Free shared PostgreSQL DB

• Dedicated & managed PostgreSQL DB

• Amazon RDS MySQL & Oracle

• NoSQL Add-ons (Redis, MongoDB, etc)

• Database.com

• Or do your own thing

Page 24: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Heroku: postgres://[username]:[password]@[server]/[db-name]

JDBC: jdbc:postgresql://[server]/[db-name]?user=[username]&password=[password]

Transform: dbUrl = dbUrl.replaceAll("postgres://(.*):(.*)@(.*)",

"jdbc:postgresql://$3?user=$1&password=$2");

Transform DATABASE_URL

Page 25: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Create a Worker Process

1. Create a process

2. Update the Procfile

3. Push to Heroku

4. Scale the workers

Page 26: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Using a Heroku Add-on

• Find an Add-on: http://addons.heroku.com

• Activate the Add-on

• Use the service

• Push to Heroku

Page 27: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Play!

• A Java framework for Web Applications

• Non Servlet or JEE based

• A full stack framework

• Focuses on productivity and fun

Page 28: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

Play! on Heroku

1. Create Play app

2. Add app to git repo

3. Create app on Heroku

4. Push app to Heroku

Page 29: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

750 free dyno hours

per month per app

Page 30: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot

heroku.com/java

github.com/heroku/java-workbook

@cloudysan

Page 31: Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sandeep Bhanot