system design

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/121

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

122 Terms

1
New cards

Load Balancer

Distributes incoming network traffic across multiple servers to ensure reliability and performance

2
New cards

Caching

Storing frequently accessed data in a temporary location for faster retrieval

3
New cards

CDN (Content Delivery Network)

A distributed network of servers that deliver content to users based on their geographic location

4
New cards

Database Sharding

Partitioning a database into smaller

5
New cards

Horizontal Scaling

Adding more servers to handle increased load

6
New cards

Vertical Scaling

Upgrading a single machine’s resources (CPU

7
New cards

Microservices

An architectural style where applications are composed of small

8
New cards

Monolithic Architecture

A single-tiered application structure where all components are interconnected and deployed together

9
New cards

Message Queue

A system for asynchronously passing messages between components or services

10
New cards

API Gateway

A single entry point that manages requests

11
New cards

Rate Limiting

Restricting the number of requests a user or client can make to prevent abuse

12
New cards

Replication

Creating copies of data across multiple servers for redundancy and high availability

13
New cards

CAP Theorem

States that in distributed systems you can only have two of three: Consistency

14
New cards

Consistency

Every read receives the most recent write or an error

15
New cards

Availability

Every request receives a response

16
New cards

Partition Tolerance

The system continues to function despite network partition failures

17
New cards

Eventual Consistency

A consistency model where all replicas become consistent over time

18
New cards

Proxy Server

A server that acts as an intermediary for requests between clients and other servers

19
New cards

Reverse Proxy

A server that forwards client requests to backend servers

20
New cards

DNS (Domain Name System)

Translates human-readable domain names into IP addresses

21
New cards

Data Replication

Copying and maintaining database objects in multiple databases

22
New cards

Failover

Automatically switching to a standby system when the primary system fails

23
New cards

Heartbeat

Regular signals sent between systems to monitor health and availability

24
New cards

Throughput

The number of requests a system can handle per second

25
New cards

Latency

The time it takes for a request to travel from the client to the server and back

26
New cards

Load Testing

Testing how a system performs under expected user load

27
New cards

Stress Testing

Testing a system beyond normal capacity to observe its breaking point

28
New cards

Autoscaling

Automatically adjusting the number of servers based on current load

29
New cards

Session Management

Mechanism for tracking user interactions across multiple requests

30
New cards

Data Partitioning

Dividing data into segments for scalability and performance

31
New cards

Indexing

Creating data structures that improve the speed of data retrieval

32
New cards

Write-Ahead Log (WAL)

A method ensuring data integrity by writing changes to a log before applying them

33
New cards

Distributed System

A collection of independent computers that appear to users as a single system

34
New cards

Leader Election

Process of designating one node as the coordinator among distributed systems

35
New cards

Heartbeat Mechanism

Method used by systems to check if nodes are alive or failed

36
New cards

CDN Edge Server

Server close to users that caches content for faster delivery

37
New cards

API Rate Limit

Control mechanism to restrict the number of API calls per user or app

38
New cards

Event-Driven Architecture

Architecture based on events triggering services or actions asynchronously

39
New cards

Idempotency

Ensuring that performing the same operation multiple times has the same effect as doing it once

40
New cards

Service Discovery

Mechanism by which microservices locate each other dynamically

41
New cards

Circuit Breaker

Pattern that prevents repeated failed calls to an unresponsive service

42
New cards

Database Index

A data structure that speeds up data retrieval at the cost of additional writes and storage

43
New cards

Content Hashing

Generating a unique hash to detect changes or duplicates in content

44
New cards

Distributed Cache

A cache system spread across multiple machines for scalability

45
New cards

Data Lake

A centralized repository for storing large amounts of raw data in native format

46
New cards

Blob Storage

Storage for large binary files like images

47
New cards

Request Queue

Stores requests temporarily until they can be processed

48
New cards

Strong Consistency

Guarantees that all users see the same data at the same time

49
New cards

Soft State

System state that may change over time even without input due to eventual consistency

50
New cards

Stateless Architecture

Design where each request is independent and does not rely on previous interactions

51
New cards

Stateful Architecture

Design where the system keeps track of client state between requests

52
New cards

CAP Theorem:

States that it is impossible for a distributed software system to simultaneously provide more than two out of three of the following guarantees (CAP): Consistency, Availability, and Partition tolerance.

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

If there is a partition, your system has to choose between being available or consistent

53
New cards

Consistent Hashing

when the hash table is resized (e.g. a new cache host is added to the system), only 'k/n' keys need to be remapped where 'k' is the total number of keys and 'n' is the total number of servers

54
New cards

ACID Properties

In the context of transaction processing, the acronym ACID refers to the four key properties of a transaction: atomicity, consistency, isolation, and durability. All changes to data are performed as if they are a single operation.

55
New cards

SHA-256

A hashing algorithm that produces a 64 character string

56
New cards

Whats the memory of a high end commerical server?

256GB

57
New cards

How many seconds in a day

86400

58
New cards

How many connections can a server hold?

about 500

59
New cards

HDFS or GlusterFS.

a network-attached storage filesystem that allows you to pool storage resources of multiple machines. In turn, this lets you treat multiple storage devices that are distributed among many computers as a single, more powerful unit.

60
New cards

How full should storage get

80%

61
New cards

How may disk space does a modern server have

4TB

62
New cards

How many bytes in a char in a word

4 bytes

63
New cards

How many ids fit in one byte, two bytes, 3 bytes, 4 bytes....

1 byte = 256

2 byte = 65,000

3 bytes = 16 million

4 bytes = 4 billion

5 bytes = max

64
New cards

Back of the envelope

1. Traffic estimates

2. Storage Estimates

3. Bandwidth estimates

4. Memory Estimate

65
New cards

How many bytes in epoch time?

4 bytes

66
New cards

Unit Tests

testing software with a small piece of source code (unit, component, and/or function

67
New cards

Integ Tests

Integration testing is the phase in software testing in which individual software modules are combined and tested as a group. Integration testing is conducted to evaluate the compliance of a system or component with specified functional requirements

68
New cards

End to End tests

A helper robot that behaves like a user to click around the app and verify that it functions correctly.End to End: A helper robot that behaves like a user to click around the app and verify that it functions correctly.

69
New cards

Load Tests

Load testing is the process of putting demand on a system and measuring its response. An example of a test is to concurrently download large files

70
New cards

Security Tests

Security testing is a process intended to reveal flaws in the security mechanisms of an information system that protect data and maintain functionality as intended

71
New cards

NP-complete problems

a class of computational problems for which no efficient solution algorithm has been found. Polynomial-time algorithms are considered to be efficient, while exponential-time algorithms are considered inefficient.

polynomial time: n^10

exponential time: 10^k

ex: Traveling salesman

72
New cards

N Choose K problems

C(n, k)= n!/[k!(n-k)!]

73
New cards

Processes vs threads

Processes have their own heap, they don't share memory

Threads have share a heap. Starting a thread is cheaper, as fewer resources need to be allocated. The threads within a process are concurrent and can execute in parallel

74
New cards

Semephore

In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system such as a multitasking operating system

75
New cards

Concurency Issues

Lost Update: if a resource is read and updated by 2 transactions, the first update is lost.

Dirty Read Problem: A dirty read occurs when one transaction is permitted to read data that is being modified by another transaction which is running concurrently but which has not yet committed itself.

Unrepeatable read: n a transaction calculates some summary (aggregate) function over a set of data while other transactions are updating the data.

76
New cards

Mutexes

allow one thread access to a section of memory at any one time. If one thread locks the mutex, any other lock attempts will block until the first one unlocks

77
New cards

Context Switching

This is a feature of a multitasking operating system and allows a single CPU to be shared by multiple processes.

78
New cards

Resource Allocation For threads or Processes

In a multitasking environment, a process is switched out of the CPU so another process can be run. The state of the old process is saved and the state of the new process is loaded. On a pre-emptive system, processes may be switched out by the scheduler.

79
New cards

Scheduling in an OS

the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process

80
New cards

Routers

One of the primary jobs of a router is to assign IP addresses to the computers on a home network. The router has a "pool" of IP addresses that it keeps track of. When a computer connects to it and asks for an IP address, the router picks an IP address from the pool and assigns it to the computer.

One of the primary jobs of a router is to assign IP addresses to the computers on a home network. The router has a "pool" of IP addresses that it keeps track of. When a computer connects to it and asks for an IP address, the router picks an IP address from the pool and assigns it to the computer.

Routers can be used to create networks

81
New cards

Domain Names

Domain Names are names of locations on the internet. They map to an IP address and can be used to lookup an ip address in a dns sesrver.

82
New cards

Firewalls

prevents unauthorized access to or from a private network. monitors and controls incoming and outgoing network traffic based on predetermined security rules.

83
New cards

How does Google Search Work?

Crawling: Google searches the web with automated programs called crawlers, looking for pages that are new or updated. Google stores those page addresses (or page URLs) in a big list to look at later. We find pages by many different methods, but the main method is following links from pages that we already know about.

Indexing: Google visits the pages that it has learned about by crawling, and tries to analyze what each page is about. Google analyzes the content, images, and video files in the page, trying to understand what the page is about. This information is stored in the Google index, a huge database that is stored on many, many (many!) computers.

Serving search results: When a user performs a Google search, Google tries to determine the highest quality results. The "best" results have many factors, including things such as the user's location, language, device (desktop or phone), and previous queries. For example, searching for "bicycle repair shops" would show different answers to a user in Paris than it would to a user in Hong Kong. Google doesn't accept payment to rank pages higher, and ranking is done algorithmically.

84
New cards

Compilers

a compiler is a computer program that translates computer code written in one programming language into another language. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language to create an executable program

85
New cards

Multi Core

a single physical processor incorporates the core logic of more than one processor. Processor can run instructions on separate cores at same time. This increases overall speed of program execution in system. Thus heat generated by processor gets reduced and increases overall speed of execution.

Multicore systems support MultiThreading and Parallel Computing

86
New cards

Networks

A network consists of two or more computers that are linked in order to share resources

87
New cards

Map Reduce

used for generating big data sets with a parallel, distributed algorithm on a cluster. A MapReduce program is composed of a map procedure, which performs filtering and sorting, and a reduce method, which performs a summary operation.

88
New cards

concurrency vs parallelism

concurrency is about composing independent processes (in the general meaning of the term process) to work together, while parallelism is about actually executing multiple processes simultaneously.

89
New cards

kernel

The kernel is a computer program at the core of a computer's operating system that has complete control over everything in the system. It is the "portion of the operating system code that is always resident in memory", and facilitates interactions between hardware and software components

90
New cards

coroutine/ fibers

Coroutines (fibers) are very similar to threads. However, coroutines are cooperatively multitasked, whereas threads are typically preemptively multitasked. They work within threads, and are great for handling asynchronousity like network calls

91
New cards

Cooperative multitasking

a technique in which different pieces of software give up their immediate control of the processing unit of a computer so that another software can use it. The programs voluntarily give up their control as this allows other programs to use the processor of the computer

92
New cards

preemptive multitasking

an OS uses some criteria to decide how long to allocate to any one task before giving another task a turn to use the CPU

93
New cards

Performance Tests

testing practice performed to determine how a system performs in terms of responsiveness and stability under a particular workload

94
New cards

64-bit checksum

a value used to verify the integrity of a file or a data transfer. In other words, it is a sum that checks the validity of data. Checksums are typically used to compare two sets of data to make sure they are the same. ... For example, a basic checksum may simply be the number of bytes in a file

95
New cards

trade offs:

range based partitioning

vertical partitioning

hash based partitioning

range based partitioning - Range partitioning maps data to partitions based on ranges of values of the partitioning key that you establish for each partition. But it can lead to uneven distribution and higher latency for hot data

hash based partitioning - Partition based on a hash of the data. It distributes data evenly but data will need to be queried from each of the servers in the distributed system

96
New cards

Tradeoff: How does the load balancer choose the backend server

1. Least Connection Method — This method directs traffic to the server with the fewest active connections. This approach is quite useful when there are a large number of persistent client connections which are unevenly distributed between the servers.

2. Least Response Time Method — This algorithm directs traffic to the server with the fewest active connections and the lowest average response time.

3. Least Bandwidth Method - This method selects the server that is currently serving the least amount of traffic measured in megabits per second (Mbps).

97
New cards

tradeoffs long polling, polling, server sent events, websockets

Long Polling: a variation of the traditional polling technique that allows the server to push information to a client whenever the data is available

Polling:the client repeatedly polls (or requests) a server for data. The client makes a request and waits for the server to respond with data. If no data is available, an empty response is returned.

Server Sent Events: Under SSEs the client establishes a persistent and long-term connection with the server. The server uses this connection to send data to a client. The connection isn't closed after each response

Websockets: It provides a persistent connection between a client and a server that both parties can use to start sending data at any time.

98
New cards

Tradeoffs Databases

relational database - supports joins and is acid compliant

Dynamo - key value store

MongoDB - document

Cassandra,- wide columnar

InfiniteGraph - graph

HBase - wide-columnar, groups data together to store new data in a memory buffer and, once the buffer is full, it dumps the data to the disk

Bigtable-multiple files into one block to store on the disk and is very efficient in reading a small amount of data. (good for storing things like thumbnails)

99
New cards

tradeoffs: cache invalidation

Write-through cache: Under this scheme, data is written into the cache and the corresponding database at the same time. The cached data allows for fast retrieval and, since the same data gets written in the permanent storage, we will have complete data consistency between the cache and the storage. Also, this scheme ensures that nothing will get lost in case of a crash, power failure, or other system disruptions.

Although, write through minimizes the risk of data loss, since every write operation must be done twice before returning success to the client, this scheme has the disadvantage of higher latency for write operations.

Write-around cache: This technique is similar to write through cache, but data is written directly to permanent storage, bypassing the cache. This can reduce the cache being flooded with write operations that will not subsequently be re-read, but has the disadvantage that a read request for recently written data will create a "cache miss" and must be read from slower back-end storage and experience higher latency.

Write-back cache: Under this scheme, data is written to cache alone and completion is immediately confirmed to the client. The write to the permanent storage is done after specified intervals or under certain conditions. This results in low latency and high throughput for write-intensive applications, however, this speed comes with the risk of data loss in case of a crash or other adverse event because the only copy of the written data is in the cache.

Cache eviction policies

100
New cards

tradeoffs: cache eviction

First In First Out (FIFO): The cache evicts the first block accessed first without any regard to how often or how many times it was accessed before

Least Recently Used (LRU): Discards the least recently used items first.

Least Frequently Used (LFU): Counts how often an item is needed. Those that are used least often are discarded first.