System Design Concepts Course and Interview Prep
Summary
TLDRThe tutorial comprehensively covers system design, focusing on scalability, reliability, data handling, and high-level architecture. It is structured to help viewers prepare for system design interviews by explaining core concepts and practical strategies. Key topics include understanding computer architecture, load balancing, caching, networking protocols, and API design. The CAP theorem is discussed to highlight trade-offs in system design. Various database types and scaling strategies are explored, along with load balancing techniques using proxy servers. The importance of redundancy, cache evictions, and network traffic management is emphasized to build efficient and resilient systems.
Takeaways
- 💡 Scalability is crucial in system design for handling increased loads and ensuring growth.
- ⚙️ High-level architecture serves as the blueprint for designing robust systems.
- 📦 Caching data optimizes performance by reducing data retrieval times.
- 🔍 Understanding the CAP theorem helps make informed trade-offs.
- 🔗 Load balancers distribute network traffic to prevent overloading on a single server.
- 🗂️ Different database types serve unique needs, from SQL to NoSQL to in-memory databases.
- 📌 Proxies act as intermediaries, with types like forward and reverse proxies enhancing security and performance.
- 🔐 Networking fundamentals, including IP addresses and protocols, are key to system communication.
- 🚦 API design, including REST, GraphQL, and gRPC, can drastically affect system efficiency.
- 🔄 Consistent health checks ensure server and system components are always operational.
Timeline
- 00:00:00 - 00:05:00
This video is a comprehensive guide on system design, emphasizing the importance of understanding the high-level architecture of computers before delving into larger distributed systems. It covers the basics of computer storage including bits, bytes, and more complex units like terabytes. It explains the differences between SSD and HDD storage, highlighting the speed advantages of SSDs. The video also discusses RAM, its use for active processes, and the concept of cache alongside CPU operations.
- 00:05:00 - 00:10:00
The next section focuses on the architecture of a production-ready application, starting with the CI/CD pipeline for automated code deployment using platforms like Jenkins. It describes how user requests are managed through load balancers and external storage systems, along with communication between multiple servers. Logging and monitoring systems are crucial for detecting system anomalies, and developers are advised to debug issues in non-production environments.
- 00:10:00 - 00:15:00
A discussion on system design principles follows, stressing scalability, maintainability, and efficiency. It highlights the importance of planning for system failures and discusses the CAP theorem's trade-offs between consistency, availability, and partition tolerance. The concept of system availability is linked to SLAs and SLOs, illustrating the goal of high uptime for essential services.
- 00:15:00 - 00:20:00
Networking basics are covered, starting with IP addresses and the use of IPv4 and IPv6. It explains how data is transmitted over a network using packets, and the roles of TCP and UDP at the transport layer. The importance of DNS for translating domain names into IP addresses is also mentioned, along with the foundational role of application layer protocols in web communication.
- 00:20:00 - 00:25:00
The section on application layer protocols delves deeper into HTTP and its status codes, while explaining the functionality of WebSockets for real-time communication. The video details the use of SMTP, IMAP, and POP3 for email, FTP and SSH for file transfers, and WebRTC and MQTT for real-time communication. RPC is also discussed as a method for executing remote procedures, emphasizing its wide application.
- 00:25:00 - 00:30:00
Next, the video explores API design best practices, using an e-commerce platform as an example. It discusses implementing CRUD operations, designing endpoints, and choosing between REST, GraphQL, and gRPC paradigms. The importance of maintaining backward compatibility and setting rate limits is stressed to ensure efficient API performance and user satisfaction.
- 00:30:00 - 00:35:00
Caching and content delivery networks (CDNs) are introduced as strategies to reduce latency and improve user experience. The video describes browser, server, database, and CDN caching, detailing how each type helps store data temporarily for quicker access. Different strategies, such as push and pull CDN methods, are covered to highlight their benefits.
- 00:35:00 - 00:40:00
Proxy servers, both forward and reverse, serve different functions in managing client-server interactions. Forward proxies assist with privacy and content filtering, while reverse proxies handle load balancing, caching, and SSL termination. The advantages of employing proxies in network management are outlined, including improved security and performance.
- 00:40:00 - 00:45:00
Load balancing strategies are detailed, explaining algorithms such as round robin, least connections, and IP hashing. The video describes the importance of continuous server health checks to ensure traffic is directed appropriately. Popular load balancer types, from hardware to software solutions, and their role in preventing system overload are examined.
- 00:45:00 - 00:53:38
Finally, the video addresses databases in system design, explaining different types such as SQL and NoSQL, their scaling methods, and performance improvement techniques such as sharding and indexing. The ACD principles are highlighted, alongside the trade-offs of the CAP theorem. It summarizes strategies to ensure database efficiency and reliability in distributed systems.
Mind Map
Video Q&A
What are the main topics covered in this system design tutorial?
The tutorial covers scalability, reliability, data handling, and high-level architecture with real-world examples.
What is the importance of understanding high-level architecture in system design?
Understanding high-level architecture is crucial before designing large-scale, distributed systems.
How are computers structured to execute code?
Computers function through a layered system, starting from binary data (bits and bytes), progressing through storage types (RAM, SSD, HDD), and utilizing cache and CPUs.
What role do load balancers and reverse proxies play in system design?
Load balancers and reverse proxies distribute user requests evenly across multiple servers to maintain smooth performance even during traffic spikes.
What are the key principles of good design in system architecture?
Scalability, maintainability, efficiency, planning for failure, and building resilient systems are the key principles.
What is the CAP theorem in system design?
The CAP theorem outlines the trade-offs between consistency, availability, and partition tolerance in distributed systems, asserting that you can only prioritize two.
How does caching improve system performance?
Caching stores copies of data for faster access, reducing latency and server load by serving frequently requested data from a closer location.
What are the common types of databases discussed in the tutorial?
Relational databases (SQL), NoSQL databases, and in-memory databases are discussed, each serving different use cases.
What strategies are used for effective load balancing?
Common load balancing strategies include round-robin, least connections, least response time, IP hashing, and weighted algorithms.
What are proxy servers and their types?
Proxy servers act as intermediaries between clients and servers, existing in types like forward proxies, reverse proxies, and open proxies.
View more video summaries
- 00:00:00this complete system design tutorial
- 00:00:02covers scalability reliability data
- 00:00:04handling and high level architecture
- 00:00:07with clear explanations real world
- 00:00:09examples and practical strategies hike
- 00:00:12will teach you the Core Concepts you
- 00:00:14need to know for a system designs
- 00:00:17interview this is a complete crash
- 00:00:19course on system design interview
- 00:00:21Concepts that you need to know to as
- 00:00:23your job interview the system design
- 00:00:25interview doesn't have to do much with
- 00:00:27coding and people don't want to see you
- 00:00:28write actual code but how you glue an
- 00:00:30entire system together and that is
- 00:00:32exactly what we're going to cover in
- 00:00:34this tutorial we'll go through all of
- 00:00:36the concepts that you need to know to as
- 00:00:38your job interview before designing
- 00:00:41large scale distributed systems it's
- 00:00:43important to understand the high level
- 00:00:45architecture of the individual computer
- 00:00:47let's see how different parts of the
- 00:00:49computer work together to execute our
- 00:00:52code computers function through a
- 00:00:54layered system each optimized for
- 00:00:56varying tasks at Decor computers
- 00:00:59understand only binary zeros and ones
- 00:01:02these are represented as bits one bit is
- 00:01:05the smallest data unit in Computing it
- 00:01:07can be either zero or one one bite
- 00:01:11consists of eight bits and it's used to
- 00:01:13represent a single character like a or
- 00:01:15number like one expanding from here we
- 00:01:18have kilobyte megabyte gigabytes and
- 00:01:21terabytes to store this data we have
- 00:01:24computer disk storage which holds the
- 00:01:26primary data it can be either htd or SS
- 00:01:30D type the disk storage is nonvolatile
- 00:01:33it maintains data without power meaning
- 00:01:35if you turn off or restart the computer
- 00:01:38the data will still be there it contains
- 00:01:41the OS applications and all user files
- 00:01:44in terms of size discs typically range
- 00:01:46from hundreds of gigabytes to multiple
- 00:01:49terabytes while ssds are more expensive
- 00:01:53they offer significantly faster data
- 00:01:55retrieval than HDD for instance an SSD
- 00:01:58may have a r speed of 500 MB per second
- 00:02:01to
- 00:02:023,500 while an HDD might offer 80 to 160
- 00:02:07mb per second the next immediate access
- 00:02:10point after dis is the Ram or random
- 00:02:12access memory RAM serves as the primary
- 00:02:15active data holder and it holds data
- 00:02:18structures variables and applications
- 00:02:20data that are currently in use or being
- 00:02:23processed when a program runs its
- 00:02:26variables intermediate computations
- 00:02:28runtime stack and more are stored in Ram
- 00:02:31because it allows for a quick read and
- 00:02:33write access this is a volatile memory
- 00:02:36which means that it requires power to
- 00:02:38retain its contents and after you
- 00:02:40restart the computer the data may not be
- 00:02:43persisted in terms of size Rams range
- 00:02:46from a few Gaby in consumer devices to
- 00:02:49hundreds of gabt in high-end
- 00:02:52servers their read right speed often
- 00:02:54surpasses 5,000 megabytes per second
- 00:02:57which is faster than even the fastest SS
- 00:03:00this dis speed but sometimes even this
- 00:03:02speed isn't enough which brings us to
- 00:03:04the cache the cache is smaller than Ram
- 00:03:07typically it's measured in megabytes but
- 00:03:10access times for cach memory are even
- 00:03:12faster than Ram offering just a few Nan
- 00:03:15for the L1 cache the CPU first checks
- 00:03:18the L1 cach for the data if it's not
- 00:03:21found it checks the L2 and L3 cache and
- 00:03:24then finally it checks the ram the
- 00:03:26purpose of a cach is to reduce the
- 00:03:28average time to Access Data that's why
- 00:03:31we store frequently used data here to
- 00:03:33optimize CPU performance and what about
- 00:03:36the CPU CPU is the brain of the computer
- 00:03:40it fetches decodes and executes
- 00:03:42instructions when you run your code it's
- 00:03:44the CPU that processes the operations
- 00:03:47defined in that program but before it
- 00:03:49can run our code which is written in
- 00:03:51high level languages like Java C++
- 00:03:54python or other languages our code first
- 00:03:57needs to be compiled into machine code a
- 00:04:00compiler performs this translation and
- 00:04:02once the code is compiled into machine
- 00:04:04code the CPU can execute it it can read
- 00:04:07and write from our Ram disk and cach
- 00:04:09data and finally we have motherboard or
- 00:04:12main board which is what you might think
- 00:04:14of as the component that connects
- 00:04:16everything it provides the path phase
- 00:04:19that allow data to flow between these
- 00:04:21components now let's have a look at the
- 00:04:23very high level architecture of a
- 00:04:25production ready up our first key area
- 00:04:28is the cicd pipeline continuous
- 00:04:30integration and continuous deployment
- 00:04:32this ensures that our code goes from the
- 00:04:34repository through a series of tests and
- 00:04:37pipeline checks and onto the production
- 00:04:39server without any manual intervention
- 00:04:42it's configured with platforms like
- 00:04:44Jenkins or GitHub actions for automating
- 00:04:46our deployment
- 00:04:47processes and once our app is in
- 00:04:50production it has to handle lots of user
- 00:04:52requests this is managed by our load
- 00:04:54balancers and reverse proxies like
- 00:04:57ngx they ensure that the user request
- 00:04:59are evenly distributed across multiple
- 00:05:01servers maintaining a smooth user
- 00:05:04experience even during traffic specs our
- 00:05:07server is also going to need to store
- 00:05:09data for that we also have an external
- 00:05:11storage server that is not running on
- 00:05:13the same production server instead it's
- 00:05:16connected over a
- 00:05:17network our servers might also be
- 00:05:20communicating with other servers as well
- 00:05:22and we can have many such services not
- 00:05:24just one to ensure everything runs
- 00:05:27smoothly we have logging and monitoring
- 00:05:29system s keeping a Keen Eye on every
- 00:05:31micro interaction of storing logs and
- 00:05:33analyzing data it's standard practice to
- 00:05:36store logs on external Services often
- 00:05:38outside of our primary production server
- 00:05:42for the back end tools like pm2 can be
- 00:05:44used for logging and monitoring on the
- 00:05:46front end platforms like Sentry can be
- 00:05:48used to capture and Report errors in
- 00:05:51real time and when things don't go as
- 00:05:53plann meaning our logging systems detect
- 00:05:55failing requests or anomalies first it
- 00:05:58enforce our alerting service after that
- 00:06:01push notifications are sent to keep
- 00:06:03users informed from generic something
- 00:06:05rank wrong to specific payment failed
- 00:06:07and modern practice is to integrate
- 00:06:09these alerts directly into platforms we
- 00:06:12commonly use like slack imagine a
- 00:06:14dedicated slack Channel where alerts pop
- 00:06:16up at the moment an issue arises this
- 00:06:19allows developers to jump into action
- 00:06:21almost instantly addressing the root CS
- 00:06:23before it escalates and after that
- 00:06:26developers have to debug the issue first
- 00:06:28and foremost the issue needs to be
- 00:06:30identified those logs we spoke about
- 00:06:32earlier they are our first Port of Call
- 00:06:35developers go through them searching for
- 00:06:37patterns or anomalies that could point
- 00:06:39to the source of the problem after that
- 00:06:41it needs to be replicated in a safe
- 00:06:43environment the golden rule is to never
- 00:06:46debug directly in the production
- 00:06:47environment instead developers recreate
- 00:06:50the issue in a staging or test
- 00:06:52environment this ensures users don't get
- 00:06:54affected by the debugging process then
- 00:06:57developers use tools to peer into the
- 00:06:58running app apption and start debugging
- 00:07:01once the bug is fixed a hot fix is
- 00:07:03rolled out this is a quick temporary fix
- 00:07:06designed to get things running again
- 00:07:08it's like a patch before a more
- 00:07:09permanent solution can be implemented in
- 00:07:12this section let's understand the
- 00:07:13pillars of system design and what it
- 00:07:16really takes to create a robust and
- 00:07:17resilent application now before we jump
- 00:07:20into the technicalities let's talk about
- 00:07:23what actually makes a good design when
- 00:07:25we talk about good design in system
- 00:07:27architecture we are really focusing ing
- 00:07:29on a few key principles scalability
- 00:07:32which is our system growth with its user
- 00:07:34base maintainability which is ensuring
- 00:07:37future developers can understand and
- 00:07:39improve our system and efficiency which
- 00:07:42is making the best use of our resources
- 00:07:45but good design also means planning for
- 00:07:47failure and building a system that not
- 00:07:49only performs well when everything is
- 00:07:51running smoothly but also maintains its
- 00:07:54composure when things go wrong at the
- 00:07:57heart of system design are three key
- 00:07:58elements moving data storing data and
- 00:08:01transforming data moving data is about
- 00:08:05ensuring that data can flow seamlessly
- 00:08:07from one part of our system to another
- 00:08:10whether it's user request seeding our
- 00:08:12servers or data transfers between
- 00:08:14databases we need to optimize for Speed
- 00:08:17and security storing data isn't just
- 00:08:19about choosing between SQL or nosql
- 00:08:22databases it's about understanding
- 00:08:24access patterns indexing strategies and
- 00:08:27backup Solutions we need to ensure that
- 00:08:29our data is not only stored securely but
- 00:08:31is also readily available when needed
- 00:08:34and data transformation is about taking
- 00:08:37row data and turning it into meaningful
- 00:08:39information whether it's aggregating log
- 00:08:42files for analysis or converting user
- 00:08:44input into a different format now let's
- 00:08:47take a moment to understand the crucial
- 00:08:49Concept in system design the cap theorem
- 00:08:52also known as Brewers theorem named
- 00:08:54after computer scientist Eric Brewer
- 00:08:57this theorem is a set of principles that
- 00:08:59guide us in making informed tradeoffs
- 00:09:01between three key components of a
- 00:09:03distributed system consistency
- 00:09:06availability and partition tolerance
- 00:09:09consistency ensures that all nodes in
- 00:09:11the distributed system have the same
- 00:09:13data at the same time if you make a
- 00:09:15change to one node that change should
- 00:09:17also be reflected across all nodes think
- 00:09:20of it like updating a Google doc if one
- 00:09:23person makes an edit everyone else sees
- 00:09:25that edit immediately availability means
- 00:09:28that the system is is always operational
- 00:09:30and responsive to requests regardless of
- 00:09:33what might be happening behind the
- 00:09:34scenes like a reliable online store no
- 00:09:37matter when you visit it's always open
- 00:09:40and ready to take your order and
- 00:09:42partition tolerance refers to the
- 00:09:44system's ability to continue functioning
- 00:09:47even when a network partition occur
- 00:09:49meaning if there is a disruption in
- 00:09:51communication between nodes the system
- 00:09:53still works it's like having a group
- 00:09:55chat where even if one person loses
- 00:09:57connection the rest of the group can
- 00:09:59continue chatting and according to cap
- 00:10:02theorem a distributed system can only
- 00:10:04achieve two out of these three
- 00:10:05properties at the same time if you
- 00:10:08prioritize consistency and partition
- 00:10:10tolerance you might have to compromise
- 00:10:12on availability and vice versa for
- 00:10:15example a banking system needs to be
- 00:10:17consistent and partition tolerant to
- 00:10:19ensure Financial accuracy even if it
- 00:10:22means some transactions take longer to
- 00:10:24process temporarily compromising
- 00:10:27availability so every design DEC
- 00:10:29decision comes with tradeoffs for
- 00:10:31example a system optimized for read
- 00:10:33operations might perform poorly on write
- 00:10:35operations or in order to gain
- 00:10:38performance we might have to sacrifice a
- 00:10:40bit of complexity so it's not about
- 00:10:42finding the perfect solution it's about
- 00:10:44finding the best solution for our
- 00:10:46specific use case and that means making
- 00:10:48informed decision about where we can
- 00:10:51afford to compromise so one important
- 00:10:53measurement of system is availability
- 00:10:56this is the measure of systems
- 00:10:58operational performance and
- 00:11:00reliability when we talk about
- 00:11:02availability we are essentially asking
- 00:11:04is our system up and running when our
- 00:11:06users need it this is often measured in
- 00:11:09terms of percentage aiming for that
- 00:11:11golden 5 9's availability let's say we
- 00:11:14are running a critical service with 99.9
- 00:11:17availability that allows for around 8.76
- 00:11:21hours of downtime per year but if we add
- 00:11:24two NES to it we are talking just about
- 00:11:275 minutes of downtime per year and
- 00:11:29that's a massive difference especially
- 00:11:31for services where every second counts
- 00:11:34we often measure it in terms of uptime
- 00:11:36and downtime and here is where service
- 00:11:38level objectives and service level
- 00:11:40agreements come into place slos are like
- 00:11:43setting goals for our systems
- 00:11:45performance and availability for example
- 00:11:48we might set an SLO stating that our web
- 00:11:50service should respond to request within
- 00:11:52300 milliseconds and
- 00:11:5499.9% of the time slas on the other hand
- 00:11:58are like for formal contracts with our
- 00:12:00users or customers they Define the
- 00:12:02minimum level of service we are
- 00:12:04committing to provide so if our SLA
- 00:12:07guarantees 99.99 availability and we
- 00:12:10drop below that we might have to provide
- 00:12:12refunds or other compensations to our
- 00:12:15customers building resilence into our
- 00:12:18system means expecting the unexpected
- 00:12:20this could mean implementing redundant
- 00:12:22systems ensuring there is always a
- 00:12:24backup ready to take over in case of
- 00:12:26failure or it could mean designing our
- 00:12:29system to degrade gracefully so even if
- 00:12:32certain features are unavailable the
- 00:12:34core functionality remains intact to
- 00:12:36measure this aspect we used reliability
- 00:12:39fault tolerance and
- 00:12:41redundancy reliability means ensuring
- 00:12:44that our system works correctly and
- 00:12:46consistently fa tolerance is about
- 00:12:48preparing for when things go wrong how
- 00:12:51does our system handle unexpected
- 00:12:53failures or attacks and redundancy is
- 00:12:56about having backups ensuring that if
- 00:12:58one part of our system fails there is
- 00:13:00another ready to take its place we also
- 00:13:03need to measure the speed of our system
- 00:13:05and for that we have throughput and
- 00:13:07latency throughput measures how much
- 00:13:10data our system can handle over a
- 00:13:12certain period of time we have server
- 00:13:14throughput which is measured in requests
- 00:13:16per second this metric provides an
- 00:13:19indication of how many client requests a
- 00:13:21server can handle in a given time frame
- 00:13:24a higher RPS value typically indicates
- 00:13:27better performance and the ability to
- 00:13:29handle more concurrent users we have
- 00:13:31database throughput which is measured in
- 00:13:34queries per second this quantifies the
- 00:13:36number of queries a database can process
- 00:13:39in a second like server throughput a
- 00:13:41higher QPS value usually signifies
- 00:13:44better
- 00:13:45performance and we also have data
- 00:13:47throughput which is measured in bytes
- 00:13:49per second this reflects the amount of
- 00:13:51data transferred over a network or
- 00:13:54processed by a system in a given period
- 00:13:56of time on the other hand latency
- 00:13:59measures how long it takes to handle a
- 00:14:00single request it's the time it takes
- 00:14:03for a request to get a response and
- 00:14:05optimizing for one can often lead to
- 00:14:08sacrifices in the other for example
- 00:14:10batching operations can increase
- 00:14:12throughput but might also increase
- 00:14:14latency and designing a system poly can
- 00:14:17lead to a lot of issues down the line
- 00:14:19from performance bottlenecks to security
- 00:14:22vulnerabilities and unlike code which
- 00:14:24can be refactored easily redesigning A
- 00:14:26system can be a Monumental task that's
- 00:14:29why it's crucial to invest time and
- 00:14:31resources into getting the design right
- 00:14:33from the start and laying a solid
- 00:14:35foundation that can support the weight
- 00:14:37of future features and user growth now
- 00:14:40let's talk about networking Basics when
- 00:14:42we talk about networking Basics we are
- 00:14:44essentially discussing how computers
- 00:14:46communicate with each other at the heart
- 00:14:49of this communication is the IP address
- 00:14:51a unique identifier for each device on a
- 00:14:54network IP V4 addresses are 32bit which
- 00:14:57allows for approximately 4 billion
- 00:14:59unique addresses however with the
- 00:15:02increasing number of devices we are
- 00:15:04moving to IP V6 which uses 128bit
- 00:15:07addresses significantly increasing the
- 00:15:09number of available unique addresses
- 00:15:12when two computers communicate over a
- 00:15:14network they send and receive packets of
- 00:15:16data and each packet contains an IP
- 00:15:19header which contains essential
- 00:15:21information like the senders and
- 00:15:23receivers IP addresses ensuring that the
- 00:15:25data reaches the correct destination
- 00:15:28this process is governed by the Internet
- 00:15:30Protocol which is a set of rules that
- 00:15:32defines how data is sent and received
- 00:15:35besides the IP layer we also have the
- 00:15:38application layer where data specific to
- 00:15:40the application protocol is stored the
- 00:15:43data in these packets is formatted
- 00:15:45according to specific application
- 00:15:47protocol data like HTTP for web browsing
- 00:15:50so that the data is interpreted
- 00:15:52correctly by the receiving device once
- 00:15:55we understand the basics of Ip
- 00:15:57addressing and data packets we can dive
- 00:15:59into transport layer where TCP and UDP
- 00:16:02come into play TCP operates at the
- 00:16:05transport layer and ensures reliable
- 00:16:08communication it's like a delivery guy
- 00:16:10who makes sure that your package not
- 00:16:12only arrives but also checks that
- 00:16:14nothing is missing so each data packet
- 00:16:16also includes a TCP header which is
- 00:16:19carrying essential information like port
- 00:16:21numbers and control flux necessary for
- 00:16:24managing the connection and data flow
- 00:16:26TCP is known for its reliability it
- 00:16:29ensures the complete and correct
- 00:16:31delivery of data packets it accomplishes
- 00:16:34this through features like sequence
- 00:16:35numbers which keep track of the order of
- 00:16:38packets and the process known as the
- 00:16:40freeway handshake which establishes a
- 00:16:42stable connection between two devices in
- 00:16:45contrast UDP is faster but less reliable
- 00:16:48than TCP it doesn't establish a
- 00:16:51connection before sending data and
- 00:16:53doesn't guarantee the delivery or order
- 00:16:55of the packets but this makes UDP
- 00:16:58preferable for time sensitive
- 00:17:00Communications like video calls or live
- 00:17:02streaming where speed is crucial and
- 00:17:05some data loss is acceptable to tie all
- 00:17:08these Concepts together let's talk about
- 00:17:10DNS domain name system DNS acts like the
- 00:17:13internet form book translating human
- 00:17:16friendly domain names into IP addresses
- 00:17:19when you enter a URL in your browser the
- 00:17:21browser sends a DNS query to find the
- 00:17:24corresponding IP address allowing it to
- 00:17:26establish a connection to the server and
- 00:17:28and retrieve the web page the
- 00:17:30functioning of DNS is overseen by I can
- 00:17:33which coordinates the global IP address
- 00:17:35space and domain name system and domain
- 00:17:39name registers like name chip or gold Ed
- 00:17:41are accredited by I can to sell domain
- 00:17:44names to the public DNS uses different
- 00:17:47types of Records like a records which
- 00:17:49map The Domain to its corresponding IP
- 00:17:52address ensuring that your request
- 00:17:54reaches to the correct server or 4 a
- 00:17:57records which map a domain name name to
- 00:17:59an IP V6 address and finally let's talk
- 00:18:03about the networking infrastructure
- 00:18:05which supports all these communication
- 00:18:07devices on a network have either public
- 00:18:10or private IP addresses public IP
- 00:18:13addresses are unique across the internet
- 00:18:15while private IP addresses are unique
- 00:18:17within a local network an IP address can
- 00:18:20be stated permanently assigned to a
- 00:18:23device or dynamic changing over time
- 00:18:25Dynamic IP addresses are commonly used
- 00:18:28for res idential internet connections
- 00:18:30and devices connected in a local area
- 00:18:33network can communicate with each other
- 00:18:36directly and to protect these networks
- 00:18:38we are using firewalls which are
- 00:18:40monitoring and controlling incoming and
- 00:18:42outgoing Network traffic and within a
- 00:18:46device specific processes or services
- 00:18:48are identified by ports which when
- 00:18:50combined with an IP address create a
- 00:18:52unique identifier for a network service
- 00:18:56some ports are reserved for specific
- 00:18:58protocols like 80 for HTTP or 22 for
- 00:19:02SSH now let's cover all the essential
- 00:19:05application layer protocols the most
- 00:19:07common protocol out of this is HTTP
- 00:19:09which stands for hyper text transfer
- 00:19:11protocol which is built on TCP IP it's a
- 00:19:14request response protocol but imagine it
- 00:19:17as a conversation with no memory each
- 00:19:19interaction is separate with no
- 00:19:21recollection of the past this means that
- 00:19:24the server doesn't have to store any
- 00:19:25context between requests instead each
- 00:19:28request contains all the necessary
- 00:19:30information and notice how the headers
- 00:19:33include details like URL and Method
- 00:19:35while body carries the substance of the
- 00:19:37request or response each response also
- 00:19:40includes the status code which is just
- 00:19:42to provide feedback about the result of
- 00:19:44a client's request on a server for
- 00:19:47instance 200 series are success codes
- 00:19:50these indicate that the request was
- 00:19:51successfully received and processed 300
- 00:19:55series are redirection codes this
- 00:19:57signify that further action needs to be
- 00:20:00taken by the user agent in order to
- 00:20:02fulfill the request 400 series are
- 00:20:06client error codes these are used when
- 00:20:08the request contains bad syntax or
- 00:20:10cannot be fulfilled and 500 series are
- 00:20:13server error codes this indicates that
- 00:20:15something went wrong on the server we
- 00:20:18also have a method on each request the
- 00:20:21most common methods are get post put
- 00:20:23patch and delete get is used for
- 00:20:25fetching data post is usually for
- 00:20:27creating a data on server puted patch
- 00:20:30are for updating a record and delete is
- 00:20:33for removing a record from database HTTP
- 00:20:36is oneway connection but for realtime
- 00:20:39updates we use web sockets that provide
- 00:20:41a two-way Communication channel over a
- 00:20:43single long lift connection allowing
- 00:20:46servers to push real-time updates to
- 00:20:48clients this is very important for
- 00:20:50applications requiring constant data
- 00:20:52updates without the overhead of repeated
- 00:20:55HTTP request response Cycles it is
- 00:20:58commonly used for chat applications live
- 00:21:00sport updates or stock market feeds
- 00:21:03where the action never stops and neither
- 00:21:05does the
- 00:21:06conversation from email related
- 00:21:08protocols SMTP is the standard for email
- 00:21:11transmission over the Internet it is the
- 00:21:14protocol for sending email messages
- 00:21:16between servers most email clients use
- 00:21:19SMTP for sending emails and either IMAP
- 00:21:22or pop free for retrieving them imup is
- 00:21:25used to retrieve emails from a server
- 00:21:27allowing a client to access and
- 00:21:29manipulate messages this is ideal for
- 00:21:31users who need to access their emails
- 00:21:33from multiple
- 00:21:35devices pop free is used for downloading
- 00:21:37emails from a server to a local client
- 00:21:40typically used when emails are managed
- 00:21:42from a single device moving on to file
- 00:21:45transfer and management protocols the
- 00:21:47traditional protocol for transferring
- 00:21:49files over the Internet is FTP which is
- 00:21:53often used in Website Maintenance and
- 00:21:55large data transfers it is used for the
- 00:21:58trans of files between a client and
- 00:22:00server useful for uploading files to
- 00:22:02server or backing up files and we also
- 00:22:05have SSH or secure shell which is for
- 00:22:08operating Network Services securely on
- 00:22:10an unsecured Network it's commonly used
- 00:22:13for logging into a remote machine and
- 00:22:15executing commands or transferring files
- 00:22:19there are also real-time communication
- 00:22:21protocols like web RTC which enables
- 00:22:24browser to browser applications for
- 00:22:26voice calling video chat and file Shar
- 00:22:28sharing without internal or external
- 00:22:30plugins this is essential for
- 00:22:32applications like video conferencing and
- 00:22:35live
- 00:22:36streaming another one is mqtt which is a
- 00:22:39lightweight messaging protocol ideal for
- 00:22:41devices with limited processing power
- 00:22:43and in scenarios requiring low bandwidth
- 00:22:46such as iot devices and amqp is a
- 00:22:50protocol for message oriented middleware
- 00:22:52providing robustness and security for
- 00:22:55Enterprise level message communication
- 00:22:57for example it is used in tools like
- 00:22:59rabbit mq let's also talk about RPC
- 00:23:03which is a protocol that allows a
- 00:23:04program on one computer to execute code
- 00:23:07on a server or another computer it's a
- 00:23:10method used to invoke a function as if
- 00:23:12it were a local call when in reality the
- 00:23:15function is executed on a remote machine
- 00:23:18so it abstracts the details of the
- 00:23:20network communication allowing the
- 00:23:22developer to interact with remote
- 00:23:24functions seamlessly as if they were
- 00:23:26local to the application and many
- 00:23:28application player protocols use RPC
- 00:23:31mechanisms to perform their operations
- 00:23:33for example in web services HTTP
- 00:23:36requests can result in RPC calls being
- 00:23:38made on backend to process data or
- 00:23:41perform actions on behalf of the client
- 00:23:43or SMTP servers might use RPC calls
- 00:23:46internally to process email messages or
- 00:23:49interact with
- 00:23:51databases of course there are numerous
- 00:23:53other application layer protocols but
- 00:23:55devance covered here are among the most
- 00:23:57commonly used Bo and essential for web
- 00:24:00development in this section let's go
- 00:24:02through the API design starting from the
- 00:24:04basics and advancing towards the best
- 00:24:06practices that Define exceptional apis
- 00:24:09let's consider an API for an e-commerce
- 00:24:11platform like Shopify which if you're
- 00:24:13not familiar with is a well-known
- 00:24:15e-commerce platform that allows
- 00:24:17businesses to set up online stores in
- 00:24:19API design we are concerned with
- 00:24:21defining the inputs like product details
- 00:24:24for a new product which is provided by a
- 00:24:26seller and the output like the
- 00:24:29information returned when someone
- 00:24:30queries a product of an API so the focus
- 00:24:33is mainly on defining how the crow
- 00:24:35operations are exposed to the user
- 00:24:38interface CR stands for create read
- 00:24:40update and delete which are basic
- 00:24:43operations of any data driven
- 00:24:45application for example to add a new
- 00:24:47product we need to send a post request
- 00:24:49to/ API products where the product
- 00:24:53details are sent in the request body to
- 00:24:55retrieve these products we need to send
- 00:24:57the get request requ EST to/ API SL
- 00:25:00products for updating we use put or
- 00:25:02patch requests to/ product/ the ID of
- 00:25:06that product and removing is similar to
- 00:25:09updating it's again/ product/ ID of the
- 00:25:12product we need to remove and similarly
- 00:25:15we might also have another get request
- 00:25:17to/ product/ ID which fetches the single
- 00:25:20product another part is to decide on the
- 00:25:23communication protocol that will be used
- 00:25:25like HTTP websockets or other protocols
- 00:25:29and the data transport mechanism which
- 00:25:31can be Json XML or protocol buffers this
- 00:25:35is usually the case for restful apis but
- 00:25:38we also have graphql and grpc paradigms
- 00:25:41so apis come in different paradigms each
- 00:25:44with its own set of protocols and
- 00:25:46standards the most common one is rest
- 00:25:49which stands for representational State
- 00:25:51transfer it is stateless which means
- 00:25:53that each request from a client to a
- 00:25:55server must contain all the information
- 00:25:57needed to understand and complete the
- 00:26:00request it uses standard HTTP methods
- 00:26:03get post put and delete and it's easily
- 00:26:07consumable by different clients browsers
- 00:26:09or mobile apps the downside of restful
- 00:26:12apis is that they can lead to over
- 00:26:14fetching or under fetching of data
- 00:26:17because more endpoints may be required
- 00:26:18to access specific data and usually
- 00:26:21restful apis use Json for data exchange
- 00:26:25on the other hand graphql apis allow
- 00:26:27clients to request exactly what they
- 00:26:29need avoiding over fetching and under
- 00:26:31fetching data they have strongly typed
- 00:26:35queries but complex queries can impact
- 00:26:37server performance and all the requests
- 00:26:40are sent as post requests and graphql
- 00:26:43API typically responds with HTTP 200
- 00:26:46status code even in case of errors with
- 00:26:49error details in the response body grpc
- 00:26:52stands for Google remote procedure call
- 00:26:55which is built on http2 which provides
- 00:26:57advanced featur features like
- 00:26:58multiplexing and server push it uses
- 00:27:02protocol buffers which is a way of
- 00:27:03serializing structured data and because
- 00:27:07of that it's sufficient in terms of
- 00:27:08bandwidth and resources especially
- 00:27:10suitable for
- 00:27:12microservices the downside is that it's
- 00:27:14less human readable compared to Json and
- 00:27:17it requires http2 support to operate in
- 00:27:21an e-commerce setting you might have
- 00:27:23relationships like user to orders or
- 00:27:25orders to products and you need to
- 00:27:28design endpoints to reflect these
- 00:27:29relationships for example to fetch the
- 00:27:32orders for a specific user you need to
- 00:27:34query to get/ users SL the user id/
- 00:27:38orders common queries also include limit
- 00:27:41and offset for pagination or start and
- 00:27:44end date for filtering products within a
- 00:27:46certain date range this allows users or
- 00:27:49the client to retrieve specific sets of
- 00:27:51data without overwhelming the system a
- 00:27:55well-designed get request should be itm
- 00:27:57ponent meaning calling it multiple times
- 00:27:59doesn't change the result and it should
- 00:28:01always return the same result and get
- 00:28:04requests should never mutate data they
- 00:28:06are meant only for retrieval if you need
- 00:28:09to update or create a data you need to
- 00:28:11do a put or post request when modifying
- 00:28:14end points it's important to maintain
- 00:28:16backward compatibility this means that
- 00:28:19we need to ensure that changes don't
- 00:28:21break existing clients a common practice
- 00:28:24is to introduce new versions like
- 00:28:26version two products so that the version
- 00:28:29one API can still serve the old clients
- 00:28:32and version 2 API should serve the
- 00:28:33current clients this is in case of
- 00:28:36restful apis in the case of graph Co
- 00:28:39apis adding new Fields like V2 Fields
- 00:28:42without removing old one helps in
- 00:28:44evolving the API without breaking
- 00:28:46existing clients another best practice
- 00:28:49is to set rate limitations this can
- 00:28:52prevent the API from Theos attacks it is
- 00:28:55used to control the number of requests a
- 00:28:57user can make in certain time frame and
- 00:29:00it prevents a single user from sending
- 00:29:02too many requests to your single API a
- 00:29:05common practice is to also set course
- 00:29:08settings which stands for cross origin
- 00:29:10resource sharing with course settings
- 00:29:13you can control which domains can access
- 00:29:15to your API preventing unwanted
- 00:29:17cross-site interactions now imagine a
- 00:29:20company is hosting a website on a server
- 00:29:22in Google cloud data centers in Finland
- 00:29:25it may take around 100 milliseconds to
- 00:29:27load for users in Europe but it takes 3
- 00:29:30to 5 Seconds to load for users in Mexico
- 00:29:33fortunately there are strategies to
- 00:29:35minimize this request latency for users
- 00:29:37who are far away these strategies are
- 00:29:39called caching and content delivery
- 00:29:41networks which are two important
- 00:29:43Concepts in modern web development and
- 00:29:45system design caching is a technique
- 00:29:48used to improve the performance and
- 00:29:50efficiency of a system it involves
- 00:29:52storing a copy of certain data in a
- 00:29:54temporary storage so that future
- 00:29:56requests for that data can be served
- 00:29:58faster there are four common places
- 00:30:01where cash can be stored the first one
- 00:30:03is browser caching where we store
- 00:30:05website resources on a user's local
- 00:30:07computer so when a user revisits a site
- 00:30:10the browser can load the site from the
- 00:30:12local cache rather than fetching
- 00:30:14everything from the server again users
- 00:30:16can disable caching by adjusting the
- 00:30:19browser settings in most browsers
- 00:30:21developers can disable cach from the
- 00:30:23developer tools for instance in Chrome
- 00:30:25we have the disable cache option in the
- 00:30:27dev Vel opers tools Network tab the cach
- 00:30:30is stored in a directory on the client's
- 00:30:32hard drive managed by the browser and
- 00:30:35browser caches store HTML CSS and JS
- 00:30:38bundle files on the user's local machine
- 00:30:40typically in a dedicated cache directory
- 00:30:43managed by the browser we use the cache
- 00:30:46control header to tell browser how long
- 00:30:48this content should be cached for
- 00:30:50example here the cache control is set to
- 00:30:537,200 seconds which is equivalent to 2
- 00:30:56hours when the re ested data is found in
- 00:30:59the cache we call that a cash hit and on
- 00:31:01the other hand we have cash Miss which
- 00:31:03happens when the requested data is not
- 00:31:05in the cash necessitating a fetch from
- 00:31:07the original source and cash ratio is
- 00:31:10the percentage of requests that are
- 00:31:12served from the cach compared to all
- 00:31:14requests and the higher ratio indicates
- 00:31:16a more effective cach you can check if
- 00:31:18the cash fall hit or missed from the
- 00:31:20xcash header for example in this case it
- 00:31:23says Miss so the cash was missed and in
- 00:31:26case the cash is found we will have here
- 00:31:27it here we also have server caching
- 00:31:30which involves storing frequently
- 00:31:32accessed data on the server site
- 00:31:34reducing the need to perform expensive
- 00:31:36operations like database queries serers
- 00:31:39side caches are stored on a server or on
- 00:31:41a separate cache server either in memory
- 00:31:44like redis or on disk typically the
- 00:31:47server checks the cache from the data
- 00:31:49before quering the database if the data
- 00:31:51is in the cach it is returned directly
- 00:31:53otherwise the server queries the
- 00:31:56database and if the data is not in the
- 00:31:58cache the server retrieves it from the
- 00:32:00database returns it to the user and then
- 00:32:03stores it in the cache for future
- 00:32:05requests this is the case of right
- 00:32:07around cache where data is written
- 00:32:09directly to permanent storage byp
- 00:32:11passing the cache it is used when right
- 00:32:14performance is less critical you also
- 00:32:16have write through cache where data is
- 00:32:18simultaneously written to cache and the
- 00:32:21permanent storage it ensures data
- 00:32:23consistency but can be slower than right
- 00:32:25round cache and we also have right back
- 00:32:28cach where data is first written to the
- 00:32:30cache and then to permanent storage at a
- 00:32:32later time this improves right
- 00:32:34performance but you have a risk of
- 00:32:36losing that data in case of a crush of
- 00:32:39server but what happens if the cash is
- 00:32:41full and we need to free up some space
- 00:32:43to use our cash again for that we have
- 00:32:46eviction policies which are rules that
- 00:32:48determine which items to remove from the
- 00:32:50cash when it's full common policies are
- 00:32:53to remove least recently used ones or
- 00:32:56first in first out where we remove the
- 00:32:58ones that were added first or removing
- 00:33:00the least frequently used ones database
- 00:33:03caching is another crucial aspect and it
- 00:33:05refers to the practice of caching
- 00:33:07database query results to improve the
- 00:33:09performance of database driven
- 00:33:11applications it is often done either
- 00:33:14within the database system itself or via
- 00:33:16an external caching layer like redies or
- 00:33:19M cache when a query is made we first
- 00:33:21check the cache to see if the result of
- 00:33:24that query has been stored if it is we
- 00:33:26return the cach state avoiding the need
- 00:33:28to execute the query against the
- 00:33:30database but if the data is not found in
- 00:33:33the cache the query is executed against
- 00:33:35the database and the result is stored in
- 00:33:37the cache for future requests this is
- 00:33:40beneficial for read heavy applications
- 00:33:42where some queries are executed
- 00:33:45frequently and we use the same eviction
- 00:33:47policies as we have for server side
- 00:33:49caching another type of caching is CDN
- 00:33:52which are a network of servers
- 00:33:54distributed geographically they are
- 00:33:56generally used to serf static content
- 00:33:58such as JavaScript HTML CSS or image and
- 00:34:01video files they cat the content from
- 00:34:04the original server and deliver it to
- 00:34:06users from the nearest CDN server when a
- 00:34:09user requests a file like an image or a
- 00:34:11website the request is redirected to the
- 00:34:14nearest CDN server if the CDN server has
- 00:34:17the cached content it delivers it to the
- 00:34:19user if not it fetches the content from
- 00:34:22the origin server caches it and then
- 00:34:24forwards it to the user this is the pool
- 00:34:27based type type of CDN where the CDN
- 00:34:29automatically pulls the content from the
- 00:34:31origin server when it's first requested
- 00:34:33by a user it's ideal for websites with a
- 00:34:36lot of static content that is updated
- 00:34:38regularly it requires less active
- 00:34:41management because the CDN automatically
- 00:34:43keeps the content up to date another
- 00:34:46type is push based CDs this is where you
- 00:34:48upload the content to the origin server
- 00:34:51and then it distributes these files to
- 00:34:52the CDN this is useful when you have
- 00:34:55large files that are infrequently
- 00:34:57updated but need to be quickly
- 00:34:58distributed when updated it requires
- 00:35:01more active management of what content
- 00:35:03is stored on the edn we again use the
- 00:35:06cache control header to tell the browser
- 00:35:08for how long it should cach the content
- 00:35:10from CDN CDN are usually used for
- 00:35:13delivering static assets like images CSS
- 00:35:16files JavaScript bundles or video
- 00:35:18content and it can be useful if you need
- 00:35:21to ensure High availability and
- 00:35:22performance for users it can also reduce
- 00:35:25the load on the origin server but there
- 00:35:28are some instances where we still need
- 00:35:29to hit our origin server for example
- 00:35:32when serving Dynamic content that
- 00:35:34changes frequently or handling tasks
- 00:35:37that require real-time processing and in
- 00:35:39cases where the application requires
- 00:35:41complex server side logic that cannot be
- 00:35:44done in the CDN some of the benefits
- 00:35:46that we get from CDN are reduced latency
- 00:35:50by serving content from locations closer
- 00:35:52to the user CDN significantly reduce
- 00:35:55latency it also adds High avail ability
- 00:35:58and scalability CDN can handle high
- 00:36:01traffic loads and are resilent against
- 00:36:03Hardware failures it also adds improved
- 00:36:06security because many CDN offer security
- 00:36:09features like DDS protection and traffic
- 00:36:11encryption and the benefits of caching
- 00:36:14are also reduced latency because we have
- 00:36:16fast data retrieval since the data is
- 00:36:18fetched from the nearby cache rather
- 00:36:20than a remote server it lowers the
- 00:36:23server load by reducing the number of
- 00:36:25requests to the primary data source
- 00:36:27decreasing server load and overall
- 00:36:30faster load times lead to a better user
- 00:36:32experience now let's talk about proxy
- 00:36:35servers which act as an intermediary
- 00:36:37between a client requesting a resource
- 00:36:39and the server providing that resource
- 00:36:42it can serve various purposes like
- 00:36:44caching resources for faster access
- 00:36:46anonymizing requests and load balancing
- 00:36:49among multiple servers essentially it
- 00:36:51receives requests from clients forwards
- 00:36:53them to the relevant servers and then
- 00:36:56Returns the servers respond back to the
- 00:36:58client there are several types of proxy
- 00:37:00servers each serving different purposes
- 00:37:03here are some of the main types the
- 00:37:05first one is forward proxy which sits in
- 00:37:08front of clients and is used to send
- 00:37:10requests to other servers on the
- 00:37:12Internet it's often used within the
- 00:37:15internal networks to control internet
- 00:37:17access next one is reverse proxy which
- 00:37:20sits in front of one or more web servers
- 00:37:22intercepting requests from the internet
- 00:37:25it is used for load balancing web
- 00:37:27acceleration and as a security layer
- 00:37:30another type is open proxy which allows
- 00:37:33any user to connect and utilize the
- 00:37:35proxy server often used to anonymize web
- 00:37:38browsing and bypass content restrictions
- 00:37:41we also have transparent proxy types
- 00:37:43which passes along requests and
- 00:37:45resources without modifying them but
- 00:37:47it's visible to the client and it's
- 00:37:49often used for caching and content
- 00:37:51filtering next type is anonymous proxy
- 00:37:54which is identifiable as a proxy server
- 00:37:57but but does not make the original IP
- 00:37:59address available this type is used for
- 00:38:02anonymous browsing we also have
- 00:38:04distorting proxies which provides an
- 00:38:06incorrect original Ip to the destination
- 00:38:09server this is similar to an anonymous
- 00:38:11proxy but with purposeful IP
- 00:38:14misinformation and next popular type is
- 00:38:16high anonymity proxy or Elite proxy
- 00:38:19which makes detecting the proxy use very
- 00:38:22difficult these proxies do not send X
- 00:38:24forwarded for or other identifying
- 00:38:27header and they ensure maximum anonymity
- 00:38:30the most commonly used proxy servers are
- 00:38:32forward and reverse proxies a forward
- 00:38:35proxy acts as a middle layer between the
- 00:38:37client and the server it sits between
- 00:38:40the client which can be a computer on an
- 00:38:42internal Network and the external
- 00:38:44servers which can be websites on the
- 00:38:47internet when the client makes a request
- 00:38:49it is first sent to the forward proxy
- 00:38:52the proxy then evaluates the request and
- 00:38:54decides based on its configuration and
- 00:38:57rules whether to allow the request
- 00:38:59modify it or to block it one of the
- 00:39:02primary functions of a forward proxy is
- 00:39:04to hide the client's IP address when it
- 00:39:07forwards the request to the Target
- 00:39:09server it appears as if the request is
- 00:39:12coming from the proxy server itself
- 00:39:14let's look at some example use cases of
- 00:39:17forward proxies one popular example is
- 00:39:20Instagram proxies these are a specific
- 00:39:23type of forward proxy used to manage
- 00:39:25multiple Instagram accounts without
- 00:39:27triggering bonds or restrictions and
- 00:39:30marketers and social media managers use
- 00:39:32Instagram proxies to appear as if they
- 00:39:34are located in different area or as
- 00:39:37different users which allows them to
- 00:39:39manage multiple accounts automate tasks
- 00:39:42or gather data without being flaged for
- 00:39:44suspicious activity next example is
- 00:39:47internet use control and monitoring
- 00:39:49proxies some organizations use forward
- 00:39:52proxies to Monitor and control employee
- 00:39:55internet usage they can block access to
- 00:39:57non-related sites and protect against
- 00:40:00web based threats they can also scan for
- 00:40:03viruses and malware in incoming content
- 00:40:06next common use case is caching
- 00:40:08frequently accessed content forward
- 00:40:10proxies can also cach popular websites
- 00:40:13or content reducing bandwidth usage and
- 00:40:15speeding up access for users within the
- 00:40:18network this is especially beneficial in
- 00:40:21networks where bandwidth is costly or
- 00:40:23limited and it can be also used for
- 00:40:26anonymizing web access people who are
- 00:40:28concerned about privacy can use forward
- 00:40:30proxies to hide their IP address and
- 00:40:33other identifying information from
- 00:40:35websites they Vis it and making it
- 00:40:38difficult to track their web browsing
- 00:40:40activities on the other hand the reverse
- 00:40:42proxy is a type of proxy server that
- 00:40:45sits in front of one or more web servers
- 00:40:47intercepting requests from clients
- 00:40:49before they reach the servers while a
- 00:40:52forward proxy hides the client's
- 00:40:54identity a reverse proxy essentially
- 00:40:56hides the servers Identity or the
- 00:40:58existence of multiple servers behind it
- 00:41:01the client interacts only with the
- 00:41:03reverse proxy and may not know about the
- 00:41:05servers behind it it also distributes
- 00:41:08client requests across multiple servers
- 00:41:11balancing load and ensuring no single
- 00:41:13server becomes overwhelmed reverse proxy
- 00:41:16can also compress inbound and outbound
- 00:41:19data cache files and manage SSL
- 00:41:21encryption there be speeding up load
- 00:41:23time and reducing server load some
- 00:41:26common use case cases of reverse proxies
- 00:41:28are load balancers these distribute
- 00:41:31incoming Network traffic across multiple
- 00:41:33servers ensuring no single server gets
- 00:41:36too much load and by Distributing
- 00:41:38traffic we prevent any single server
- 00:41:41from becoming a bottleneck and it's
- 00:41:43maintaining optimal service speed and
- 00:41:45reliability CDs are also a type of
- 00:41:48reverse proxies they are a network of
- 00:41:50servers that deliver cach static content
- 00:41:53from websites to users based on the
- 00:41:55geographical location of the user they
- 00:41:58act as Reverse proxies by retrieving
- 00:42:00content from the origin server and
- 00:42:02caching it so that it's closer to the
- 00:42:04user for faster delivery another example
- 00:42:07is web application firewalls which are
- 00:42:10positioned in front of web applications
- 00:42:13they inspect incoming traffic to block
- 00:42:15hacking attempts and filter out unwanted
- 00:42:17traffic firewalls also protect the
- 00:42:20application from common web exploits and
- 00:42:22another example is SSL off loading or
- 00:42:25acceleration some reverse proxies handle
- 00:42:28the encryption and decryption of SSL TLS
- 00:42:31traffic offloading that task from web
- 00:42:33servers to optimize their performance
- 00:42:36load balancers are perhaps the most
- 00:42:38popular use cases of proxy servers they
- 00:42:41distribute incoming traffic across
- 00:42:43multiple servers to make sure that no
- 00:42:45server Bears Too Much load by spreading
- 00:42:48the requests effectively they increase
- 00:42:49the capacity and reliability of
- 00:42:52applications here are some common
- 00:42:54strategies and algorithms used in load
- 00:42:56balancing
- 00:42:57first one is round robin which is the
- 00:42:59simplest form of load balancing where
- 00:43:02each server in the pool gets a request
- 00:43:04in sequential rotating order when the
- 00:43:06last server is reached it Loops back to
- 00:43:08the first one this type works well for
- 00:43:11servers with similar specifications and
- 00:43:14when the load is uniformly
- 00:43:16distributable next one is list
- 00:43:18connections algorithm which directs
- 00:43:20traffic to the server with the fewest
- 00:43:22active connections it's ideal for longer
- 00:43:25tasks or when the server load is not
- 00:43:27evenly distributed next we have the
- 00:43:30least response time algorithm which
- 00:43:32chooses the server with the lowest
- 00:43:34response time and fewest active
- 00:43:36connections this is effective and the
- 00:43:38goal is to provide the fastest response
- 00:43:40to requests next algorithm is IP hashing
- 00:43:44which determines which server receives
- 00:43:46the request based on the hash of the
- 00:43:48client's IP address this ensures a
- 00:43:51client consistently connects to the same
- 00:43:53server and it's useful for session
- 00:43:55persistence in application where it's
- 00:43:57important that the client consistently
- 00:43:59connects to the same server the variance
- 00:44:02of these methods can also be vited which
- 00:44:04brings us to the weighted algorithms for
- 00:44:07example in weighted round robin or
- 00:44:09weighted list connections servers are
- 00:44:11assigned weights typically based on
- 00:44:13their capacity or performance metrics
- 00:44:16and the servers which are more capable
- 00:44:18handle the most requests this is
- 00:44:20effective when the servers in the pool
- 00:44:22have different capabilities like
- 00:44:24different CPU or different Rams we also
- 00:44:27have geographical algorithms which
- 00:44:30direct requests to the server
- 00:44:32geographically closest to the user or
- 00:44:34based on specific Regional requirements
- 00:44:37this is useful for Global Services where
- 00:44:39latency reduction is priority and the
- 00:44:42next common algorithm is consistent
- 00:44:44hashing which uses a hash function to
- 00:44:47distribute data across various nodes
- 00:44:49imagine a hash space that forms a circle
- 00:44:52where the end wraps around to the
- 00:44:54beginning often referred to as a has
- 00:44:56ring and both the nodes and the data
- 00:44:59like keys or stored values are hushed
- 00:45:01onto this ring this makes sure that the
- 00:45:04client consistently connects to the same
- 00:45:06server every time an essential feature
- 00:45:09of load balancers is continuous Health
- 00:45:11checking of servers to ensure traffic is
- 00:45:14only directed to servers that are online
- 00:45:16and responsive if a server fails the
- 00:45:19load balancer will stop sending traffic
- 00:45:22to it until it is back online and load
- 00:45:25balancers can be in different forms
- 00:45:27including Hardware applications software
- 00:45:30Solutions and cloud-based Services some
- 00:45:33of the popular Hardware load balancers
- 00:45:35are F5 big IP which is a widely used
- 00:45:38Hardware load balancer known for its
- 00:45:40high performance and extensive feature
- 00:45:42set it offers local traffic management
- 00:45:45Global server load balancing and
- 00:45:48application security another example is
- 00:45:51Citrix forly known as net scaler which
- 00:45:54provides load balancing content
- 00:45:55switching and ation acceleration some
- 00:45:58popular software load balancers are AJ
- 00:46:01proxy which is a popular open-source
- 00:46:03software load balancer and proxy server
- 00:46:06for TCP and HTTP based applications and
- 00:46:10of course Eng X which is often used as a
- 00:46:12web server but it also functions as a
- 00:46:15load balancer and reverse proxy for HTTP
- 00:46:18and other network protocols and some
- 00:46:20popular cloud-based load balancers are
- 00:46:23aws's elastic load balancing or microsof
- 00:46:27oft aure load balancer or Google Cloud's
- 00:46:30load balancer there are even some
- 00:46:32virtual load balancers like Vim ver
- 00:46:35Advanced load balancer which offers a
- 00:46:37softwar defined application delivery
- 00:46:39controller that can be deployed on
- 00:46:41premises or in the cloud now let's see
- 00:46:44what happens when a load balancer goes
- 00:46:47down when the load balancer goes down it
- 00:46:49can impact the whole availability and
- 00:46:52performance of the application or
- 00:46:54Services it manages it's basically a
- 00:46:57single point of failure and in case it
- 00:46:59goes down all of the servers become
- 00:47:01unavailable for the clients to avoid or
- 00:47:04minimize the impact of a load balancer
- 00:47:06failure we have several strategies which
- 00:47:09can be employed first one is
- 00:47:10implementing a redundant load balancing
- 00:47:13by using more than one load balancer
- 00:47:15often in pairs which is a common
- 00:47:18approach if one of them fails the other
- 00:47:20one takes over which is a method known
- 00:47:22as a
- 00:47:23failover next strategy is to
- 00:47:25continuously monitor and do health
- 00:47:27checks of load balancer itself this can
- 00:47:30ensure that any issues are detected
- 00:47:32early and can be addressed before
- 00:47:35causing significant disruption we can
- 00:47:37also Implement Autos scaling and
- 00:47:39selfhealing systems some Modern
- 00:47:42infrastructures are designed to
- 00:47:43automatically detect the failure of load
- 00:47:45balancer and replace it with the new
- 00:47:47instance without manual intervention and
- 00:47:51in some configurations the NS failover
- 00:47:53can reroute traffic away from an IP
- 00:47:56address that is is no longer accepting
- 00:47:58connections like a failed load balancer
- 00:48:01to a preconfigured standby IP which is
- 00:48:03our new load balancer system design
- 00:48:06interviews are incomplete without a deep
- 00:48:08dive into databases in the next few
- 00:48:10minutes I'll take you through the
- 00:48:12database Essentials you need to
- 00:48:14understand to a that interview we'll
- 00:48:16explore the role of databases in system
- 00:48:18design sharding and replication
- 00:48:20techniques and the key ACD properties
- 00:48:24we'll also discuss different types of
- 00:48:25databases vertical and horizontal
- 00:48:28scaling options and database performance
- 00:48:30techniques we have different types of
- 00:48:32databases each designed for specific
- 00:48:35tasks and challenges let's explore them
- 00:48:38first type is relational databases think
- 00:48:41of a relational database like a well
- 00:48:43organized filling cabinet where all the
- 00:48:45files are neatly sorted into different
- 00:48:47drawers and folders some popular
- 00:48:50examples of SQL databases are poster SQL
- 00:48:53MySQL and SQL light all of the SQL
- 00:48:57databases use tables for data storage
- 00:49:01and they use SQL as a query language
- 00:49:04they are great for transactions complex
- 00:49:06queries and integrity relational
- 00:49:09databases are also acid compliant
- 00:49:11meaning they maintain the ACD properties
- 00:49:14a stands for atomicity which means that
- 00:49:17transactions Are All or Nothing C stands
- 00:49:20for consistency which means that after a
- 00:49:23transaction your database should be in a
- 00:49:25consistent state I is isolation which
- 00:49:28means that transactions should be
- 00:49:30independent and D is for durability
- 00:49:33which means that once transaction is
- 00:49:34committed the data is there to stay we
- 00:49:37also have nosql databases which drop the
- 00:49:40consistency property from the ACD
- 00:49:43imagine a nosql database as a
- 00:49:45brainstorming board with sticky notes
- 00:49:47you can add or remove notes in any shape
- 00:49:50of form it's flexible some popular
- 00:49:52examples are mongod DB Cassandra and
- 00:49:55redis there are different different
- 00:49:56types of nosql databases such as key
- 00:49:59value pairs like redis document based
- 00:50:02databases like mongod DB or graph based
- 00:50:05databases like Neo 4G nosql databases
- 00:50:09are schema less meaning they don't have
- 00:50:11foreign Keys between tables which link
- 00:50:13the data together they are good for
- 00:50:16unstructured data ideal for scalability
- 00:50:19quick iteration and simple queries there
- 00:50:22are also inmemory databases this is like
- 00:50:25having a whiteboard for quick
- 00:50:27calculations and temporary sketches it's
- 00:50:30fast because everything is in memory
- 00:50:32some examples are redies and M cach they
- 00:50:35have lightning fast data retrieval and
- 00:50:37are used primarily for caching and
- 00:50:39session storage now let's see how we can
- 00:50:42scale databases the first option is
- 00:50:44vertical scaling or scale up in vertical
- 00:50:47scaling you improve the performance of
- 00:50:49your database by enhancing the
- 00:50:51capabilities of individual server where
- 00:50:54the data is running this could involve
- 00:50:56increasing CPU power adding more RAM
- 00:50:59adding faster or more dis storage or
- 00:51:01upgrading the network but there is a
- 00:51:03maximum limit to the resources you can
- 00:51:05add to a single machine and because of
- 00:51:08that it's very limited the next option
- 00:51:10is horizontal scaling or scale out which
- 00:51:13involves adding more machines to the
- 00:51:15existing pool of resources rather than
- 00:51:17upgrading the single unit databases that
- 00:51:20support horizontal scaling distribute
- 00:51:22data across a cluster of machines this
- 00:51:25could involve database sharding or data
- 00:51:27replication the first option is database
- 00:51:30sharding which is Distributing different
- 00:51:32portions shards of the data set across
- 00:51:34multiple servers this means you split
- 00:51:37the data into smaller chunks and
- 00:51:39distribute it across multiple servers
- 00:51:41some of the sharding strategies include
- 00:51:44range based sharding where you
- 00:51:46distribute data based on the range of a
- 00:51:48given key directory based sharding which
- 00:51:51is utilizing a lookup service to direct
- 00:51:53traffic to the correct database we also
- 00:51:56have geographical charting which is
- 00:51:58splitting databases based on
- 00:52:00geographical
- 00:52:01locations and the next horizontal
- 00:52:03scaling option is data replication this
- 00:52:06is keeping copies of data on multiple
- 00:52:08servers for high availability we have
- 00:52:11Master Slave replication which is where
- 00:52:14you have one master database and several
- 00:52:16read only slave databases or you can
- 00:52:19have master master application which is
- 00:52:22multiple databases that can both read
- 00:52:24and write scaling your data database is
- 00:52:27one thing but you also want to access it
- 00:52:29faster so let's talk about different
- 00:52:31performance techniques that can help to
- 00:52:33access your data faster the most obvious
- 00:52:36one is caching caching isn't just for
- 00:52:39web servers database caching can be done
- 00:52:41through inmemory databases like redies
- 00:52:44you can use it to cat frequent queries
- 00:52:46and boost your performance the next
- 00:52:48technique is indexing indexes are
- 00:52:50another way to boost the performance of
- 00:52:52your database creating an index for
- 00:52:55frequently accessed column will
- 00:52:56significantly speed up retrieval times
- 00:52:59and the next technique is query
- 00:53:01optimization you can also consider
- 00:53:03optimizing queries for fast data access
- 00:53:05this includes minimizing joints and
- 00:53:07using tools like SQL query analyzer or
- 00:53:10explain plan to understand your query's
- 00:53:13performance in all cases you should
- 00:53:15remember the cap theorem which states
- 00:53:17that you can only have two of these
- 00:53:19three consistency availability and
- 00:53:21partition tolerance when designing a
- 00:53:24system you should prioritize two of the
- 00:53:26is based on the requirements that you
- 00:53:28have given in the interview if you
- 00:53:30enjoyed this crash course then consider
- 00:53:32watching my other videos about system
- 00:53:34Design Concepts and interviews see you
- 00:53:36next time
- system design
- scalability
- high-level architecture
- load balancing
- caching
- networking
- API design
- CAP theorem
- databases
- proxy servers