Top Banner
Architecting Database Jony Sugianto, Research Engineer, Detikcom [email protected]
31

Architecting Database by Jony Sugianto (Detik.com)

Jan 19, 2017

Download

Technology

Tech in Asia ID
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Architecting Database by Jony Sugianto (Detik.com)

Architecting Database

Jony Sugianto, Research Engineer, [email protected]

Page 2: Architecting Database by Jony Sugianto (Detik.com)

Design Database System

● Complexity

- Database model

● Volume

- Sharding

● Traffic read/write

- Replication

Page 3: Architecting Database by Jony Sugianto (Detik.com)

Database Model

● Key-values Stores

● Document Databases

● Relational Databases

● Graph Databases

Page 4: Architecting Database by Jony Sugianto (Detik.com)

Key-values Stores

● A Key-Values Stores is a simple Hash table

● Where all the accesses to the Stores via primary keys

● A client can:

- Get the value for a key

- Put a value for a key

- Delete a key from the Stores

● Keys and Values can be complex compound objects and sometime lists, maps or other data structures

● Key-value data access enable high performance

● Easy to distribute across cluster

Page 5: Architecting Database by Jony Sugianto (Detik.com)

Key-Value Example

Page 6: Architecting Database by Jony Sugianto (Detik.com)

Key-Values: Cons

● No complex query filters

● All joins must be done in code

● No foreign key constraints

● Poor for interconnected data

Page 7: Architecting Database by Jony Sugianto (Detik.com)

Key-Values Stores Implementation

● Memory based

- Memcached

- Redis

● Memory and Disk based

- MapDB

- Diskv

● Database System

- Dynamo DB

- Aerospike

Page 8: Architecting Database by Jony Sugianto (Detik.com)

Document Databases

● Documents are the main concept

● Documents are:

-self-describing

-Hierarchical tree data structures(map. List, scalar-values)

{ name:ade, usia:20, alamat:depok}

{ name:wahyu, usia:30, pekerjaan:dosen}

Page 9: Architecting Database by Jony Sugianto (Detik.com)

Document Databases

Page 10: Architecting Database by Jony Sugianto (Detik.com)

Document Databases:Pros and Cons

● Pros:

- Simple model

- Built in Map-reduce ?

- Scalable

● Cons:

- Poor for interconnected data

Page 11: Architecting Database by Jony Sugianto (Detik.com)

Document Database Implementation

● MongoDB

● CouchDB

● Etc.

Page 12: Architecting Database by Jony Sugianto (Detik.com)

Relational Database

● Most popular Database system

● The model is based on tables, rows and columns and the manipulation of data stored within

● Relational database is a collection of these tables

Page 13: Architecting Database by Jony Sugianto (Detik.com)

Relational Model

Page 14: Architecting Database by Jony Sugianto (Detik.com)

Relational Database Pros/Cons

● Pros

- simple, well-establish, standard approach

- maps well to data with consistent structure

- has extensive join capabilities

● Cons

- hard to scale

- does not map well to semi-structured data

- knowledge of the database structure is required to create queries

Page 15: Architecting Database by Jony Sugianto (Detik.com)

Relational Database Implementation

● Postgres

● Mysql

● sqllite

Page 16: Architecting Database by Jony Sugianto (Detik.com)

Graph Database

● Relation as first class citizen

● Very old fundamental theory (1700)

● huge amount of graph algorithm existing

Page 17: Architecting Database by Jony Sugianto (Detik.com)

Graph Database

Page 18: Architecting Database by Jony Sugianto (Detik.com)

Graph Model

Page 19: Architecting Database by Jony Sugianto (Detik.com)

Key Value to Graph

Page 20: Architecting Database by Jony Sugianto (Detik.com)

Document to Graph

Page 21: Architecting Database by Jony Sugianto (Detik.com)

Relational to Graph

Page 22: Architecting Database by Jony Sugianto (Detik.com)

Graph Database Pros/Cons

● Pros

- powerful data model

- easy to query(relation as pointer to object)

- map well to semi-structured data

- can easily evolve schema

● Cons

- hard to scale

- lacks of tool and framework support

- requires new art of problem solving

Page 23: Architecting Database by Jony Sugianto (Detik.com)

Graph Database implementation

● JgraphT(library)

● JUNG(library)

● Neo4J

● HyergraphDB

● OrientDB

Page 24: Architecting Database by Jony Sugianto (Detik.com)

Sharding and Replication

● Handle huge amount of data

● Handle high traffic read/write data

Page 25: Architecting Database by Jony Sugianto (Detik.com)

What is Sharding?

● Sharding is NOT Master/Slave Database

● Sharding is NOT Replication

● Sharding is NOT Clustering

● Sharding is Splitting data across databases

● Splitted Data share nothing

● Important issues sharding key

Page 26: Architecting Database by Jony Sugianto (Detik.com)

Sharding

Database Shard ShardShard

Aggregation

Page 27: Architecting Database by Jony Sugianto (Detik.com)

Sharding Implementation

● Application site

● Middleware site

- Vitess

- Gizzard

● Server site

- MongoDB

Page 28: Architecting Database by Jony Sugianto (Detik.com)

Replication

● Creating and maintaining multiple copies of the same databases

● Improve:

- reliability

- fault-tolerance

- accessibility

● Important issues strategy of synchronizing data between database replicas

Page 29: Architecting Database by Jony Sugianto (Detik.com)

Replication

Page 30: Architecting Database by Jony Sugianto (Detik.com)

Scalability, Complexity and Database Model

Scalability

Complexity

Key-Values Stores

Document Database

Relational Database

Graph Database

Page 31: Architecting Database by Jony Sugianto (Detik.com)

Questions?