System Design Flashcards

1
Q

What is a semaphore

A

Non negative integer variable shared between various threads

It has 2 operations: Wait & Signal

Used to control access to a common resource by multiple processes or threads

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

What is a mutex

A

MUTUAL EXCLUSION
Specific kind of semaphore that is a locking mechanism

Used to ensure exclusive access to a single resource

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

What is a thread

A

Smallest sequence of a programmed instruction that can be managed by a single scheduler

It is an execution unit that contains a thread ID, program counter, register set and track

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

Types of load balancer

A

Hardware v software

Layer 4 v Layer 7
4: operates on transport layer, routes traffic based on IP address and port
7: operates on app layer and routes based on content such as URL paths or HTTP headers

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

Examples of load balancing algorithms

A

Round robin: distributed requests sequentially among servers

Least connections

IP hash: determines server based on IP address of client

Weighted algos: distributes to servers based on weights

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

What is a scheduler? Give examples of types?

A

System component responsible for managing the execution of processes and threads

Job scheduler: long term

CPU scheduler: short term

Medium term

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

Scheduling algos

A

First come first served

Shortest Job next

Prioritising

Round robin

Multilevel: split into sub queues with own algo

Multilevel feedback: same as multilevel but allows movement between sub queues based on some criteria

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

What is a RESTful API

A

Representational state transfer

Uses stateless communication
Client server architecture
Cacheable responses
Uniform interfaces
Layered system: client (usually) can’t tell if is communicating with end server

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

Alternatives to RESTful

A

SOAP (simple object access protocol)

GRAPH QL

gRPC Google Remote Procedure Calls

OData open data protocol

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

Why use RESTful

A

Simplicity: uses standard HTTP methods

Scalability: stateless nature allows

Flexibility: can handle many type of calls and return in many formats

Portability: can access from any environment that supports HTTP

Low bandwidth

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

Steps to make RESTful

A
  1. Define resources
  2. Define HTTP methods
    POST GET DELETE
  3. use status codes to represent outcome of posts
  4. Ensure statelessness
    Each call should contain all necessary info without relying on stored user info
  5. Implement error handling
  6. Documentation
  7. Versioning
  8. Security considerations
    Implement rate limiting, input validation, maybe auth
  9. Response formatting
    Use JSON
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Problems of SOAP

A

Simple object access protocol

Complexity, heavier than RESTful

Verbosity

Flexibility, often protocol dependent

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

Limitations of GraphQL

A

Client side caching can be difficult due to query complexity

File upload is more complex

More overheads (processing time)

Steeper learning curve

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

Limitations of gRPC

A

Google remote procedure calls

Its use of HTTP/2 is not natively support in all web browsers

Readability: uses binary format (which is efficient)

Complexity

Ecosystem: not as mature but is growing

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

Steps for designing a system

A

1) scope problem: determine parameters

2) determine assumptions: q&a

3) draw out simplified system

4) identify issues

5) redesign

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

Designing algorithms the scale

A

1) ask lots of Qs to determine limitations

2) ‘make believe’ begin at simple one machine

3) now determine difference between this and question

4) what are issues in reaching scaled system

5) adjust and iterate

17
Q

Horizontal versus vertical scaling

A

Vertical: increasing resources to a specific node, eg; additional memory to server

Horizontal: increasing # of nodes

Vertical is generally easier but is limited, eg; you can only add so much memory to a server

18
Q

Denormalization

A

Adding redundant information into a database to speed up reads

Alternative to joining tables using SQL

19
Q

Sharding

A

Database partitioning

Vertical: effectively partitioning by feature, eg: for social network separate profiles out into tables that have image_url, friends, posts

Hash based: uses an ID to partition. Issue: relocation of all data may be required when scaling

Directory based: lookup table

20
Q

Cache

A

In memory cache can deliver rapid results
Key value pairing

Sits between app layer and data source

21
Q

When to use async processes

A

If a process is slow, you don’t want the whole system being held up by it

22
Q

Networking metrics

A

Bandwidth: maximum amount of date per unit of time

Throughput: actual amount of data transferred

Latency