Advanced Search
Search Results
112 total results found
Archive Pattern
Move data no longer needed to a different place so performance is not dragged. archive book reviews that are more than one year old
Anti Patterns
Unbounded Arrays an array without a size limit used subset pattern or extended reference pattern Bloated Docments A document that groups together related data that is accessed separately say a book store has two pages: home and detailed page. Home shows 10 ...
Schema Validation
To create a new "sales" collection schema validation, we use the createCollection method with the validator option. In this example, we combine a query operator, $and, and JSON schema to define the schema validation rules. $and checks the discounterPrice is lo...
Schema Evolution
In this example, we implemented the updated reviews schema to include an optional locale field, in the properties document, which accepts only fr or en values: const bookstore_reviews_international = { bsonType: "object", required: [“_id”, "review_id",...
Schema Migration
Schema migration is transition from one schema to the next Migration Strategies: Eager: all at once Lazy: as data is used Incremental: small interactive steps Predictive: updates the schema based on predictions for future data usage Here’s the default schema...
MongoDB Cheatsheet
Feature easy to use, well documented similar to SQL B-Tree ACID Transactions Single Leader Replication Supports $lookup operation, which is basically a left outer join since it's also using B-Tree, indexing is similar to relational SQL Flexible Schema ...
Regex
// Character class [xyz] => matches one of [x,y,z] [a-c] => matches one of [a,b,c] // Negated character class [^xyz] => matches anything that is not in [x,y,z] [^a-c] => matches anything that is not in [a,b,c] // Wildcard . => matches any single character ex...
Redis Cheatsheet
Key Points in-memory, key-value store supports string, int, hash(map<string, string>), list, set, sorted set, bitmap can be used as a database, cache, messsage broker, pub/sub key-eviction, expiration, hashes, string, set, order-set, pub/sub, channel, RDB, AO...
Fundamentals and High Level Overview
System Design Process Gather requirments Back of envelope calculations API design Architectual design 1 Database sequential reads and writes are always cheaper than random reads and writes want to keep data that is frequently read together close together w...
Trees
Types of trees Binary Tree Binary Search Tree left child < node < right value AVL Tree self balanced BST diff(height(leftChild), height(rightChild)) <= 1 Red-Black Tree solves the same problem as AVL Tree but with less strict balance and thus less ...
Nginx Cheatsheet
Configuration files /etc/nginx/nginx.conf /etc/nginx/sites-available/* /etc/nginx/sites-enabled/* Master and worker processes master process reads and evaluate configurations, and maintain worker processes. worker processes process the actual requests...
Message Broker / Stream Processing Cheatsheet
Stream Processing a broker between producers and consumers broker deals with TCP/UDP connections, processing speed, etc.. In memory vs Log based (on disk) if order doesn't matter, and no need to persistent data, then use in-memory message broker if order ...
Git
Dev developing procedure checkout a new branch called "feature_branch" make modifications commit, push pull main, update to latest merge main to feature_branch with git rebase main resolve conflicts and commit push feature_branch to remote with git push -f o...
Setting up a Redis-Cluster in Kubernetes
Definitions
Bloom Filter Searching for a key in a cache system might take a long time in a LSM tree because it would require to look through all SSTables before finally realizing the key doesn't exists Bloom filter uses multiple different hash values to determine if the ...
Strings
ZList: def buildZList(s: str) -> List[int]: """ Used in pattern matching: buildZList(needle + '.' + haystack) and check for length(needle) in result Construct an array of length equal to the length of the input string Where the first number in...
Database Comparisons
SQL Databases relational normalized data (minimum duplicate data) Uses B Tree or B+ Tree indexing, where B+ Tree is more common Fast reads but slow writes good for situations where correctness is more important than performance, like banking, job sched...
Network Protocols
HTTP, WebSocket, gRPC, WebRTC original post: GetStream Communication Protocol? a protocol is a set of rules that govern how data is exchanged over the network Multiplexing to allow multiple requests and responses to be multiplexed over a single connectio...
Database Replications
Sync vs Async replication sync ensures strong consistency, but slower writes async ensures fastest writes, but result in eventual consistency or even data lost in case of failure Single Leader Replication problems with failover some writes from previous l...
Database Indexes
B-Tree Index Pros: fast read, fast range query no limit on number of keys Cons: slow writes Hash Index Pros: O(1) read and write Cons: keys needs to fit in memory no range queries allowed LSM Tree Index Red-black tree, balanced binary tree, et...