Thinking Beyond RDBMS : OPEN SHIFT Building Polyglot Persistence - - PowerPoint PPT Presentation

thinking beyond rdbms open shift building polyglot
SMART_READER_LITE
LIVE PREVIEW

Thinking Beyond RDBMS : OPEN SHIFT Building Polyglot Persistence - - PowerPoint PPT Presentation

Thinking Beyond RDBMS : OPEN SHIFT Building Polyglot Persistence Java Applications Workshop PRESENTED BY Shekhar Gulati WHO AM I? Shekhar Gulati -- OpenShift Developer Evangelist Java / JavaScript /Python / NoSQL / Cloud Guy


slide-1
SLIDE 1

OPENSHIFT

Workshop

PRESENTED

BY

Shekhar Gulati

Thinking Beyond RDBMS : Building Polyglot Persistence Java Applications

slide-2
SLIDE 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
slide-3
SLIDE 3

AGENDA

slide-4
SLIDE 4

WHO ARE YOU?

slide-5
SLIDE 5

There are no stupid questions only stupid

  • answers. So ask questions

ASK QUESTIONS

slide-6
SLIDE 6

http://nosql-database.org/ lists 150 databases

NOW WE HAVE CHOICES ...

slide-7
SLIDE 7
  • 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

WHY RDBMS?

slide-8
SLIDE 8
  • 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.

RDBMS LIMITATIONS

slide-9
SLIDE 9

NoSQL Databases to rescue

slide-10
SLIDE 10
  • 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

NoSQL TO RESCUE

slide-11
SLIDE 11

NoSQL CLASSIFICATION NOSQL CLASSIFICATION

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

slide-12
SLIDE 12

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

POLYGLOT PERSISTENCE

slide-13
SLIDE 13

http://martinfowler.com/articles/nosql-intro.pdf HYPOTHETICAL EXAMPLE

slide-14
SLIDE 14

GET MORE INFO AT

slide-15
SLIDE 15

APPLICATION

http://localjobs-t20.rhcloud.com/

slide-16
SLIDE 16
  • 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

TECHNOLOGY CHOICES

slide-17
SLIDE 17
  • 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

MONGODB

slide-18
SLIDE 18

Database → Database Table → Collection Row → Document Index → Index

MONGODB TERMINOLOGY MONGODB TERMINOLOGY

slide-19
SLIDE 19
  • Easy to get running
  • Open Source
  • Active community
  • Rich documents
  • Geospatial indexing
  • Writes are very fast. You can customize it using

WriteConcern

WHY MONGODB?

slide-20
SLIDE 20

RICH DOCUMENT

slide-21
SLIDE 21

21

 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))

GEOSPATIAL INDEXING BASICS

slide-22
SLIDE 22

22

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) If you use latitude and longitude as your coordinate system, always store longitude first. MongoDB’s 2d spherical index

  • perators only recognize [ longitude, latitude] ordering.

HOW TO MAKE IT WORK

slide-23
SLIDE 23

OpenShift

is

PaaS by Red Hat

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

slide-24
SLIDE 24
  • 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!

WHY OPENSHIFT?

slide-25
SLIDE 25
  • rigin

Public Cloud Service On- premise

  • r Private

Cloud Software Open Source Project FLAVORS OF OPENSHIFT

slide-26
SLIDE 26

26

OUR STACK

slide-27
SLIDE 27

27

Let's build the application

slide-28
SLIDE 28

28

OPENSHIFT – GETTING STARTED

  • Go to

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

Promo code is LINUXCON2013

  • Create namespace
  • Install rhc command line

utility

  • Run rhc setup command
slide-29
SLIDE 29

29

$ rhc create-app localjobs jbosseap mongodb-2.2 postgresql-9.2 -s $ rhc add-cartridge http://cartreflect-claytondev.rhcloud.com/reflect? github=smarterclayton/openshift-redis-cart --app localjobs $ rhc env set SPRING_PROFILES_ACTIVE=openshift 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

DEMO : LOCALJOBS APP

slide-30
SLIDE 30

30

$ git rm -rf src pom.xml $ git commit -am “delete template app” $ git remote add upstream -m master https://github.com/shekhargulati/localjobs- demo.git $ git pull -s recursive -X theirs upstream master

ITS All GIT

Source code https://github.com/shekhargulati/localjobs-demo

slide-31
SLIDE 31

31

git push

slide-32
SLIDE 32

32

Code Walkthrough

slide-33
SLIDE 33

QUESTIONS?

slide-34
SLIDE 34

DONE!