Development Notes
  • Introduction
  • Programming Langauges
    • Java
      • Cache
      • Java Fundamentals
      • Multithreading & Concurrency
      • Spring Boot
        • Spring Security
        • Development tips
      • ORM
        • Mybatis
      • Implementation & Testing
    • Node.js
      • Asynchronous Execution
      • Node.js Notes
    • Python
      • Memo
  • Data Structure & Algorithm
  • Database
  • Design Pattern
  • AWS Notes
    • Services
      • API Gateway
      • CloudHSM
      • Compute & Load Balancing
        • Auto Scaling Group
        • EC2
        • ECS
        • ELB
        • Lambda
      • Data Engineering
        • Athena
        • Batch
        • EMR
        • IoT
        • Kinesis
        • Video Streaming
        • Quicksight
      • Deployment
        • CloudFormation
        • Code Deploy
        • Elastic Beanstalk
        • OpsWorks
        • SAM
        • SSM
      • ElasticSearch
      • Identity & Federation
        • Directory Service
        • IAM
        • Organizations
        • Resource Access Manager (RAM)
        • SSO
        • STS
      • KMS
      • Management Tools
        • Catalog
        • CloudTrail
        • CloudWatch
        • Config
        • Cost Allocation Tags
        • GuardDuty
        • Savings Plans
        • Trusted Advisor
        • X-Ray
      • Migration
        • Cloud Migration: The 6R
        • Disaster Recovery
        • DMS
        • VM Migrations
      • Networking
        • ACM
        • CloudFront
        • Direct Connect
        • EIP & ENI
        • Network Security
        • PrivateLink
        • Route53
        • VPC
        • VPN
      • Service Commnucation
        • Amazon MQ
        • SNS
        • SQS
        • Step Functions
        • SWF
      • Storage
        • Aurora
        • DynamoDB
        • EBS
        • EFS
        • ElastiCache
        • RDS
        • Redshift
        • S3
        • Storage Gateway
      • Other Services
        • Alexa for Business, Lex, Connect
        • AppStream 2.0
        • CloudSearch
        • Comprehend
        • Data Tools
        • Elastic Transcoder
        • Mechanical Turk
        • Rekognition
        • WorkDocs
        • WorkSpaces
    • Well Architect Framework
      • Security
      • Reliability
      • Performance Effeciency
      • Cost Optimization
      • Operational Excellence
    • Labs
      • Webserver Implementation
      • ELB Implementation
      • Auto-scaling Implementation
      • A 3-tier Architecture In VPC
  • Architecture
    • Security
  • Spark
    • Memo
  • Conference Notes
    • Notes of JCConf 2017
  • AI Notes
Powered by GitBook
On this page

Was this helpful?

Database

PreviousData Structure & AlgorithmNextDesign Pattern

Last updated 4 years ago

Was this helpful?

Basics

  • - DBMS transaction properties

    • JOOQ,

Relational DB

  • PostgreSQL

    • Default isolation level: Read Committed

    • Replication: Master-slave

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

    • Index

      • How do indexes work in a relational DB? Types and scenarios?

      • Index types:

        • B tree

        • Hash Index

        • GIN(Gernalized inverted index)

  • MySQL

    • Default isolation level: Repeatable Read

    • Replication: master-master, master-slave

    • Partitioning method: horizontal partitioning, sharding with MySQL Cluster or MySQL Fabric

  • 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

      • Partitioning method: horizontal partitioning

  • 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

      • volatile caching

      • When value is smaller than 1 MB, very fast.

      • Support multi-thread

    • Advanced data structures

Trouble Shooting

  • How do you know that your database queries are taking time? How will you solve it?

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

Reference:‌

Reference

NoSQL

​ (Facebook's solution), Open Graph, Neo4j‌

​​

Second Level Cache -

Uber replace Postgres with Mysql

ACID
Transactions Isolation levels
Read lock, Write lock
Optimistic lock & Pessimistic lock
Optimistic lock
Pessimistic lock
JPA Optimistic Locking
Efficient Use of PostgreSQL Indexes
GIST
PostgreSQL 锁解密
B+ Tree Index
Designing Schemaless, Uber Engineering’s Scalable Datastore Using MySQL
The Architecture of Schemaless, Uber Engineering’s Trip Datastore Using MySQL
limitations
#NoSQLFor?
#MemcachedWorkWithMysql
Oracle v$session view
TAO
Quora: How does Facebook maintain a list of friends for each user? Does it maintain a separate table for each user?
English
Chinese
#1