Play! + GAE
 Play! + Heroku


  @hagikuratakeshi
•       (             )
Twitter @hagikuratakeshi

•
•       (                 )

•
(Aws Management Console       )

•           Hadoop
•
Play!
BookShelfs
•http://books-share.appspot.com/
BookShelfs
•


•
•
(    BookShelves)
BookShelfs

•Play!(Java) + GAE + Siena
•            Amazon API

•          Twitter4j
Play! ?

•Java
•
•@ikeike443
GAE ?

•
•Play!    GAE Module

 •> play install gae
•PaaS
Siena ?

•GAE Datastore O/R
•Play! Module
 •> play install siena
•Playframework           GAE/
 Siena
GAE
※     Dis
GAE
•
•$8/
    • SpinUp      Always On ($0.30/ )
     (    3Instance     )
•
•$180/
$100
Heroku
•Ruby PaaS
 (Java, Clojure, Node.js       )

•Play!         !!

•No vendor lock in !!
•    (Small Start          )
Heroku
GAE, Siena
•$ heroku login
•$ git init
•$ git add .
•$ git commit -m init
•$ heroku create --stack cedar
•$ git push heroku master
•http://bookshelfs-siena-
 local.herokuapp.com/
•Siena GAE

 →Heroku
 Deploy
��������������
→Siena
   Model
Heroku   PostgreSQL
JPA
models
Siena 2.0          GAE
 MySQL/PostgreSQL/Hbase

�����������������
Siena/PostgreSQL
1



•Model   List


 →
2


•Model
 User -> Account
 PostgreSQL User
 Table
GAE Module
•GAE Module


 •Task Queue (Tweet Queueing)
 • com.google.appengine.api.datastore.Blob
  •
KVS -> RDB
•GAE BigTable -> PostgreSQL

 →
 → KVS
 → RDB


 →
KVS
•

Book             Account

id     account   id    name

101     A01      A01   User1
102     A01      A02   User2
(1/2)
•
    Book
    id    account name

    101    A01   User1
    102    A01   User1
(2/2)
    •                      Java

@Override
public JsonElement serialize(Book book, Type type) {


	 Account owner = Account.findById(book.ownerUserId);
	 result.add("owner", gson.toJsonTree(owner));


}
RDB
•
 →

•RDB -> KVS

 →        join   SQL
•BookShelfs            Java


 → BigTable (   KVS)


 →
DB Index               (1/3)
•GAE     filter, order
 Query Index
         -> deploy
 → datastore-indexes-auto.xml
DB Index                  (2/3)
  List<Borrow> borrows =
  Borrow.all().filter("borrowerUserId",userId)
	 	 	 .filter("status ", BookStatus.RETURNED)
	 	 	 .order("-createdAt")
	 	 	 .fetch();	
	   	
                                 Index
DB Index               (3/3)
•Siena PostgreSQL
           Index annotation
                Index
 →        Index
            ?
 →                (fullscan, sort)
Heroku


$ git commit
$ git push heroku master
•http://bookshelfs-
 postgres.herokuapp.com/
Heroku


GAE
GAE      Datastore CSV
                 URL:
http://d.hatena.ne.jp/eller/20110103
Heroku      PostgreSQL

•$ heroku db:push
 → DB      push
                    sqlite
     PostgreSQL CSV
GAE → Heroku
Deploy

•
•GAE -> $ play gae:deploy
•Heroku ->
    $ git push heroku master
    (git     )
•Heroku           (2011/11 )

 •GAE -> $180
  (BookShelfs     )

 •Heroku -> $0   $15
  (Shared Database )
•Heroku    SpinUp


 →Amazon Ec2        Instance


•DB
Heroku
Addon
MongoDB   Hosting Addon
MongoDB     Module
    Play!
    → Morphia
Morphia
package models;

import   play.data.validation.Email;
import   play.data.validation.Required;
import   play.modules.morphia.Model;       Morphia     Model
import   play.modules.morphia.Blob;
import   com.google.code.morphia.annotations.Entity;

@Entity
public class User extends Model {

    @Email
    @Required
    public String email;

    @Required
    public String password;
Model


→Siena
Siena MongoDB
 PersistenceManager


��������������
1
Siena 2.0
Siena

application.conf
Mongo     PersistenceManager


             ↓
play.modules.siena.SienaPlugin
application.conf
db=mongodb
siena.mongodb.hostnames=dbh55.mongolab.com:
27557
siena.mongodb.databaseName=heroku_appxxxxxxxx
siena.mongodb.userName=heroku_appxxxxxxx
siena.mongodb.password=xxxxxxxxxxxxx
•http://bookshelfs-
 mongo.herokuapp.com/
MongoDB
DB


        Siena-MongoDB
    Merge
→
•2011/11         Heroku
 PostgreSQL or MongoDB
•          OpenSource

•Siena-MongoDB          Merge
•No vendor lock in

 →Siena              PostgreSQL



•Play! + Heroku
• GAE (                          URL
 • http://books-share.appspot.com/
• Heroku
 • Siena-GAE(Ec2                     )

   • http://bookshelfs-siena-local.herokuapp.com/
 • Siena-PostgreSQL
   • http://bookshelfs-postgres.herokuapp.com/
 • Siena-MongoDB (                                  )

   • http://bookshelfs-mongo.herokuapp.com/
2011/10/08_Playframework_GAE_to_Heroku

2011/10/08_Playframework_GAE_to_Heroku