Different NoSQL Databases and when to Use Them
General Format:
- What type of database? Why?
- When to use?
- CAP Guarantees
- Scale of Operation
Redis
Redis is a Key Value Store. It is basically a data structures store:
- strings,
- hashes,
- lists,
- sets,
- sorted sets with range queries,
- bitmaps,
- hyperloglogs,
- geospatial indexes with radius queries and
-
streams
- Redis: It is put under CP because redis cluster becomes unavailable in case of partition. Redis Sentinel & Redis cluster are two types of distributed redis setup.
- Redis Sentinel: (AP). Sentinel manages failover. Helps set it up for high availability.
- Redis Cluster: (CP). It is a multiple writer/ larger than ram solution. Basically a sharding solution. Does not provide perfect availability or consistency
- https://stackoverflow.com/questions/31143072/redis-sentinel-vs-clustering
- When use redis: https://stackoverflow.com/questions/10558465/memcached-vs-redis?rq=1
- Cassandra AP: It uses consistent hashing to determine the nodes that should be responsible for handling given data. It provides lightwight transaction using PAXOS
DynamoDB
DynamoDB is KeyValue Store. Also called tabular data store.
CAP:
- Availability over consistency.
- Option for Strong Consistency.(https://stackoverflow.com/questions/20870041/amazon-dynamodb-strong-consistent-reads-are-they-latest-and-how) When to Use:
Cassandra
Cassandra is Column Oriented/ Wide Column store.
CAP:
- Availability over consistency.
When to use:
- High Availability. Means it is not immediately Consistent. Rather eventual consistency.
- Allows write to any node. Light weight transactions.
- Favours writes over reads. Writes are faster. Means when writes are more than reads. Not good for analytical purposes.
- Good for targeted reads by primary key. Other queries sub-optimal.
MongoDB
MongoDB is a document Sore.
CAP:
- Consistent: Mongo does not accept writes and will only start accepting writes when partition is fixed or new master takes over.
When to use:
- When You have schema-less data. Like from scraping web pages.