happydecoder Profile picture
programmer - tweets about programming, and life advice that donโ€™t suck. prev. flipkart

Oct 10, 2023, 18 tweets

๐—”๐—ฝ๐—ฝ๐—ฒ๐—ฎ๐—ฟ๐—ถ๐—ป๐—ด ๐—ณ๐—ผ๐—ฟ ๐—ฎ ๐˜€๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ฑ๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„ ?

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

๐Ÿญ. ๐—”๐˜ƒ๐—ฎ๐—ถ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

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.

๐Ÿญ.๐—ฎ ๐—™๐—ฎ๐˜‚๐—น๐˜ ๐˜๐—ผ๐—น๐—ฒ๐—ฟ๐—ฎ๐—ป๐—ฐ๐—ฒ

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.

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

๐Ÿญ.๐—ฐ ๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

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.

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.

๐Ÿฎ. ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†

Scalability is the ability of the system to handle growing load.

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.

๐Ÿฎ.๐—ฎ ๐—˜๐—น๐—ฎ๐˜€๐˜๐—ถ๐—ฐ๐—ถ๐˜๐˜†

Elasticity is similar to scalability but it's for short term, tactical needs.

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.

๐Ÿฏ. ๐—ฃ๐—ฒ๐—ฟ๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐—ป๐—ฐ๐—ฒ

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.

๐Ÿฐ. ๐——๐˜‚๐—ฟ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†
In a durable system, once data is successfully submitted, it can not be lost.

You can achieve durability using
- Backup
- Raid
- Replication

๐Ÿฑ. ๐—–๐—ผ๐—ป๐˜€๐—ถ๐˜€๐˜๐—ฒ๐—ป๐—ฐ๐˜†
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.

๐Ÿณ. ๐—ฆ๐—ฒ๐—ฐ๐˜‚๐—ฟ๐—ถ๐˜๐˜†
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

8. Cost

Cost non-functional requirement can be classified into - Development cost
- Maintenance cost
- Resource cost

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 โค๏ธ

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling