Thinking Beyond RDBMS :
OPENSHIFT
Building Polyglot Persistence Java
Applications
Workshop

PRESENTED
BY

Shekhar
Gulati
WHO AM I?

•

Shekhar Gulati -- OpenShift Developer Evangelist

•

Java / JavaScript /Python / NoSQL / Cloud Guy

•

Twitt...
AGENDA
WHO ARE YOU?
ASK QUESTIONS

There are no stupid questions only stupid
answers. So ask questions
NOW WE HAVE CHOICES ...

http://nosql-database.org/ lists 150
databases
WHY RDBMS?
●

Widely used and understood

●

Tested in real environments

●

Efficient use of storage space if data normal...
RDBMS LIMITATIONS
●

Complex object graphs does not map very well with flat
tables.

●

Difficult to evolve Schema with ti...
NoSQL Databases to rescue
NoSQL TO RESCUE
●

Schema-less

●

Eventual consistent

●

Scales writes and reads

●

●

Easy to scale horizontally to ad...
NoSQL CLASSIFICATION
CLASSIFICATION

Source http://www.slideshare.net/bscofield/nosql-codemash-2010
POLYGLOT PERSISTENCE

Using multiple data storage technologies, chosen based
upon the way data is being used by individual...
HYPOTHETICAL EXAMPLE

http://martinfowler.com/articles/nosql-intro.pdf
GET MORE INFO AT
APPLICATION

http://localjobs-t20.rhcloud.com/
TECHNOLOGY CHOICES
●

MongoDB – Storing Jobs data

●

PostgreSQL – Storing Users data

●

Redis – Cache for Users

●

Java...
MONGODB
●

Document Oriented database
–

●

JSON-style documents

Schema-less
–

Each document is heterogeneous, and may h...
MONGODB TERMINOLOGY

Database →

Database

Table

→

Collection

Row

→

Document

Index

→

Index
WHY MONGODB?
●

Easy to get running

●

Open Source

●

Active community

●

Rich documents

●

Geospatial indexing

●

Wr...
RICH DOCUMENT
GEOSPATIAL INDEXING
BASICS



What is it for?





Find all the MongoDB jobs near me – Proximity Queries
Find all the ...
HOW TO MAKE IT WORK

1)

Put your coordinates into an array

{ loc : [ 50 , 30 ] } //SUGGESTED OPTION
{ loc : { x : 50 , y...
OpenShift
is

PaaS by Red Hat

Multi-language,
Auto-Scaling,
Self-service,
Elastic,
Cloud Application
Platform
WHY OPENSHIFT?

●

●

Supports MongoDB , PostgreSQL ,and MySQL
Multi-language support. Supports Java, Node.js, Perl,
Pytho...
FLAVORS OF OPENSHIFT

Open
Source
Project

Public
Cloud
Service

origin

Onpremise
or Private
Cloud
Software
OUR STACK

26
Let's build the application

27
OPENSHIFT – GETTING
STARTED

Go to

●

https://openshift.redhat.com/app/account/new

Promo code is DEVFEST2013

Create nam...
DEMO : LOCALJOBS APP

Lot of other tasks you can do with rhc – tail log, app management,
cartridge management , ssh manage...
HOW IT FITS
ITS All GIT

$ git rm -rf src pom.xml
$ git commit -am “delete template app”
$ git remote add upstream -m master
https://g...
git push

32
Code Walkthrough

33
QUESTIONS?
DONE!
Upcoming SlideShare
Loading in...5
×

Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devfest Vienna

719

Published on

Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devfest Vienna

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
719
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devfest Vienna

  1. 1. Thinking Beyond RDBMS : OPENSHIFT Building Polyglot Persistence Java Applications Workshop PRESENTED BY Shekhar Gulati
  2. 2. WHO AM I? • Shekhar Gulati -- OpenShift Developer Evangelist • Java / JavaScript /Python / NoSQL / Cloud Guy • Twitter Handle : shekhargulati • Github https://github.com/shekhargulati • Slides http://www.slideshare.net/shekhargulati
  3. 3. AGENDA
  4. 4. WHO ARE YOU?
  5. 5. ASK QUESTIONS There are no stupid questions only stupid answers. So ask questions
  6. 6. NOW WE HAVE CHOICES ... http://nosql-database.org/ lists 150 databases
  7. 7. WHY RDBMS? ● Widely used and understood ● Tested in real environments ● Efficient use of storage space if data normalized properly ● Great tools support ● ACID semantics ● Incredibly flexible and powerful query language ● Great framework support
  8. 8. RDBMS LIMITATIONS ● Complex object graphs does not map very well with flat tables. ● Difficult to evolve Schema with time. ● Data constraints and JOINs can be expensive at runtime. ● Difficult to scale horizontally.
  9. 9. NoSQL Databases to rescue
  10. 10. NoSQL TO RESCUE ● Schema-less ● Eventual consistent ● Scales writes and reads ● ● Easy to scale horizontally to add processing power and storage Tries to solve few practical use-cases
  11. 11. NoSQL CLASSIFICATION CLASSIFICATION Source http://www.slideshare.net/bscofield/nosql-codemash-2010
  12. 12. 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 http://martinfowler.com/articles/nosql-intro.pdf
  13. 13. HYPOTHETICAL EXAMPLE http://martinfowler.com/articles/nosql-intro.pdf
  14. 14. GET MORE INFO AT
  15. 15. APPLICATION http://localjobs-t20.rhcloud.com/
  16. 16. TECHNOLOGY CHOICES ● MongoDB – Storing Jobs data ● PostgreSQL – Storing Users data ● Redis – Cache for Users ● Java 7 – Spring framework , Spring Social, Spring MongoDB, Spring Security , Spring Redis , etc. ● OpenShift ● Git ● Twitter Bootstrap ● jQuery ● Searchify : Full-text Search as a Service
  17. 17. MONGODB ● Document Oriented database – ● JSON-style documents Schema-less – Each document is heterogeneous, and may have completely unique structure compared to other documents. ● Fast and horizontally scalable ● Rich query language
  18. 18. MONGODB TERMINOLOGY Database → Database Table → Collection Row → Document Index → Index
  19. 19. WHY MONGODB? ● Easy to get running ● Open Source ● Active community ● Rich documents ● Geospatial indexing ● Writes are very fast. You can customize it using WriteConcern
  20. 20. RICH DOCUMENT
  21. 21. GEOSPATIAL INDEXING BASICS  What is it for?    Find all the MongoDB jobs near me – Proximity Queries Find all the MongoDB jobs within Colombo – Bounded Queries Find all the MongoDB job at this location – Exact Queries ● Supports only two dimensional indexes.  You can only have one geospatial index per collection.  By default, 2d geospatial indexes assume longitude and latitude have boundaries of -180 inclusive and 180 non-inclusive (i.e. [-180, 180)) 21
  22. 22. HOW TO MAKE IT WORK 1) Put your coordinates into an array { loc : [ 50 , 30 ] } //SUGGESTED OPTION { loc : { x : 50 , y : 30 } } { loc : { foo : 50 , y : 30 } } 1) { loc : { lon : 40.739037, lat: 73.992964 } } 2) Make a 2d index db.places.ensureIndex( { loc : "2d" } ) 3) 22 If you use latitude and longitude as your coordinate system, always store longitude first. MongoDB’s 2d spherical index operators only recognize [ longitude, latitude] ordering.
  23. 23. OpenShift is PaaS by Red Hat Multi-language, Auto-Scaling, Self-service, Elastic, Cloud Application Platform
  24. 24. WHY OPENSHIFT? ● ● Supports MongoDB , PostgreSQL ,and MySQL Multi-language support. Supports Java, Node.js, Perl, Python, PHP and Ruby ● Extensible via DIY and cartridges ● No need to learn anything new ● Open source – OpenShift Origin ● Scalable ● FREE!
  25. 25. FLAVORS OF OPENSHIFT Open Source Project Public Cloud Service origin Onpremise or Private Cloud Software
  26. 26. OUR STACK 26
  27. 27. Let's build the application 27
  28. 28. OPENSHIFT – GETTING STARTED Go to ● https://openshift.redhat.com/app/account/new Promo code is DEVFEST2013 Create namespace ● Install rhc command line utility ● Run rhc setup command ● 28
  29. 29. DEMO : LOCALJOBS APP Lot of other tasks you can do with rhc – tail log, app management, cartridge management , ssh management , namespace management, etc. Run rhc -h for details 29
  30. 30. HOW IT FITS
  31. 31. ITS All GIT $ git rm -rf src pom.xml $ git commit -am “delete template app” $ git remote add upstream -m master https://github.com/shekhargulati/localjobsdemo.git $ git pull -s recursive -X theirs upstream master Source code https://github.com/shekhargulati/localjobs-demo 31
  32. 32. git push 32
  33. 33. Code Walkthrough 33
  34. 34. QUESTIONS?
  35. 35. DONE!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×