Introduction to System Design

Gather all requirements:

  1. Functional Requirements
  2. Non Functional Requirements
  3. Costing Limitation

Understand the expectation like

  1. Consistency
  2. Availability
  3. Performance
  4. Scalability

Selecting Various component which has fulfilled all the functional and non-functional requirements while meeting the constraints.

In this kind of interview are not hard to come up with solutions. But what we need to prove that, find which approach is suitable for the requirements.

And I will tell you the fun fact there is no one absolute solution to any problems. There can be multiple ways in which to design the uber, Facebook, NetFlix, and so on.

We have come up with approach 1 and approach 2 and take a decision on which approach is suitable. Sometimes both approaches will merge and that’s works perfect. Decision-making is the key role of the system design approaches. 

While designing considering: 

  • pick up the component
  • Select DataStore
  • Caching
  • Messaging
  • Types of Architecture – 1) event-driven or 2) Transactional
  • Availability
  • Number of Transaction
  • Number of Requests
  • Scale 
  • Number of Users

Think about what components are required as per requirements and start designing and coming up with the solutions.

Even after designing Architecture, your job doesn’t get over. You have to think about the future what are the places or the scenarios where the system is going to fail and what are the limitation of the system and what would be the follow-up and what would be version 2 of the system. That’s really important when comes to designing the system.

Example of System Design Architecture:

System Design – Architecture diagram

1. What is a System?

Architecture or collection of software(Technologies) that communicate with each other interact in order to serve a certain set of users to a certain set of requirements.

Example of System: 

Example applications
: Instagram, Whatsapp, Netflix and Hotstar

2. What is Design?

Design is a process of understanding the user requirements and selecting the components, modules, and software technologies and how they are interlinked and communicate with each were actually serve the needs of the system.

3. Why System Design?
System Design is the process of designing the architecture, components, and interfaces for a system so that it meets the end-user requirements.

Let’s now see what are the components of system design?

System Design

Topics to be covered: High-Level System Design

  1. Introduction to System Design
  2. Components of System Design
  3. Client-Side Architecture
  4. Proxies
  5. Data & Data Flow
  6. Database Types: SQL | NoSQL | Column | Search | Key Value
  7. Anatomy of Applications and Services
  8. API (Application Programming Interface)
  9. Caching | Cache patterns | Cache Invalidations & Eviction
  10. What is Rest API? | CRUD APIs | REST vs HTTP
  11. Message Queues | Producer consumer Model
  12. Pub-Sub Messaging | Publisher Subscriber
  13. Performance Metrics
  14. Fault & Failure in distributed System
  15. Scaling in nutshell | Horizontal vs Vertical Scaling
  16. Database Replication | Synchronous vs Asynchronous
  17. CAP | Consistency, Availablity, and Partitioning
  18. What is CAP Theorem? Degrees of CAP Theorem | Use cases
  19. What is Database sharding? Logical and Physical Shards
  20. Key-based Sharding | Shard Key | Hash function | Advantages and disadvantages
  21. Range-based sharding | Advantages, and disadvantages | Hotspots | Use Cases
  22. Directory-based sharding
  23. A simple introduction to the basics of hashing & need for Consistent Hashing
  24. Basics of consistent hashing in plain English
  25. Foundation of System Design Interview starting with Functional vs Non Functional Requirements
  26. How to solve capacity estimation problems faster? | Thumb rules and quick tips

HLD (High-Level system Design) Interview important Topic

  1. Websockets
  2. Polling (Short polling, long polling)
  3. Polling vs web sockets
  4. Server-Side Events (SSE)
  5. HTTPs, HTTP (Get put post delete)
  6. REST vs GraphQL
  7. Message Queues (pub-sub pattern)
  8. Proxy( Forward / Reverse proxy)
  9. Load Balancing (Reverse proxies)
  10. Horizontal scaling and vertical scaling
  11. Latency and throughput
  12. CAP Theorem
  13. Consistent hashing
  14. NoSQL / SQL (ACID)
  15. Storage (BLOB, Graph-based storage)
  16. Indexing
  17. Replication and sharding
  18. Caching (hit/ miss | LRU | LFU)
  19. Resiliency, Availability, Replication
  20. Paging & filtering
  21. Rate limiting
  22. Logging & Monitoring

AWS Regions and Zones

AWS Regions and zones:
AWS is a regions all around the world.
Regions is nothing but a data centers.

Regions and zone

Blue dots denotes that exists today. But the orange one coming soon.

AWS Budget Setup:

After successfully confirm you account. Then go to my account click on my billing Dashboard.

Then Go to Budget Tab

Set up you budget
On the Set budget details page, edit the Name field to read MyMonthlyBudget. For Period and Start date keep the default values. Specify your Budgeted Amount.

In the Budget parameters section, you can use these features to create budgets that track costs associated with a particular set of AWS services, linked accounts, tags, or other usage dimensions. For this tutorial, keep these values as the default.

Configure alert for when actual cost exceeds 50% of budget threshold

Scroll down to the Notifications (optional) section. In this section, you can have AWS Budgets contact you and others via email when budget conditions are met.

Configure the notification to fire when actual costs are greater than 50% of budgeted amount as pictured in the screen shot to the right. Add your email address and the email address of anyone who should receive this notification in the Email contacts field. Then select Add new notification.

Configure alert for when forecasted cost exceeds your budget

Configure this notification to fire when forecasted costs are greater than 100% of the budgeted amount as pictured in the screenshot to the right. Add your email address and the email address of anyone who should receive this notification in the Email contacts field. Then select the Add new notification.

Configure alert for when actual costs exceeds your budget

Configure this notification to notify you when actual costs are greater than 100% of budgeted amount. Add your email address and the email address of anyone who should receive this notification in the Email contacts field. Then select the Create button to create the budget and notifications.

Review your new budget
After the budget has been created, you see a list AWS Budgets you have created. It is a best practice to create a total monthly cost budget for each AWS account that you use.

You can create up to 62 budget days per month using the AWS Budgets service within the Free Tier limit. After that, you simply pay as you go to create additional budgets.

Inspect your new budget
To dive deeper into your budget details, click on your new budget. From there, you can view your budget details, access a budget performance summary, and inspect your historical budget performance.

Thank you for reading!

Top companies Node Js Interview questions 1

1) Difference between var, let, and const?


var msg = "Hello world";

    console.log("1 "+ msg)
console.log("2 "+ msg)

// output
// 1 Hello world
// 2 Hellow world

“var” is globally accessible, even if it is inside the scope like below example

    var msg = "Hello world";
    console.log("1 "+ msg)
console.log("2 "+ msg)

// output
// 1 Hello world
// 2 Hellow world

Above both “var” declaration gives output same.


But “let” variable type will not accessible from one to another.

    let msg = "Hello world";
    console.log("1 "+ msg)
console.log("2 "+ msg)
//  msg is not defined

Here the above example will give the output “msg is not defined”.

console.log("2 "+ msg)

ReferenceError: msg is not defined
    at Object.<anonymous>


const msg = "Hello";
    msg = msg + " world";
    console.log("1 "+ msg)
console.log("2 "+ msg)

const stands for constant.
The constant variable will not able to modify the values. So, it throws an error “type error” like below.

    msg = msg + " world";

TypeError: Assignment to constant variable.
    at Object.<anonymous>
var Globally Accessable on both inside and outside of scope
let Not Globally Accessable. It is accessable only in inside of scope
const Not Globally Accessable on both inside and outside of scope. Once declare and assign the variable will not able to modify the values.

Check the next questions to crack the interviews.

hacker-rank | min-max sum of array

find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.

arr = [1,3,5,7,9]

The minimum sum is 1+3+5+7 = 16 and the maximum sum is 3+5+7+9 = 24. The function prints

16 24

Output Format
Print two space-separated long integers denoting the respective minimum and maximum values that can be calculated by summing exactly four of the five integers. (The output can be greater than a 32-bit integer.)

Sample Input
1 2 3 4 5

Sample Output
10 14


The numbers are 1, 2, 3, 4, and 5. Calculate the following sums using four of the five integers:

  • Sum everything except 1, the sum is 1+2+3+4+5 = 14.
  • Sum everything except 2, the sum is 1+3+4+5 = 13.
  • Sum everything except 3, the sum is 1+2+4+5 = 12.
  • Sum everything except 4, the sum is 1+2+3+5 = 11.
  • Sum everything except 5, the sum is 1+2+3+4 = 10.

From the above calculation, 10 is the minimum and 14 is maximum.

Code language => Python


arr = [1,3,5,7,9]

def sumOfarray(arry):
    s = 0
    l = len(arry)
    for x in range(0,l):
        s =s+ arry[x]
    return s

def findminandmax(arr):
    sumOfarr = []
    for i in range(0, len(arr)):
        a  = arr[:]
    return print(str(min(sumOfarr)) + " "+ str(max(sumOfarr)))


# 16 24

Note: we use a deep clone([:]) or deep copy for changing an array without affecting previous array values.

Example for deep clone:
1st case without deep clone

# Example for deep clone:
a = [5, 2]
b  =  a
b[0] = 100
#[100 ,2]

2nd case with a deep clone [:]

# if we dont want to change variable a, then
a = [5,2]
b = a[:]
b[0] = 100

hacker-rank | print staircase right aligned with space and hash

Staircase detail

This is a staircase of size: n = 4


Note: Right-aligned #

Its base and height are both equal to n. It is drawn using # symbols and spaces. The last line is not preceded by any spaces.

Query: Write a program that prints a staircase of size n.

Function Description
The staircase has the following parameter(s):

int n: an integer
Print a staircase as described above.

Input Format
A single integer, n, denoting the size of the staircase.

Code language => Python


def staircase(n):
    l = n
    for x in range(0,l):
        ns = l-x -1
        print(ns * " "+("#")*(x+1))


# output

In python, we can multiply a string. eg,
=> “ab” * 2
=> abab
From above we can multiply the “ab” 2 times. So, we use the same concept to print space.

hacker-rank | calculate ratios of positive, negative, and zero elements

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with 6 places after the decimal.

Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with an absolute error of up to 10^4 are acceptable.

arr = [1, 1, 0, -1, -1]
There are n= 5 elements, two positive, two negative, and one zero. Their ratios are (2/5) = 0.400000 , (2/5) = 0.400000 and (1/5) = 0.200000. Results are printed as each in new lines:

Coding language => Python
Coding logic => own logic


arr = [-4, 3, -9, 0, 4, 1]

# iterating each number in list
def findcount(numbers):
    pos_count, neg_count, zero_count = 0, 0, 0
    for num in numbers:
        # checking condition
        if num > 0:
            pos_count += 1
        elif num == 0:
            zero_count += 1
        elif num < 0:
            neg_count += 1
    return [pos_count, neg_count, zero_count]

def plusMinus(arr):
    l = len(arr)
    ratiolist = findcount(arr) 
    ratioOfPositive = ratiolist[0] / l
    ratioOfNegative = ratiolist[1] / l
    ratioOfZero = ratiolist[2] / l
    print(format(ratioOfPositive,'.6f' )+"\n"+ format(ratioOfNegative,'.6f' )+"\n"+ format(ratioOfZero,'.6f' ))



NOTE: python print float digit with 6 decimal point
=> format(‘2′,’.6f’)
=> 2.000000

find factorial of a number in python simple way

Coding Style = my style of coding

Coding language = python

def findFactorial(num):
    a = 1
    for x in range(0, num):
       a = a * (num -x)
    return a

# 5! * 4! * 3! * 2! * 1!
# output : 
# 120

for x in range(0, 5)
Already set a = 1, so

First loop
=> a = 1 * (5 – 0)
=> a = 5

Second loop
=> a = 5 * (5 – 1)
=> a = 5 * 4
=> a = 20

Third loop
=> a = 20 * (5 – 2)
=> a = 20 * 3
=> a = 60

Fourth loop
=> a = 60 * (5 – 3)
=> a = 60 * 2
=> a = 120

Fourth loop
=> a = 120 * (5 – 4)
=> a = 120 * 1
=> a = 120
After that x range is now 4, we set only in the range between 0 to 5
Now loop ended. So we print( findFactorial(5) ) => its return answer 120.

Hope this logic will help you to understand the factorial concept in programming. Thank you for reading!

Regex | regular expression javascript | web form validation regex

some common regular expressions are below. If you find any errors comments below. I will correct my regex as soon as possible.
If you need any regex for your work, just ping below. I will help you to solve it.

Regex For Regex Example Description
` if((endix+1) == el.inputs.length){ tbody =tbody +``+el.for+`
`+inputer+``+el.descripton+`` } }); if((rix+1) == regexdata.length){ $tbody.innerHTML = tbody; } }); });
  • Standard Naming Regex
  • Email regex
  • comma-separated regex
  • Web URL regex
  • s3bucket regex

we will daily update all common regex soon. Please wait for a while. If you know or need any regular expression for your web development comment here. We will share our knowledge.