Infrastructure Flashcards

1
Q

What is a load balancer, and what are common load balancing algorithms?

A

A load balancer distributes incoming traffic across multiple servers. Common algorithms:

  • Round Robin: Requests are distributed sequentially.
  • Least Connections: Routes to the server with the fewest active connections.
  • IP Hash: Routes based on client IP.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the CAP theorem, and what are its three components?

A

CAP theorem states that a distributed system can achieve only two out of three guarantees:

  • Consistency: Every read gets the latest write.
  • Availability: Every request gets a response (even if outdated).
  • Partition Tolerance: System works despite network partitions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do horizontal and vertical scaling differ in system design?

A

Horizontal Scaling: Adding more servers to the system.
Vertical Scaling: Increasing resources (CPU, RAM) of existing servers.

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

What is database sharding, and when is it used?

A

Sharding splits a database into smaller, independent pieces (shards) to improve scalability and performance.

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

Why is caching used, and what are common caching strategies?

A

Caching stores frequently accessed data in a faster storage layer. Strategies:

  • Write-Through: Updates cache and database simultaneously.
  • Write-Back: Updates cache first, database later.
  • Least Recently Used (LRU): Removes least-accessed items.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a CDN improve system performance?

A

A CDN caches static assets (e.g., images, scripts) on edge servers closer to users, reducing latency, bandwidth, and server load.

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

What are the key challenges of distributed systems?

A

Challenges include:

  • Data consistency: Keeping data synchronized across nodes.
  • Fault tolerance: Handling node failures.
  • Latency: Minimizing delays in communication.
  • Complexity: Managing multiple systems and the relevant infrastructure.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is microservices architecture, and what are its benefits?

A

Microservices split applications into independent services, each responsible for a specific domain. Benefits:

  • Scalability: Scale individual services independently.
  • Resilience: Faults in one service don’t affect others.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an API gateway, and why is it used?

A

An API gateway acts as a single entry point for client requests, handling authentication, routing, and rate limiting. Example: AWS API Gateway.

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

What is rate limiting, and how can it be implemented?

A

Rate limiting controls the number of requests a client can make in a given time. Implementation:

  • Token Bucket Algorithm: Tokens are added to a bucket at a fixed rate. Each request consumes a token. If the bucket is empty, the request is rejected or delayed. Allows bursts up to the bucket’s capacity.
  • Leaky Bucket Algorithm: Requests enter a queue (bucket) and are processed at a fixed rate. Excess requests overflow and are dropped. Ensures a steady outflow rate, smoothing traffic spikes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is data partitioning, and how is it different from sharding?

A

Partitioning divides data logically within a system, while sharding is a specific implementation of partitioning across databases.

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

What is eventual consistency in distributed systems?

A

Eventual consistency ensures that all replicas in a distributed system will converge to the same value over time, often used in systems prioritizing availability (e.g., DynamoDB).

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

What is leader election in distributed systems, and why is it needed?

A

Leader election designates one node as the leader to coordinate tasks. It ensures consistency in distributed systems.

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

What is a proxy server, and what are its types?

A

A proxy server acts as an intermediary between a client and server. Types:

  • Forward Proxy: Represents clients.
  • Reverse Proxy: Represents servers (e.g., Nginx).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a message queue, and why is it used?

A

A message queue allows asynchronous communication between services, decoupling producers and consumers. Examples: Kafka, RabbitMQ.

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

What is replication in databases, and what are its types?

A

Replication duplicates data across servers for availability and fault tolerance. Types:

  • Master-Slave: One primary server, multiple replicas.
  • Multi-Master: All nodes can read/write.
17
Q

What is a heartbeat (health check) mechanism in distributed systems?

A

Heartbeats are periodic signals sent between nodes to check their health and detect failures.

18
Q

What is a circuit breaker pattern, and why is it used?

A

A circuit breaker detects failures in a service and stops requests temporarily to prevent cascading failures and overloading dependent systems.

19
Q

What are common data consistency models in distributed systems?

A
  • Strong Consistency: Every read gets the latest write.
  • Eventual Consistency: Reads might be stale but converge over time.
  • Causal Consistency: Ensures related operations are seen in order.
20
Q

What is idempotency, and why is it important in system design?

A

Idempotency ensures that performing the same operation multiple times results in the same outcome, critical for handling retries in distributed systems (e.g., re-sending a payment request).