happydecoder Profile picture
Oct 10, 2023 โ€ข 18 tweets โ€ข 6 min read โ€ข Read on X
๐—”๐—ฝ๐—ฝ๐—ฒ๐—ฎ๐—ฟ๐—ถ๐—ป๐—ด ๐—ณ๐—ผ๐—ฟ ๐—ฎ ๐˜€๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ฑ๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„ ?

Read this 8 system design non-functional requirements.

Non-Functional requirements defines qualities of a system, how a system is supposed to be.

For example: scalable, highly available, fast etc Image
๐Ÿญ. ๐—”๐˜ƒ๐—ฎ๐—ถ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

Availability = system uptime, the percentage of time system has been up

99% availability = the system was unavailable about 3.65 days a year.

Availability is measured as the success rate of requests.

99% availability = 99/100 = 1 req of 100 fails. Image
๐Ÿญ.๐—ฎ ๐—™๐—ฎ๐˜‚๐—น๐˜ ๐˜๐—ผ๐—น๐—ฒ๐—ฟ๐—ฎ๐—ป๐—ฐ๐—ฒ

If a system is fault tolerant, then it is also highly available.

A fault tolerant system aims 0 downtime.

A fault tolerant system is designed to continue to operate even if one of its connecting components fails. Image
eg. An airplane is a fault tolerant system, even if one engine fails, the other engine resumes immediately, and the system continues to operate.

๐Ÿญ.๐—ฏ ๐—ฅ๐—ฒ๐˜€๐—ถ๐—น๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ
A resilience system is almost the same as a fault tolerant system, one extra thing is,
a resilient system is designed to be periodically tested for fault tolerance.

A resilient system has a practice of periodically testing the system for faults by deliberately generating faults. Done using caos engineering, game day engineering etc Image
๐Ÿญ.๐—ฐ ๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

You may have a highly available system, but it might still suffer with frequent data corruption, and returns incorrect results.
Or the system is too slow and response is no longer useful.
Although we have availability, we donโ€™t have reliability. Image
Fault tolerant, resilience, and reliability relate to the same concept, availability.

When your interviewer asks you to design a fault-tolerant or resilient or reliable system, apply the same set of principles and best practices that is used for availability. Image
๐Ÿฎ. ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

Scalability is the ability of the system to handle growing load. Image
You can scale a system horizontally or vertically.

Ideally, horizontal and vertical scaling can be used in conjunction, eg, scale horizontally, then vertically, then again horizontally. Image
๐Ÿฎ.๐—ฎ ๐—˜๐—น๐—ฎ๐˜€๐˜๐—ถ๐—ฐ๐—ถ๐˜๐˜†

Elasticity is similar to scalability but it's for short term, tactical needs. Image
If our system is elastic, we can start with N machines at the start of the day, and keep adding machines throughout the day as the load increases. After the peak load has passed, we gradually decrease the number of machines. Image
๐Ÿฏ. ๐—ฃ๐—ฒ๐—ฟ๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐—ป๐—ฐ๐—ฒ

A highly performance system is quick with its request and response processing.
If your interviewer asked you to design a performant system, think in terms of latency and throughput. Image
๐Ÿฐ. ๐——๐˜‚๐—ฟ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†
In a durable system, once data is successfully submitted, it can not be lost.

You can achieve durability using
- Backup
- Raid
- Replication Image
๐Ÿฑ. ๐—–๐—ผ๐—ป๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐˜†
Consistency guarantees that your data is consistent across all distributed copies.

In a large distributed system consistency is hard to achieve.
Cap theorem tells that in case of a network partition, you can choose either consistent or availability.
๐Ÿฒ. ๐— ๐—ฎ๐—ถ๐—ป๐˜๐—ฎ๐—ถ๐—ป๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†
Maintainability is the ability of the system to go through repairs/modifications while it is up and running.

Once a fault is detected, it is desirable to be able to apply the necessary improvements asap, without having to shut down the system. Image
๐Ÿณ. ๐—ฆ๐—ฒ๐—ฐ๐˜‚๐—ฟ๐—ถ๐˜๐˜†
Security assures that all data within the system or its part is protected against any malware attacks/unauthorized access.
Security system include three fundamentals attributes, often referred to as the CIA triad
- Confidentiality
- Integrity
- availability Image
8. Cost

Cost non-functional requirement can be classified into - Development cost
- Maintenance cost
- Resource cost Image
Closing this thread now.

These are important system design concepts, and each non-functional requirement deserves a detailed post of its own.

More on that later.

Retweet and follow @happydecoder โค๏ธ

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with happydecoder

happydecoder Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @happydecoder

Oct 25, 2023
When you are running a simple monolith application, all your services run on the same set of instances.

Successful applications have a habit of growing over time and eventually becoming huge.

Once your application become huge, itโ€™s becomes a monstrous monolith Image
As the traffic grows, the load grows, the team grows, you start slowly transforming the monolith into a set of independent services.

In other words, you transform your monolith into a microservice architecture. Image
With microservices arises the problem of service discovery.

With multiple independent services in place, each running on its own set of instances.

How does the instance of one service identify the other ? Image
Read 22 tweets
Oct 24, 2023
๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐—ฝ๐—ฎ๐—ฟ๐˜๐—ถ๐˜๐—ถ๐—ผ๐—ป ๐—ฑ๐—ฎ๐˜๐—ฎ ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜€๐˜€ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐˜€ ?

๐Ÿงต Image
Once you've identified that your single database server is not enough to handle the huge volume of transactions and storage of data.

To incorporate improved availability and scalability, you decide to partitioned and shard your data.
Let's say you've decided to partition the data across 3 shards.

All the existing and incoming data should now reside on one of these shards.

How do you choose a shard for each user ? Image
Read 12 tweets
Oct 23, 2023
๐—Ÿ๐—ฒ๐˜'๐˜€ ๐—ด๐—ฒ๐˜ ๐—ถ๐—ป๐˜๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐—ฒ๐—ฑ ๐˜๐—ผ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—ฝ๐—ฎ๐—ฟ๐˜๐—ถ๐˜๐—ถ๐—ผ๐—ป๐—ถ๐—ป๐—ด.

๐Ÿงต Image
Partitioning and sharding are techniques used to divide and distribute large volumes of data into smaller, more manageable chunks.

The divided pieces of data is known as partitions.

When you distribute these partitions across multiple servers(shards), is known as sharding. Image
As your business grows, your data grow.

More requests, more storage, more cache etc.

Once your data gets huge, it gets difficult for a single server to manage it all alone.

e.g. a single monolithic database can become a bottleneck for huge volume of read/write queries.
Read 9 tweets
Oct 12, 2023
This one thread will teach you everything that you need to know about ๐——๐—ก๐—ฆ ( ๐——๐—ผ๐—บ๐—ฎ๐—ถ๐—ป ๐—ก๐—ฎ๐—บ๐—ฒ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ) ๐Ÿ“Œ

๐Ÿงต Image
We use IP addresses to visit websites on the internet.

Since humans cannot easily remember IP addresses to visit a website(domain name),

A global phone book was created.

The phone book maintains mappings of all domain names to IP addresses. Image
Client remembers the domain name.

It forwards the request with the domain name to the DNS server.

And DNS servers reply with the actual IP address associated with that domain name.

Clients move on to forward the request to that IP address. Image
Read 28 tweets
Oct 3, 2023
Learn HTTP cache like you'll never forget.

๐Ÿงต Image
This is part one of two parts series on HTTP cache.

Topics covered in part one:
- What is HTTP cache.
- How HTTP cache work.
- Types HTTP cache.
- States HTTP cache.

Part two will cover:
- HTTP ๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ฒ ๐—ต๐—ฒ๐—ฎ๐—ฑ๐—ฒ๐—ฟ๐˜€
- ๐—ถ๐—บ๐—ฝ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜ HTTP cache.
Let's go ๐Ÿš€

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ฒ ?

A cache is a temporary data store from which high-speed data retrieval is possible.

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—›๐—ง๐—ง๐—ฃ ๐—ฐ๐—ฎ๐—ฐ๐—ต๐—ฒ ?

HTTP cache is a storage that holds the frequently accessed resources on web pages.
Read 14 tweets
Oct 2, 2023
๐—œ๐—ฑ๐—ฒ๐—บ๐—ฝ๐—ผ๐˜๐—ฒ๐—ป๐—ฐ๐—ฒ ๐Ÿ“Œ

Idempotence is a property of certain operations/API.

An idempotent api can be repeated an arbitrary number of times.
And the result will be the same as if it had been done only once.

e.g. Sorting a list is idempotent, as repeated sorting has no effect
Idempotent operations are often used in the design of APIs, where a request to perform an operation is guaranteed to happen at least once, but might also happen more than once.

If the operation is idempotent, then there is no harm in performing the operation two or more times.
Let's take a look at an idempotent API for payments deduct implemented using idempotency key.

An idempotency key is a unique string generated by the client.
For example, base64 ASCII characters.

The client sends the idempotency key with each request.
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(