System design Flashcards
db: disaster recovery
- create a standby DB in different AZ, replicated from master DB
- using the same DNS to connect to DB
- if the master goes down, the replica is automatically up to replace
db: replica and backup
- aws RDS backup every 5m
2. can create 5 read replicas: within AZ, cross AZ or cross region
aurora: how to connect to read/write to DB?
- using reader endpoint, writer endpoint
2. aurora auto-routing to correct destination
detect data conflicts
- using versioning vector D([s1, v1], [s2, v2])
- given 2 vectors if all v values in the one vector >= the other one –> no conflict
conflict example:
D1([s1,2], [s2,1]) -> populate D1 from s1 2 save into s2
D2([s1, 1], [s2,2]) -> populate D2 from s1 1 save twice to s2
rds: available network speed between instances
5 Gbps to 25 Gbps depends on the instances (same for both up and down)
home internet: 350 Mbps (both up and down)
redis commands for list, set, sorted set
- sorted set: zadd, zincrby, zrangebyscore, zrangebyrank, zrangebylex, zrembyrank
- set: sadd, srem, scard
- list: lpush, lpop, rpush, rpop, lindex, linsert, llen
CNAME, A, AAAA record
A: map host to IP
AAAA: same as A but for IPv6
CNAME: host to another host
sticky cookies
- send cookies to client
2. server uses cookies to identify the server behind the LB
aws load balancers
- application load balancer: application layer e.g. HTTP
2. network load balancer: network layer e.g. TCP/IP
terms using in the load balancer
- target group i.e. group of instances
2. health check
aws route 53
- modes: latency, geographical, failover, simple
- TTL
- 53 is DNS port
forward compatibility
is planning ahead
e. g.
1. reserved keywords in programming languages,
2. build something that is easy for adding new feature
argument:
1. mvp: build enough to release only
Kafka consumer and offset
- consumer is assigned to process messages in 1 or many partitions
- 1 partition only be handled by 1 consumer
- after polling messages, consumer will commit to save offset in Kafka so that if re-balancing/restart the delivered messages won’t be delivered again
AAA pattern
Arrange, Act, Assert