System Design Basics Flashcards

1
Q

Performance vs scalability

A

A service is scalable if it results in increased performance in a manner proportional to resources added. Generally, increasing performance means serving more units of work, but it can also be to handle larger units of work, such as when datasets grow.1

Another way to look at performance vs scalability:

  • If you have a performance problem, your system is slow for a single user.
  • If you have a scalability problem, your system is fast for a single user but slow under heavy load.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Latency vs throughput

A

Latency is the time to perform some action or to produce some result.

Throughput is the number of such actions or results per unit of time.

Generally, you should aim for maximal throughput with acceptable latency.

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

CAP theorem

A

In a distributed computer system, you can only support two of the following guarantees:

  • Consistency - Every read receives the most recent write or an error
  • Availability - Every request receives a response, without guarantee that it contains the most recent version of the information
  • Partition Tolerance - The system continues to operate despite arbitrary partitioning due to network failures

Networks aren’t reliable, so you’ll need to support partition tolerance. You’ll need to make a software tradeoff between consistency and availability.

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

CP (CAP theorem)

A

Consistency and partition tolerance

Waiting for a response from the partitioned node might result in a timeout error. CP is a good choice if your business needs require atomic reads and writes.

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

AP (CAP theorem)

A

Availability and partition tolerance

Responses return the most readily available version of the data available on any node, which might not be the latest. Writes might take some time to propagate when the partition is resolved.

AP is a good choice if the business needs allow for eventual consistency or when the system needs to continue working despite external errors.

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

Weak consistency (Consistency patterns)

A

After a write, reads may or may not see it. A best effort approach is taken.

This approach is seen in systems such as memcached. Weak consistency works well in real time use cases such as VoIP, video chat, and realtime multiplayer games. For example, if you are on a phone call and lose reception for a few seconds, when you regain connection you do not hear what was spoken during connection loss.

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

Eventual consistency (Consistency patterns)

A

After a write, reads will eventually see it (typically within milliseconds). Data is replicated asynchronously.

This approach is seen in systems such as DNS and email. Eventual consistency works well in highly available systems.

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

Strong consistency (Consistency patterns)

A

After a write, reads will see it. Data is replicated synchronously.

This approach is seen in file systems and RDBMSes. Strong consistency works well in systems that need transactions.

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

Fail-over (Availability patterns)

Active-passive

A

With active-passive fail-over, heartbeats are sent between the active and the passive server on standby. If the heartbeat is interrupted, the passive server takes over the active’s IP address and resumes service.

The length of downtime is determined by whether the passive server is already running in ‘hot’ standby or whether it needs to start up from ‘cold’ standby. Only the active server handles traffic.

Active-passive failover can also be referred to as master-slave failover.

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

Fail-over (Availability patterns)

Active-active

A

In active-active, both servers are managing traffic, spreading the load between them.

If the servers are public-facing, the DNS would need to know about the public IPs of both servers. If the servers are internal-facing, application logic would need to know about both servers.

Active-active failover can also be referred to as master-master failover.

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

Disadvantages of Fail-over (Availability patterns)

A

Fail-over adds more hardware and additional complexity.
There is a potential for loss of data if the active system fails before any newly written data can be replicated to the passive.

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

Availability in parallel vs in sequence

A

If a service consists of multiple components prone to failure, the service’s overall availability depends on whether the components are in sequence or in parallel.

In sequence
Overall availability decreases when two components with availability < 100% are in sequence:

Availability (Total) = Availability (Foo) * Availability (Bar)

If both Foo and Bar each had 99.9% availability, their total availability in sequence would be 99.8%.

In parallel
Overall availability increases when two components with availability < 100% are in parallel:

Availability (Total) = 1 - (1 - Availability (Foo)) * (1 - Availability (Bar))

If both Foo and Bar each had 99.9% availability, their total availability in parallel would be 99.9999%.

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