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

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 3
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
Sep 29
๐—”๐—ฃ๐—œ ๐—ฅ๐—ฎ๐˜๐—ฒ ๐—Ÿ๐—ถ๐—บ๐—ถ๐˜๐—ถ๐—ป๐—ด. ๐Ÿ“

When you're exposing an API service.

Chances are high that your service experiences a sudden burst in traffic.

This can degrade your system performance, and potentially lead to service outage.

How do you tackle this ?

๐Ÿงต
๐—”๐—ฃ๐—œ ๐—ฟ๐—ฎ๐˜๐—ฒ ๐—น๐—ถ๐—บ๐—ถ๐˜๐—ถ๐—ป๐—ด lets you limit the number of requests that a client can send to the server within a certain time interval.

Once the upper limit is reached,
Further requests are either queued for later processing, or straight up dropper and ignored.
Let's understand the core reasoning behind having a rate limiter in place.

Requests on the server consume resources, e.g CPU, memory, disk etc.

If your server is bombarded with more requests than it is designed to handle.
Read 19 tweets
Sep 21
๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—๐—ช๐—ง ๐—น๐—ถ๐—ธ๐—ฒ ๐˜†๐—ผ๐˜‚'๐—น๐—น ๐—ป๐—ฒ๐˜ƒ๐—ฒ๐—ฟ ๐—ณ๐—ผ๐—ฟ๐—ด๐—ฒ๐˜.

๐Ÿงต Image
Before I tell you all the fun part.

First, it's important to understand two key concepts.
- ๐—”๐˜‚๐˜๐—ต๐—ผ๐—ฟ๐—ถ๐˜€๐—ฎ๐˜๐—ถ๐—ผ๐—ป
- ๐—”๐˜‚๐˜๐—ต๐—ฒ๐—ป๐˜๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป

They are similar but not the same.

Let's see how ?
Say you're a developer in a tech company.

Your company ID card is your ๐—”๐—จ๐—ง๐—›๐—˜๐—ก๐—ง๐—œ๐—–๐—”๐—ง๐—œ๐—ข๐—ก - it's your identity.

As a developer you're authorized to code push and deploy.
But you're not authorized to access mergers and acquisition data.
Read 26 tweets
Aug 28
Requests on the internet consumes resources(cpu, time, memory etc).

If you're aiming for a high performance, high throughput system.

You should understand and internalise the concept of batching.

Follow, and Retweet. So my tweets can haunt you. Image
The idea of batching is pretty simple. Instead of sending each request or message separately, you group them together in a single request.

Usually, it is better to make fewer requests with more data as opposed to making more requests with less data.

why ? Image
With batching :
- you no need to pass http headers with every request

- no need to establish multiple connections and allocate memory resources for each requests.

- no need to create multiple threads to process requests (if the server is using the thread per request model).
Read 15 tweets
Aug 24
PROCESS VS THREAD

Reading this will help you understand how computer programs work and how they use your computerโ€™s resources. Image
Let's say you've got google chrome installed on your system.
Itโ€™s simply a file sitting on your disk.

When you click open chrome, you execute the file.
Your program comes to life. Memory space and other computing resources get allocated.

In other words, you initiated a process. Image
A process is a program in execution.

program = code file
process = code file + program counter + process stack + registers + heap etc

A program can have a single process or multiple processes.

for example - every time open a new tab in chrome, chrome spawns a new process. Image
Read 13 tweets
Aug 21
In a distributed world the micro services need to be able to talk to each other.

For instance,
When you hit the โค๏ธ button, the reaction service(service A) talks to the notification service(service B), and I'm notified of your reaction.

How does micro services communicateโ“ Image
There are two ways a service instance A can communicate with another service instance B.

1. Synchronous
2. Asynchronous
Synchronous -
In synchronous messaging the client sends its request directly to the server, and waits for the response to arrive.

The Client is dependent on the response from the server to proceed with its other requests.

HTTP REST is a good example. Image
Read 16 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 on Twitter!

:(