0% found this document useful (0 votes)
25 views3 pages

Sys Design

System design involves planning the architecture and components of a system. It includes high-level design (HLD) describing major modules and their relationships, and low-level design (LLD) detailing each component. Key aspects of system design include architecture, latency, throughput, availability, consistency, load balancing, and scaling approaches like distributed and monolithic architectures. Design must consider principles like the CAP theorem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Sys Design

System design involves planning the architecture and components of a system. It includes high-level design (HLD) describing major modules and their relationships, and low-level design (LLD) detailing each component. Key aspects of system design include architecture, latency, throughput, availability, consistency, load balancing, and scaling approaches like distributed and monolithic architectures. Design must consider principles like the CAP theorem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

System Design

 It is the process of designing the elements of a system such as the architecture, modules and components,
different interfaces of those components and the data that goes through that system.
 Main components are HLD and LLD
 HLD: describe the main components that would be developed for the resulting product like system
architecture design, db design, services, processes, the relationship btwn various modules and features.
 LLD: describes the design of each element mentioned in the HLD. Like classes, interfaces relationships btwn
diff classes and actual logic of the various components.
 Architecture  internal design details for building the applications.
 Latency: network delay + computation delay.
 Throughput: amount of data transmitted per unit of time. It is the process flow rate. Measured in bits/sec.
 Availability [Redundancy-only copy, types: active and passive |and Replication-copy+ synchronized]
 Consistency [improve bandwidth, replication based on distance aware strategies] (strong: ticket booking,
banking and eventual consistency: social media, live streaming)
 Load balancing: Process of efficient distribution of network traffic across all nodes in distributed system.
Does health check, high scalability, high throughput and availability, supports horizontal scaling.
Types: Round robin(static), weighted round robin(static), IP hash algo(static) Source IP hash(static), Least
connection algo(dynamic), least response time(dynamic).
 Consider a web application : (main components: frontend, backend, data storage/db)
o Monolithic architecture- all three written and deployed together. Also called centralized.
o When it is good :
 at the beginning
 all modules are present in the single system, so they require fewer network calls.
 Easier to secure
 Easy testing
 Less confusion/maintenance.

o Disadvantages:
 Error detection and debug is difficult
 Re-deployment after each update or error correction
 Mono language constraint, and one error might effect the whole application.
 no scaling and single point of failure.
o Distributed system architecture- different modules are written in different execution environment,
and they have diff code bases.

 Multiple individual systems connected through a network that share resources and
communicate and coordinate.
 overcomes single point of failure and scaling and low latency (more than monolithic), more
throughput, high availability.
 Reduce latency : by caching(storing on server/client a period), CDN(content delivery
network- geographically distributed), hardware upgradation.
 data lose can occur so we maintain replica.
 Complex, need load balancing, hard to secure, message loss.

 CAP Theorem:
o Consistency Availability, Partition tolerance.
o Possible to attain only 2, the third is always compromised.
o 1st preference is P choice btwn C and A.

 Lamport logical clock: maintains the clock across the servers on diff
geographical locations.
 if event occurs then count ++ ;
 receive = max(val of curr-1, val of curr-2)+1;
 Scalability:
o Vertical scaling : improving the hardware resources.
o Horizontal scaling: adding nodes/ resources (distributing system).

 RDBMS: overcomes all the flaws of file system storage but had constrain on horizontal scaling so we use
NoSQL.
 NoSQL: key-value db(redis) , document db(mongo) , columnar db(cassandra) , graph db(neo4j).
 Polyglot persistence: using diff databases for diff modules in the same applications.

 Indexing in DB: Indexing creates a lookup table with the column and the pointer to the memory location of
the row, containing this column.
Separate sorted column is created for the particular column and for each entry the corresponding row
pointer is created.- BTree is used for that pointer storing.
 Synchronous and Asynchronous (Kafka or RabbitMQ ).
 Communication protocol: push(be connected and get updates), polling/pull(ask-get), long polling, socket
(create channel and communicate) , server sent events (get updates even when the connection is not
established, like notification even after closing app).
 Service-Oriented Architecture (SOA): It is a style of architecture that promotes loose coupling and granular
applications to make the components of the software reusable.
o Advantages: selective scaling, diff tech stack, loose coupling, agile!
o Disadvantages: higher latency, complex to secure, cascading failures, complex understanding.
 Microservice architecture: is an evolved version of SOA that promotes software components to be loosely
coupled. Every service is completely independent of each other (diff db for each service).
 Authentication(verify myself) and Authorization (what can I do)
 Token based authentication: no need to use username and pw each time, token gets expires after each
period of time.
 OAuth – enables user account info to be used by 3rd party services eg: “login with google”, “login with
facebook”, etc.
 Proxy: proxy server is a hardware or a piece of software that is placed btwn a client and application to
provide intermediary services in the communication.
o Forward proxy- (hides client)
 Used by client.
 Client->Proxy server->main server
 Server doesn’t know the client.
o Reverse proxy- (hides server)
 Used by server side
 Client->proxy server<-main server
 User don’t know who which server is responding.
 Functional and non-functional requirements.
 Refer this Example, Example2
 HLD: Step-1 : API
Step-2 : db
Step-3 : algorithm
Step-4 : design

 System design of DROPBOX:


o Functional requirements: upload, download, share
o Non-functional requirements: scalable, low latency, high available, optimize data transfer by
minimizing bandwidth, ACID [Atomicity Consistency Isolation Durability]
o Estimate the system capacity:
 1 billion users
 avg user stores 20GB
 total space 20 billion GB
o High level design:

o What client can do:


 Upload, download, delete.

o DB: mysql for high consistency


o Synchronizer: should notify client after each update. Listens to messaging queue.

You might also like