System Design Flashcards

1
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is write though cache what is the benefit

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you implement Session store

A

You can use redis to store data about a user and the key can be what is passed around to access the data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is write though cache what is the benefit

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is max values of a single redis key

A

512MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Typical Size of a Redis Cluster

A

Can be anywhere from 32GB or 2x a mac book pro

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Debouncing and how is it different from throttling

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the specks of a top Server machine

  • Clock cycles per second
  • number of cores
  • RAM
  • Memory
A

4Ghz
8 Core
32-124 GB ram
500GB - 2Tb or data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you route reques for multi region deployments

A

You route requests for mutli region deploymenys using a DNS strategy.

ie. region based
ie. load based
ie. both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to deal with a single view of something that requires distributed consensus.

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to make a authenticaion and authorization service

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the structure of a JWT

A
{ 
  header: 
  payload:
  signature:
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Whate are the uses of Rate limiting

A

Heps protect against DOS or DDOS attacks.
brute force Password attacks
API abuse
Misbehaving scripts (intentional or unintentional)
Keeps costs lower

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Difference between Ratelimiting and Throttling

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Difference between

A) Relative time based/ Rolling window throttling

B) Fixed window throttling

C) Set based throttling with a counter

A

A) Rolling window based throtteling you store the first time the user calls and all requests between
datetime.now().timestamp() - prevTime < timeWindow
inc count if limit not reached
if limit is reached stop.

B) Fixed time window can be used by declaring an array
1 - 60 all the hits in that 60 seconds. Issue here is more than throttle limit request can be executed withing a second

C) If you need to support multiple time,
10 request every 10 seconds
1000 requests per hour
Use a hash set and that sores the time stamp and the total number of hits. If the request are getting older than the max time ie 1 hour then delete those

17
Q
What are the 99's 
99% -? (2 9's), 
99.9 -? how much downtime (3 9's) 
99.99 -? how much downtime (4 9's) 
99.999 - ? how much downtime  5 9's)
99.9999 - ? how much downtime
A

99’s is a measurement of avalibility of a system

99 -> 3 days of down time (80 hours)

  1. 9 -> (8 hours)
  2. 99 -> (54 mins down time)
  3. 999 -> (5 mins of down time)
  4. 9999 -> 30 seconds