System Design

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

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.

20 Terms

1
New cards

Idempotency

an operation can be performed multiple times without changing the result. This is important because it helps maintain consistency and predictability in APIs, especially in situations where there are network issues, request retries, or duplicate requests.

Creating a payment

If an API call to create a payment is ______, then multiple calls to create a payment will still result in one payment.

To achieve this, we can keep track of the unique identifier of each request and check if we already had executed it.

2
New cards

domain model-driven API

A _______ is an API where the design and structure are based on the core business concepts and rules of the domain it serves. This means the API’s endpoints and operations are tailored to reflect meaningful actions within the business, such as creating an order for a customer in an e-commerce system, rather than just generic CRUD operations on data.

Example: In a banking API, instead of having generic endpoints like /transactions, a domain model-driven API would have /accounts/{accountId}/transactions to record a transaction for a specific account, ensuring the API closely aligns with real-world banking activities

3
New cards

Pagination

is a technique used in APIs to divide a large set of data into smaller, manageable chunks called pages. This makes it easier to retrieve, process, and display data without overwhelming the server or the client.

Example: In an API for a blog, instead of fetching all articles at once, you might use _____ to retrieve articles 10 at a time with a request like GET /articles?page=2&size=10, which fetches the second page of 10 articles. This improves performance and user experience.

4
New cards

Stateless architecture

is a design principle where each client request to the server is independent and contains all the information needed to process it. The server does not retain any memory of previous requests.

Example: HTTP, the protocol used by the web, is stateless. Each time you load a webpage, your browser sends all the necessary information in that single request, and the server responds without needing to remember any of your previous interactions.

5
New cards

atomicity (ACID)

Definition: refers to the property of an operation to be completed fully or not at all, ensuring that no partial or incomplete changes occur.

Example: In a database transaction, __________ ensures that all changes are applied completely, or the system reverts to its previous state to prevent errors.

6
New cards

Consistency (ACID)

The database must be consistent before and after the transaction.

When a transaction executes, the database might temporarily be in an invalid state. However, _________ ensures that once the transaction completes, the database returns to a valid state according to the rules set by the schema, constraints, and triggers. In other words, _________ ensures that data integrity is maintained throughout the transaction lifecycle.

7
New cards

Isolation (ACID)

Multiple Transactions occur independently without interference.

8
New cards

Durability (ACID)

The changes of a successful transaction occurs even if the system failure occurs.

To ensure _____ , databases usually write the transaction changes to a persistent storage (like a hard disk or SSD) before confirming the transaction. This way, even if something unexpected happens, the data is already saved somewhere safe and can be restored.

9
New cards

ACID

an acronym that refers to the set of 4 key properties that define a transaction: Atomicity, Consistency, Isolation, and Durability.

10
New cards

SpEL (Spring Expression Language)

Definition:

a powerful expression language integrated into the Spring framework. It allows dynamic evaluation of expressions in Spring-managed beans, supporting property access, method invocation, conditional logic, and more.

Key Features:

- Access bean properties and methods

- Perform arithmetic and logical operations

- Use conditional (ternary) expressions

- Work with collections

- Evaluate conditions dynamically in Spring annotations like @Value, @Cacheable, etc.

Example:

@Value("#{person.age > 18 ? 'Adult' : 'Minor'}")

private String personType;

This ______ expression above checks if person.age is greater than 18. If true, personType is set to "Adult", otherwise, it’s set to "Minor".

11
New cards

Exponential Backoff

is a retry strategy where the wait time between retries increases exponentially. This helps prevent overwhelming a system (like a server) when repeated failures occur.

Example:

For each failed request, the retry wait time doubles:

1. 1st retry: wait 1 second

2. 2nd retry: wait 2 seconds

3. 3rd retry: wait 4 seconds

4. 4th retry: wait 8 seconds

This method gradually reduces the frequency of retries, giving the system time to recover.

12
New cards

Metastable Failures

Definition:

A system failure that occurs when a seemingly stable system is operating near its capacity limit. Even a small disturbance can cause a cascading failure, overwhelming the system and making recovery difficult.

Example:

A cache expires, causing thousands of requests to hit a database at once. The sudden traffic overloads the database, leading to crashes and further failures in the system.

13
New cards

Metastable State

A system in a _____ is one that operates at high load or near its capacity limits. In this state, the system appears to be functioning normally, but it’s vulnerable to even small disturbances. Once the system crosses a certain threshold, it can tip over into failure. Think of it like a ball balanced at the top of a hill—small pushes won’t cause it to move, but a slight nudge beyond a certain point can make the ball roll down uncontrollably.

14
New cards

Load shedding

is a technique used to prevent a system from becoming overwhelmed by high traffic or excessive load. When a system reaches its capacity, load shedding selectively drops or rejects less critical requests to ensure that essential services remain functional. This helps maintain system stability and avoid total failure under heavy load.

Example:

A video streaming micro-service may start dropping requests for high-resolution video during a traffic spike, while still serving low-resolution video to maintain service for most users.

15
New cards

Circuit Breakers

a design pattern used to prevent a system from repeatedly calling a failing service or component, which could lead to a system overload or cascading failures.

Think of it like an electrical circuit breaker in your home. If there’s an overload or fault (like a short circuit), the breaker “trips,” cutting off power to prevent further damage. In software, a circuit breaker does something similar—it “opens” when it detects repeated failures in a service, temporarily stopping any further requests to that service.

There are 3 states :
closed → open → half open

16
New cards

Circuit Breaker - Closed State

Initially, the circuit breaker is _____ state meaning all requests to a service are allowed. If the service responds successfully, everything is fine.

17
New cards

Circuit Breaker - Open State

If the service starts failing (e.g., slow responses or errors), the circuit goes into a _______ state meaning no further requests are sent to the service for a period of time. This protects the system from overloading the failing service.

18
New cards

Circuit Breaker - Half Open State

In this circuit breaker state, after a timeout, the circuit tries to send a few test requests to see if the service has recovered. If the service works, the circuit goes into a closed state again; if it fails, the circuit stays in open state

19
New cards

Booststrap classes

  • Definition:
    "________" are the classes that the _____ class loader loads. These are essentially the core Java classes that are part of the Java platform.

  • Examples:
    Classes like java.lang.Object, java.lang.String, java.lang.System, and many others in the standard Java API are bootstrap classes.

  • Characteristics:

    • Loaded First: They are loaded before any application-specific classes.

    • Not Visible to User Code: Since the bootstrap class loader is implemented in native code, you typically cannot interact with it directly from your Java code.

    • Immutable: They are considered fixed parts of the Java runtime, and you usually cannot change or replace them.

20
New cards

A/B Testing

Aka split testing. A method to compare two versions of a feature (A and B) to see which performs better on a key metric, like conversion rate. Users are split into two groups, with one seeing Version A (control) and the other Version B (variant). Based on performance, you choose the better version. It's data-driven, reduces risk, and allows for incremental improvements, but requires sufficient sample size and proper statistical analysis.