System Design Flashcards
What is cache Aside
A) who is responsible for updating the cache
B) when to read form db
C) what is the eviction policy can be supported
Usually, the default strategy to use when dealing with caches. The cache-aside patterns to load data into the cache only as needed
A) Application updates cache when changes are made
B) If there is a cache miss or if the application must re-compute. Its really up to applicaion
C) Set expiery of the key or standard LRU etc.
What is write though cache what is the benefit
Write through cache allows one to have to most up to date cache for example in a application where the state is not mutated oftet but read a lot and non stale data is important
-eg tracking leader board
How can you implement Session store
You can use redis to store data about a user and the key can be what is passed around to access the data
What is write though cache what is the benefit
Write through cache allows one to have to most up to date cache for example in a application where the state is not mutated oftet but read a lot and non stale data is important
-eg tracking leader board
What is max values of a single redis key
512MB
What is the Typical Size of a Redis Cluster
Can be anywhere from 32GB or 2x a mac book pro
Can you do consistent Hashing using a SQL db?
A) what is needed to deal with which server to lookup
B) how and when are the servers/port of db initialized in the service
C) what will happened when you add a node and remove a node
A) Use a consistent hashing library and use a service that will give you the on the server-side and initialize all the database instances
B) Forward each request to app server which will take the sharding-key and returns the server details
C) When you add or remove a node you can just update the one service that holds all the data for the shard
What is Debouncing and how is it different from throttling
Debouncing is a strategy to try to read a state of an object after it has stabilized. For example when a change event occurs store the state and then sleep for 100ms and re-read the state if state remains the same then trigger the request.
- This is best implemented in the UI as this strategy with API calls will surely be very bad experience and ignore other’s API calls
What are the specks of a top Server machine
- Clock cycles per second
- number of cores
- RAM
- Memory
4Ghz
8 Core
32-124 GB ram
500GB - 2Tb or data
How do you route reques for multi region deployments
You route requests for mutli region deploymenys using a DNS strategy.
ie. region based
ie. load based
ie. both
How to deal with a single view of something that requires distributed consensus.
Use zookeeper to be the source of truth. This helps coordinate achtions my multiple machines like deploy the same service across different regions/machines
How to make a authenticaion and authorization service
1) jwt for token which is pased with each request
2) Authention service that will map the user to the session key
3) store session data in cache storage with that users session info including ACL
4) each application will use the key to fetch the session objects form cache
What is the structure of a JWT
{ header: payload: signature: }
Whate are the uses of Rate limiting
Heps protect against DOS or DDOS attacks.
brute force Password attacks
API abuse
Misbehaving scripts (intentional or unintentional)
Keeps costs lower
Difference between Ratelimiting and Throttling
Rate Limiting is a process that is used to define the rate and speed at which consumers can access APIs
Throttling is the process of controlling the usage of the APIs by customers during a given period. Throttling can be defined at the application level and/or API level and return 429 - Too many requests