Infrastructure Flashcards
What is a load balancer, and what are common load balancing algorithms?
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.
What is the CAP theorem, and what are its three components?
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 do horizontal and vertical scaling differ in system design?
Horizontal Scaling: Adding more servers to the system.
Vertical Scaling: Increasing resources (CPU, RAM) of existing servers.
What is database sharding, and when is it used?
Sharding splits a database into smaller, independent pieces (shards) to improve scalability and performance.
Why is caching used, and what are common caching strategies?
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 does a CDN improve system performance?
A CDN caches static assets (e.g., images, scripts) on edge servers closer to users, reducing latency, bandwidth, and server load.
What are the key challenges of distributed systems?
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.
What is microservices architecture, and what are its benefits?
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.
What is an API gateway, and why is it used?
An API gateway acts as a single entry point for client requests, handling authentication, routing, and rate limiting. Example: AWS API Gateway.
What is rate limiting, and how can it be implemented?
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.
What is data partitioning, and how is it different from sharding?
Partitioning divides data logically within a system, while sharding is a specific implementation of partitioning across databases.
What is eventual consistency in distributed systems?
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).
What is leader election in distributed systems, and why is it needed?
Leader election designates one node as the leader to coordinate tasks. It ensures consistency in distributed systems.
What is a proxy server, and what are its types?
A proxy server acts as an intermediary between a client and server. Types:
- Forward Proxy: Represents clients.
- Reverse Proxy: Represents servers (e.g., Nginx).
What is a message queue, and why is it used?
A message queue allows asynchronous communication between services, decoupling producers and consumers. Examples: Kafka, RabbitMQ.