Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Polyglot Persistence for Spring Apps on OpenShift

Polyglot Persistence for Spring Apps on OpenShift

Polyglot Persistence for Spring Apps on OpenShift

Shekhar Gulati

June 22, 2012
Tweet

More Decks by Shekhar Gulati

Other Decks in Programming

Transcript

  1. INTERNAL ONLY | PRESENTER NAME 2 Polyglot Persistence for Spring

    Apps on OpenShift Shekhar Gulati Senior Consultant, Xebia 26 June 2012
  2. INTERNAL ONLY | PRESENTER NAME 4 • Widely used and

    understood • Tested in real environments • Great tools support • ACID semantics • Great framework support • ORM like hibernate • Spring • JDBC Relational databases have served us well..
  3. INTERNAL ONLY | PRESENTER NAME 6 Problems • Complex object

    graphs • Schema Evolution with time • Semi-structured data • Difficult to scale • One solution for every problem
  4. INTERNAL ONLY | PRESENTER NAME 8 We have to choose

    between what is right, and what is easy
  5. INTERNAL ONLY | PRESENTER NAME 9 Polyglot Persistence Using multiple

    data storage technologies, chosen based upon the way data is being used by individual applications or components of single application. • Martin Fowler
  6. INTERNAL ONLY | PRESENTER NAME 11 Lots of companies are

    going this way.. • Facebook • Twitter • Google • StumbleUpon • LinkedIn • Lots of other companies..
  7. INTERNAL ONLY | PRESENTER NAME 13 What is MongoDB? •

    Document Oriented database • JSON-style documents: Lists, Maps, primitives • Schema-less • Each document is heterogeneous, and may have completely unique structure compared to other documents. • Fast and horizontally scalable • Rich query language
  8. INTERNAL ONLY | PRESENTER NAME 14 MongoDB Terminology in comparison

    with RDBMS Database → Database Table → Collection Row → Document Index → Index
  9. INTERNAL ONLY | PRESENTER NAME 15 MongoDB in Action >

    use notebook switched to db notebook > show dbs local (empty) > var notebook = {"name":"RedHat Developer Day Notes","desc":"Notes on RedHat developer day","author":"shekhar"} > db.notebooks.insert(notebook) > db.notebooks.find({"author":"shekhar"}) { "_id" : ObjectId("4fe1c495e89c1726c32b4966"), "name" : "RedHat Developer Day Notes", "desc" : "Notes on RedHat developer day", "author" : "shekhar" }
  10. INTERNAL ONLY | PRESENTER NAME 16 Configurable writes : WriteConcern

    • Default : Fire and Forget • Other options • SAFE • Journal Safe • Fsync • Replica safe Speed is inversely proportional to Reliability
  11. INTERNAL ONLY | PRESENTER NAME 19 Benefits of PaaS •

    Lets developer focus on his job i.e. to write code. • Reduce cost and time to market • You develop “Cloud Aware “ applications from bottom up. • Improve developer productivity. • PaaS can help achieve Continuous delivery
  12. INTERNAL ONLY | PRESENTER NAME 20 As a developer it

    gives you power to prototype your ideas rapidly.
  13. INTERNAL ONLY | PRESENTER NAME 22 Introducing OpenShift • A

    free auto-scaling, cloud-based application platform from RedHat. • Multi Language, Multi Frameworks, Multi Cartridges. • Support Cloud Portability • No proprietary software. • Open source – OpenShift Origin
  14. INTERNAL ONLY | PRESENTER NAME 23 Other facts • Command

    Line,Web, Eclipse , Forge plugin, and Spring Roo plugin. • Client Tools for data stores • Runs on top of EC2 but free • Supports 3 applications per user. • 40,000 files, 1GB of storage, and 512MB Memory per gear • Multi tenant • Shell Access.
  15. INTERNAL ONLY | PRESENTER NAME 26 Sign up for OpenShift

    Sign up at https://openshift.redhat.com/app/account/new
  16. INTERNAL ONLY | PRESENTER NAME 27 Installing OpenShift client tools

    • Install Ruby 1.8 or above • Fedora / RHEL • yum install rubygem-rhc • Ubuntu • gem install json_pure • gem install rhc • Windows • Install ruby using Ruby installer • gem install rhc
  17. INTERNAL ONLY | PRESENTER NAME 29 Steps to deploy application

    on OpenShift • Create domain • Create application • Add cartridges – mongodb and mysql • Pull code from git repo • git push • Voila !! App is on Cloud
  18. INTERNAL ONLY | PRESENTER NAME 30 Domain Management • Create

    domain by typing command • rhc domain create -n summit -l <login> -d • View the domain information • rhc domain show -l <login> • Update domain name • rhc domain alter -n summit-other -l <login> • Destroy domain • rhc domain destroy -n summit -l <login>
  19. INTERNAL ONLY | PRESENTER NAME 31 Creating an application •

    To create an application • rhc app create -a notebook -l <login> -t jbossas-7 -d • Application will be running at • http://notebook-summit.rhcloud.com/
  20. INTERNAL ONLY | PRESENTER NAME 33 Pulling application source code

    • git remote add notebook -m master [email protected] :shekhargulati/notebook.git • git pull -s recursive -X theirs notebook master
  21. INTERNAL ONLY | PRESENTER NAME 34 Adding MySQL and MonogoDB

    • rhc app cartridge add -a notebook -c mongodb-2.0 -l <login> • rhc app cartridge add -a notebook -c mysql--l <login>
  22. INTERNAL ONLY | PRESENTER NAME 36 If that was not

    enough.. There are lot of other goodies
  23. INTERNAL ONLY | PRESENTER NAME 38 Add Jenkins support •

    rhc app create -a jenkins -t jenkins-1.4 -l <login> • rhc app cartridge add -a notebook -c jenkins-client-1.4 -l <login>
  24. INTERNAL ONLY | PRESENTER NAME 40 In case you want

    to know my details.. • Senior Java Consultant at Xebia • Spring portfolio projects , Big Data, NoSQL, Cloud enthusiast. • Freelance Writer • [email protected] • Twitter handle : shekhargulati