TCP vs UDP – Detailed Difference (Table
Format)
Feature TCP (Transmission Control UDP (User Datagram
Protocol) Protocol)
Definition A connection-oriented protocol that A connectionless protocol
ensures reliable and ordered delivery that sends data quickly
of data. without guaranteeing delivery.
Connection Type Connection-oriented – A connection Connectionless – No
must be established before data connection is established
transfer using the Three-Way before sending data.
Handshake (SYN → SYN-ACK →
ACK).
Reliability Highly reliable. Ensures every packet Not reliable. Packets may be
reaches the destination. lost without notification.
Data Delivery Guarantees successful delivery of all Does not guarantee delivery.
packets.
Packet Ordering Delivers packets in the exact order Packets may arrive out of
they were sent. order.
Acknowledgment Receiver sends an acknowledgment No acknowledgments are
(ACK) (ACK) for each received packet. sent.
Retransmission Lost or corrupted packets are Lost packets are not
automatically retransmitted. retransmitted.
Error Checking Detects errors and recovers by Detects some errors using a
requesting retransmission. checksum but does not
recover lost packets.
Flow Control Yes. Prevents the sender from No flow control. Sender
overwhelming the receiver using a keeps transmitting regardless
sliding window. of receiver capacity.
Congestion Yes. Reduces transmission rate when No congestion control.
Control the network is congested. Continues sending packets
even during congestion.
Speed Slower due to connection setup, Faster because there is no
acknowledgments, and connection setup or
retransmissions. acknowledgments.
Latency Higher latency due to additional Lower latency, making it ideal
reliability mechanisms. for real-time applications.
Header Size 20–60 bytes (minimum 20 bytes). 8 bytes.
Overhead High overhead due to extra control Very low overhead.
information.
Bandwidth Usage Uses more bandwidth because of Uses less bandwidth since it
acknowledgments and control only sends data packets.
packets.
Communication Reliable communication. Best-effort communication.
Type
Connection Setup Takes more time because of the Starts transmitting
Time Three-Way Handshake. immediately.
Data Integrity Maintains complete data integrity. Data integrity is not
guaranteed if packets are
lost.
Suitable For Applications where every byte of data Applications where speed is
is important. more important than perfect
accuracy.
Examples of HTTP, HTTPS, FTP, SSH, SMTP, DNS, DHCP, VoIP, Online
Applications POP3, IMAP, Database connections. Gaming, Video Streaming,
Live Broadcasting.
Real-Life Example Sending an important document by Sending a live radio
registered courier that confirms broadcast where missing a
delivery and resends if necessary. few words is acceptable.
Three-Way Handshake
The TCP Three-Way Handshake is the process used to establish a reliable connection
between a client and a server before data transfer. It consists of three steps: the client
sends a SYN packet to request a connection, the server replies with a SYN-ACK to
acknowledge and accept the request, and the client sends an ACK to confirm. After
these three steps, the connection is established and data transmission begins.
SSL Termination (Simple Explanation)
What is SSL Termination?
SSL Termination is the process where SSL/TLS encryption is decrypted at a device
(such as a Load Balancer, Reverse Proxy, or Web Server) before the request is
forwarded to the backend server.
In simple words:
The client sends encrypted (HTTPS) data.
A load balancer or proxy decrypts it.
The backend server receives plain HTTP (or sometimes re-encrypted
HTTPS).
How SSL Termination Works
Step 1: Client Sends HTTPS Request
The user's browser sends an encrypted request.
[Link]
Data is encrypted using SSL/TLS.
Step 2: Load Balancer Receives Request
The load balancer has the SSL certificate.
It decrypts the request.
Encrypted Data
↓
Load Balancer
Decrypts
Step 3: Backend Receives HTTP
The backend server receives normal HTTP data.
GET /login
Username
Password
The backend doesn't need to perform SSL encryption/decryption.
Difference Between Virtualization and
Containerization (Detailed Table)
Feature Virtualization Containerization
Definition Virtualization is a technology Containerization is a
that creates multiple Virtual technology that packages an
Machines (VMs) on a single application and its
physical server. Each VM has dependencies into containers
its own operating system. that share the host operating
system's kernel.
Main To run multiple operating To run multiple applications
Purpose systems on one physical efficiently using the same
machine. operating system.
Isolation Each Virtual Machine is Containers are isolated from
completely isolated with its each other but share the host
own operating system. OS kernel.
Operating Every VM has its own Guest Containers do not have a
System Operating System. separate OS; they use the host
OS kernel.
Kernel Every VM has its own kernel. All containers share the host
operating system's kernel.
Architecture Hardware → Hypervisor → Hardware → Host OS →
Virtual Machines → Guest Container Runtime →
OS → Applications Containers → Applications
Resource Uses more CPU, RAM, and Uses fewer resources because
Usage storage because each VM containers share the host OS.
runs a full OS.
Boot Time Slow (usually takes minutes Very fast (usually seconds or
or tens of seconds) because less) because only the
an entire operating system application starts.
must boot.
Performance Slightly lower due to Better performance because
virtualization overhead. there is less overhead.
Size Large (often several GB) Small (often MBs to a few
because the VM includes a hundred MBs) because it
full operating system. contains only the application
and required libraries.
Startup Slower. Faster.
Speed
Security Strong isolation because Good isolation, but since
each VM has its own OS. containers share the kernel, a
kernel vulnerability can
potentially affect multiple
containers.
Portability Can be moved between Highly portable. Containers run
compatible hypervisors but consistently anywhere with a
VM images are large. compatible container runtime.
Operating Can run different operating Containers generally require
Systems systems simultaneously (e.g., the same kernel family as the
Supported Windows VM and Linux VM host (Linux containers use a
on the same host if supported Linux kernel; Windows
by the hypervisor). containers use a Windows
kernel).
Management More complex because each Easier to manage using
VM must be managed and container orchestration tools
updated separately. like Kubernetes.
Scalability Slower scaling because new Very fast scaling because
VMs take longer to create. containers start quickly.
Overhead High due to multiple Low because there is no
operating systems. separate OS for each container.
Failure If one VM crashes, other VMs If one container crashes, other
Impact are usually unaffected. containers usually continue
running, though they share the
same host kernel.
Best Use Running multiple operating Microservices, cloud-native
Cases systems, legacy applications, applications, DevOps, CI/CD,
and strong workload and scalable web applications.
isolation.
Examples VMware, Microsoft Hyper-V, Docker, containerd, CRI-O,
Oracle VirtualBox, KVM. Podm
Benefits of Virtualization (Detailed)
Virtualization allows multiple Virtual Machines (VMs) to run on a single physical
server. Each VM has its own operating system and applications, enabling better
utilization of hardware resources.
Benefits of Virtualization
Benefit Explanation Example
1. Better Multiple VMs share the same One server runs a web
Resource physical server, making efficient server, database server,
Utilization use of CPU, RAM, and storage and application server
instead of leaving resources idle. simultaneously.
2. Cost Savings Reduces the need to purchase Instead of buying 10
multiple physical servers, lowering servers, a company can run
hardware, electricity, cooling, and 10 VMs on 2 powerful
maintenance costs. servers.
3. Server Combines several physical servers Five old servers are
Consolidation into one physical machine with replaced by one server
multiple VMs. running five VMs.
4. Isolation Each VM is independent. If one VM A database VM crashes, but
crashes or is infected by malware, the web server VM remains
other VMs continue running available.
normally.
5. Scalability New VMs can be created quickly as During increased website
business needs grow. traffic, additional web server
VMs are created.
6. Flexibility Different operating systems can run A Linux VM and a Windows
on the same physical server. VM run on the same host.
7. Easy Backup Entire VMs can be backed up, Restore a VM from
and Recovery cloned, or restored easily. yesterday's backup after
accidental data loss.
8. Disaster VM images can be replicated to If one data center goes
Recovery another location and restarted down, VMs start in a backup
quickly if the primary server fails. data center.
9. Faster Testing Developers can quickly create, test, A developer creates a test
and and delete virtual machines without VM to try a software update
Development affecting production systems. safely.
10. High If configured, VMs can VMware HA or Hyper-V
Availability automatically restart on another Failover Cluster moves VMs
host if the current host fails. to another server.
DNS and Route53
DNS Routing
What is an IP Address? (Simple and
Detailed Explanation)
An IP Address (Internet Protocol Address) is a unique numerical address
assigned to every device connected to a network. It helps identify a device and
allows data to be sent to the correct destination.
Simple Definition:
An IP address is like the home address of a device on a network. Just
as a postal address helps deliver a letter to the correct house, an IP address
helps deliver data to the correct device.
Real-Life Example
Imagine you want to send a letter to your friend.
The letter needs:
● Sender's Address → Your home address
● Receiver's Address → Your friend's home address
Without an address, the post office wouldn't know where to deliver the letter.
Similarly, when you send data over the internet:
● Source IP Address → Sender's device
● Destination IP Address → Receiver's device
The network uses these IP addresses to deliver the data correctly.
To convert an IP address into binary (0s and 1s), convert each octet separately. An
IPv4 address has 4 octets, and each octet is represented by 8 bits.
Let's use [Link] as an example.
Step 1: Split the IP address
172 . 32 . 16 . 1
Step 2: Use the binary place values
Each octet has these place values:
12 6 3 1 8 4 2 1
8 4 2 6
If the number contains that value, write 1; otherwise write 0.
Convert 172
Start with 172.
12 6 3 1 8 4 2 1
8 4 2 6
1 0 1 0 1 1 0 0
Why?
● 172 ≥ 128 → 1 (Remaining = 44)
● 44 < 64 → 0
● 44 ≥ 32 → 1 (Remaining = 12)
● 12 < 16 → 0
● 12 ≥ 8 → 1 (Remaining = 4)
● 4 ≥ 4 → 1 (Remaining = 0)
● 0<2→0
● 0<1→0
172 = 10101100
Convert 32
12 6 3 1 8 4 2 1
8 4 2 6
0 0 1 0 0 0 0 0
32 = 00100000
Convert 16
12 6 3 1 8 4 2 1
8 4 2 6
0 0 0 1 0 0 0 0
16 = 00010000
Convert 1
12 6 3 1 8 4 2 1
8 4 2 6
0 0 0 0 0 0 0 1
1 = 00000001
Final Answer
[Link]
What is Subnetting?
Subnetting is the process of dividing one large network into smaller, manageable
networks, called subnets.
Think of it like this:
● Network = A large apartment building
● Subnet = Each floor in the building
● Devices = Apartments on each floor
Instead of everyone sharing one large network, subnetting creates smaller networks to
improve organization and efficiency.
Why do we need subnetting?
Imagine a company with 500 computers.
Without subnetting:
Network
------------------------------------
PC1 PC2 PC3 ... PC500
● Too much broadcast traffic
● Network becomes slow
● Hard to manage
● Security is lower
With subnetting:
Subnet 1 (HR)
PC1 PC2 PC3
Subnet 2 (Finance)
PC4 PC5 PC6
Subnet 3 (IT)
PC7 PC8 PC9
Each department has its own subnet.
Benefits
Benefit Explanation
Better Less broadcast traffic
performance
Better security Departments are isolated
Easier Smaller networks are easier to
management troubleshoot
Efficient IP usage IP addresses are allocated more
effectively
What is a Subnet?
A subnet (subnetwork) is a smaller network created from a larger network.
Think of a company building.
● Building = Entire Network
● Rooms/Floors = Subnets
● Employees = Devices (Computers, Servers, Printers)
Instead of everyone working in one large hall, employees are divided into different
rooms based on departments.
Example:
Large Network ([Link]/24)
Router
|
[Link]/24
|
Switch
--------------------------------
| | | | |
PC1 PC2 PC3 PC4 PC5
Now divide it into smaller networks (subnets):
Router
|
--------------------
| | |
HR Subnet IT Subnet Finance Subnet
[Link] [Link] [Link]
Each subnet is an independent network.
Why do we create subnets?
Suppose a company has 300 computers.
Without subnetting:
One Big Network
PC1 PC2 PC3 .... PC300
Problems:
● Too much broadcast traffic
● Slower network
● Difficult to manage
● Less secure
With subnetting:
HR Subnet
Finance Subnet
IT Subnet
Benefits:
● Better performance
● Better security
● Easier management
● Efficient IP address usage
Public Subnet
A public subnet is a subnet whose resources can be reached from the internet (if
allowed by security rules).
These resources usually have:
● Public IP address
● Route to an Internet Gateway (IGW)
Examples:
● Web servers
● Load Balancers
● Bastion (Jump) Server
AWS Example
Internet
|
Internet Gateway (IGW)
|
Public Subnet
|
EC2 Web Server
(Public IP)
A user from anywhere on the internet can access the web server (assuming the security
group and network ACL allow it).
Example:
● You type [Link]
● Request reaches the EC2 instance in the public subnet.
● The EC2 instance responds.
Characteristics of a Public Subnet
Feature Public Subnet
Internet Access Yes
Public IP Usually Yes
Route to Internet Gateway Yes
Can receive traffic from Yes (if permitted)
internet
Typical Resources Web servers, Load Balancers, Bastion
Hosts
Private Subnet
A private subnet is a subnet whose resources cannot be accessed directly from the
internet.
Resources in a private subnet:
● Usually have only private IP addresses
● Do not have a direct route to an Internet Gateway
Examples:
● Database servers
● Application servers
● Internal services
AWS Example
Internet
|
Internet Gateway
|
Public Subnet
|
Load Balancer
|
Private Subnet
|
Application Server
The application server is not directly accessible from the internet. Traffic reaches it
through the load balancer or another internal component.
Characteristics of a Private Subnet
Feature Private Subnet
Internet Access No (directly)
Public IP No
Route to Internet No
Gateway
Direct internet access No
Typical Resources Databases, Application
Servers
What is a NAT Gateway?
Sometimes servers in a private subnet need outbound internet access (for updates or
downloading packages), but they should not be reachable from the internet.
A NAT Gateway solves this.
Example:
Internet
^
|
Internet Gateway
^
|
NAT Gateway
^
|
Private Subnet
|
Application Server
The application server can:
● Download software updates
● Access package repositories
● Call external APIs
But people on the internet cannot initiate connections to it.
Public vs Private Subnet
Feature Public Subnet Private Subnet
Internet Gateway Yes No
Route
Public IP Yes (typically) No
Accessible from Yes (if security allows) No
Internet
Internet Access Direct Via NAT Gateway (outbound
only)
Typical Resources Web Server, Load Balancer, Database, Application
Bastion Host Server, Cache
AWS Architecture Example
Internet
|
Internet Gateway
|
+----------------+
| Public Subnet |
|----------------|
| Load Balancer |
| Web Server |
+----------------+
|
Private Network
|
+-------------------------------+
| Private Subnet |
|-------------------------------|
| Application Server |
| Database Server |
+-------------------------------+
|
NAT Gateway
|
Internet
How a request flows
1. A user opens a website in their browser.
2. The request reaches the Internet Gateway.
3. The Internet Gateway forwards it to the Load Balancer in the public subnet.
4. The Load Balancer sends the request to the Application Server in the private
subnet.
5. The Application Server reads or writes data in the Database (also in a private
subnet).
6. The response travels back through the Load Balancer to the user.
The application and database servers remain protected because they are never directly
exposed to the internet.