Database

Basics

Relational DB

  • PostgreSQL

    • Default isolation level: Read Committed

    • Replication: Master-slave

    • Partitioning method: partitioning by range, list and (since PostgreSQL 11) by hash

    • Index

  • MySQL

  • Oracle

    • Commercial

      Replication:

      • master-master

        • All nodes can do read / write

          • Support fail-over

          • Consistency:

            • Most multi-master replication systems are only loosely consistent, i.e. lazy and asynchronous, violating ACID properties.

            • Performance: Eager replication systems are complex and increase communication latency.

          • Integrity: Issues such as conflict resolution can become intractable as the number of nodes involved rises and latency increases.

        • master-slave

          • Only master node can modify data. Slave nodes waiting for master node for high consistency

          • No automatic fail over

        • Cluster

          • No single point of failure

          • Very high throughput

          • 99.99% uptime

          • Auto-Sharding

          • Real-Time Responsiveness

          • On-Line Operations(Schema changes etc)

          • Distributed writes

          • See known limitations

      • Partitioning method: horizontal partitioning

NoSQL #NoSQLFor?

  • Column-oriented

    • Cassandra

      • Strength:

        • ability to scale while still being reliable

        • high availability (high velocity writes, and lower velocity reads)

      • Structured / non-structured data. Flexible wide column.

      • A cluster of equal-privileged nodes in a ring structure.

  • Graph

  • Document-oriented

    • Mongo

      • JSON document based

  • Key-value

    • Properties:

      • Can provide a good look up for sharded RDB

    • ready to talk about:

      • Cache Hit Ratio

      • Evictions

      • Expired objects

    • Redis

      • Support persistence

      • Support key-objects (string, hash, list, set, sorted set)

      • Can selectively outdate data

      • Support single threaded only

    • Memcached

    • Advanced data structures

Trouble Shooting

Implementation:

  • Designing a friend list

    • Relational DB

      • Instead of just insert 1 row and do bi-directional search. Insert 2 rows at the same time to describe from both user's perspectives would help keep search SQL simple and make sharding possible.

    • NoSQL

      • Graph DB

        • TAO (Facebook's solution), Open Graph, Neo4j‌

Reference:

Reference

Last updated