Posts

Showing posts from November, 2023

Redundancy

Image
  Redundancy It is duplication of nodes or components so that when a node or components fails duplicate node is available to service customers. Active Redundancy When each unit is operating/active and responding to the action. Multiple loads are connected to load balancer & each unit receives an equal load. Passive Redundancy When 1 node is active/operational and the other is not responding. During the breakdown of active node , passive node maintains availability by becoming the active node.

Caching Eviction Techniques

Image
 Caching Eviction Techniques 1. LRU - Least Recently Used : It delete the cache not used in a very long time. 2. MRU - Most Recently Used : It delete the cache most recently used in a very long time. 3. LFU - Least Frequently Used : It delete the cache space among all which is least used 4. LIFO - Last In First Out :                                       5. FIFO - First In First Out : 6. RR - Random Replacement : 

Caching

Image
 Caching For Example : Instagram profile page which is a static information ,retrieve same information by clicking 10 times , for 1st time its retrieved from server ,for getting information next time onwards it can be store in cache ,inorder to reduce latency for getting response in lesser time.                                                                      Instagram profile page Data Retrieval Two Types: Memory / Locale Cache : Example: Memcached When to be use ? 1. Read Intensive : 2. Static Contents Distributed / Extended Cache: Example: Redis Two Types: 1. Application Server Cache : DB query response query server in cache. 2. CDN

Scalability

Image
  Scalability When number of requests increases ,it determines strength of system is up or down, response time should decrease or it should be maintained. Vertical Scalability 1 machine having 1 server with high configuration , RAM we can increase , DB Hard Disk we can increase. PROS                                                                  Easy Implementation                                                                                                                                    ...

Designing Instagram

Image
  Designing Instagram

Lamport Logical Clock

Image
Sequence of events are taken into count , when server are at different geographical regions of the world . Different geographical regions have different timestamp. Different server at different place with different timestamp Two process P1,P2 process ,events are taking place :  New event take place: increment the count Received event: Maximum of event1 & event2 ,by increment of 1

Examples of CAP Theorem:

Image
  CAP Theorem: For a distributed System, CAP Theorem states that it is possible to attain only two properties and the third would be always compromised.  Examples of CAP Theorem: Note: Partition Tolerance is important part .So we have option to choose either Availability or Consistency inorder to achieve CAP Theorem statement. Which is more important? Availability or Consistency a) Blog Website :  Availability   Reason:   It is necessary for it to be available. b) Multiplayer online game  :  Availability  Reason:   It is necessary for it to be available for user experience. c) Bank : Consistency Reason: Amount /Data inserted should be consistent.                               This should not happen balance after cash deposit of amount 100 still showing 0 d) Ticket Booking System :   Consistency Reason: Ticket booked for a seat should be updated fo...

CAP Theorem

Image
  CAP Theorem C- Consistency This should not happen balance after cash deposit of amount 100 still showing 0 A- Availability CBSE website goes down during result days due to heavy user request traffic P- Partition Tolerance                                                                               Server Down: Partition i.e Network Partition                                                                              Tolerance: Use Replicas

Necessity of Two properties among CAP theorem

Image
  Necessity of Two properties among CAP theorem For a distributed System, CAP Theorem states that it is possible to attain only two properties and the third would be always compromised.  System Design can select : Consistency and Partition Tolerance but Availability is compromised. Consistency and Availability but Partition Tolerance is compromised. Availability and Partition Tolerance but Consistency is compromised. Consistency and Availability when system is centralized  only possible when same DB is used. Partition Tolerance is important part .So we have option to choose either Availability or Consistency inorder to achieve CAP Theorem statement

Factors Improving Consistency

Image
  Factors Improving Consistency: 1.Improving network Bandwidth : Increase the speed , synchronization will be fast. 2.Stop the Read: Government website is down ,until the new update is updated. 3.Replication based on Distance aware strategies: Server is very close , then synchronization help. Types of consistency: Strong Consistency Eventual Consistency Weak Consistency When the system doesn’t allow Read operation until all nodes with replicated data are updated. Example: ticket booking User Read Request are not halted till all the replicas are updated rather the update process is eventual. Some users might receive old data but eventually all the data is updated to latest data. Ex: Social Media posts if updated late then its ok Same post, but after updating post, some see latest post, some still see old post data All the nodes are not in synchronization depend on business logic. ...

Consistency

Image
 Consistency example: Bank Balance not yet updated , it is still showing balance to be zero. Here User 1 and User 2 must get same data ,inorder to be consistent. When more than one client requests the system, for all such requests, it will be called consistent when each client gets the same data. The data should always be consistent ,regardless of who is accessing it. Here Bank Balance is inconsistent as after cash deposit it should show balance of amount 100 not of amount 0. When more than one client request the system , for all such requests, when different clients get different responses due to some recent updates that has not been committed to all system yet, this read operation will be called dirty read. 

Availability

Image
 Availability: Example: Official CBSE website on Result day => Lots of students visit website => Website not available To make sure that it is available every time like Google. Monolithic Architecture: On same server ,all modules deployed at same place. Distributed System : Replica of each module is done. Fault Tolerance is directly proportional to Availability. Hence Distributed System is more available. How to increase Availability: 1. Use of Distributed System 2. Replication and Redundancy Replication : It involves redundancy , copying of data from 1 node to another or synchronization of states between nodes. Redundancy: It is duplication of nodes, in case some of them are failing.

Factors affecting Throughput and how to improve throughput

  Causes of low throughput : 1. Latency: If latency increases ,throughput decreases. 2. Protocol Overhead: Between Two server , to and fro communication , Handshake .Therefore latency increases ,throughput decreases. 3. Congestion: Too many requests received at a time. How to improve throughput : 1. Using CDN (Content Delievery Network) 2. Caching 3. Distributed System 4. Load Balancer 5. Improved Resources 

Throughput

Image
  Throughput      Volume of work or information flowing through a system.     100 video in 100 days -> 1 video per day.    Monolithic Architecture :    Data is in  1 system .    1 work done by 1 resource.   Distributed System :  1 work done by many resources.   No limit of resources - Horizontal Scaling can be done by adding more machine.   Load Balancer - Round Robin Fashion request is given to each machine one by one.              

How to reduce latency inorder to increase user friendly experience?

  Method to reduce latency: 1. Caching : Process of storing information for a set period of time on a computer. It reduces time of response by sending data to user directly Let take an example of function returning id value after 1000 lines , we can use caching key to return id value. example: idValue(int id){ //after 1000 lines return id; } 2. CDN --Content Delivery Network   static data--[not much change in data] Data from USA kept in India by CDN Server [ i.e mostly static data] to get information faster. CDN -Geographically distributed network of proxy server and their objective is to serve content to users more quickly. 3. Upgrade your system

Latency

Image
  Latency: Monolithic Architecture :[server at same place]: Latency = computational delay. Distributed System: [server at different place]: Latency = network delay +computational delay. Network Delay : Round Trip time taken by server. Computational Delay: Time taken by server to take data and return information. Here t3 is computational delay ; t1 and t2 is network delay Monolithic Architecture=t3 Distributed System=t1+t2+t3

Distributed System

Image
  Distributed System: Collection of multiple individual system connected through a network that share resources, communicate and coordinate to achieve goals. Advantages: 1. Scalable - we can horizontally scalable by adding more machine / replica to improve its capability. 2. No single point of failure - Replicas will support ,if system fails. 3. Low Latency - If system is distributed , we can put system anywhere in a region .                                   If system is centralized ,it will be at one place only. Disadvantages: 1. Complex: Distributed System has so many servers and nodes, so it  is complex. 2. Management Requirement: Additional Detail Required for so many server /nodes to get connected ,  when  network is said to be distributed . 3. Difficult to secure. 4. Message may be lost in between nodes.

Monolithic Architecture

Image
  Architecture - Internal Design of  system Monolithic Architecture  It is also called Centralized Architecture . If all the components and function of projects are entangled together and deployed in a single codebase -- Monolithic Architecture It provide less complexity ,easy to understand ,resulting in higher production . In case of few users ,we use Monolithic Architecture.

Difference between HLD(High Level Design) and LLD(Low Level Design)?

Image
  Difference between HLD(High Level Design) and LLD(Low Level Design)?                                                                                                                                                                                                                     HLD (High Level Design)    LLD (Low Level Design)   a)Describes the  main components that would be developed for the...

What is System Design?

Image
What is System Design?                                                                                                                                                                                     Process of designing the elements of system such as architecture ,modules and components etc.                                                                       ...