A Beginner's Guide to Computer Networking

Prashant GohelPrashant Gohel
20 min read

Table of contents

๐Ÿง  What is Computer Networking?

Letโ€™s imagine this:

  • There are 5 cities โ€” C1, C2, C3, C4, and C5.

  • These cities are connected by roads.

  • You can travel between cities using a car.

Now, imagine:

  • Cities = Computers

  • Roads = Network

  • Car = Data

โžก๏ธ So, Computer Networking is like building roads between cities so that cars (data) can travel from one city (computer) to another.

In simple terms:

Computer Networking is a system where multiple computers are connected to share data, files, and resources like printers or the internet โ€” either via wires (cables) or wireless means.


๐Ÿค” Why Networking Matters in DevOps?

As a DevOps Engineer, your job involves working with servers, cloud systems, and automations.

๐Ÿงฐ So why is networking important?

  • You often transfer files between servers.

  • You need to configure firewalls, load balancers, DNS records, and monitor traffic.

  • You might have to SSH into a remote machine, which is part of a network.

In short, you canโ€™t do DevOps without a good grip on networking.


๐ŸŒ How Does the Internet Work?

Letโ€™s make this super simple:

๐ŸŽฌ Example: Youโ€™re watching Netflix in India But Netflix's main servers are in the USA. So how does your request reach them?

You might imagine that data travels through satellites. Yes, thatโ€™s possible, but itโ€™s slow due to the distance.

โœ… Real Answer: Undersea Optical Fiber Cables Oceans are filled with underwater fiber cables โ€” these cables carry data at high speed and low latency.

So when you visit www.netflix.com, hereโ€™s what happens:

๐ŸŒ Step-by-Step Internet Journey

  • You type a website (e.g., www.netflix.com) in the browser.

  • The request goes out using a protocol: HTTP or HTTPS.

HTTP (HyperText Transfer Protocol) sends webpages.

HTTPS is the secure version (with encryption).

Butโ€ฆ how will the internet know where Netflix is?

Thatโ€™s where DNS (Domain Name System) comes in.

๐Ÿ”Ž DNS works like a phonebook:

  • You ask it: โ€œWhere is www.netflix.com?โ€

  • It replies: โ€œHereโ€™s the IP address: 198.123.45.67.โ€

  • ๐ŸŒ The IP address is where Netflix's server lives โ€” in the USA.

  • Your request travels through routers, ISPs, and cables...

Your Device โ†’ Router โ†’ ISP (like Jio, Airtel) โ†’ Submarine Cables โ†’ Netflix Server

Netflix sends video data back the same way to your browser โ€” and voilร , your movie starts!


๐Ÿ”ง Try It Yourself (Practical Commands)

๐Ÿ” Trace the Route

See how your request travels across the internet:

traceroute netflix.com      # On Linux/macOS
tracert netflix.com         # On Windows

This will show:

  • Your routerโ€™s IP

  • ISP nodes

  • International jumps

  • And finally, the destination (Netflix)

๐Ÿ“ถ Check Connection

Use ping to see if you can reach a server:

ping google.com

It sends small packets to Google and shows if itโ€™s reachable and how long it takes (latency).


๐Ÿง  The OSI Model

OSI (Open Systems Interconnection) Model is a framework that standardizes how data is transferred between two systems over a network.

It has 7 layers, each with a specific role in ensuring smooth, secure, and reliable communication.

๐ŸŽฎ Imagine This:

Two friends, A and B, are playing a multiplayer online game from different countries.

Letโ€™s use this scenario to understand how the OSI Model works.

๐Ÿ“š OSI Layers Mnemonic:

All People Seem To Need Data Processing

(Application โ†’ Physical)


๐Ÿ”ผ Layer 7: Application Layer โ€“ โ€œLetโ€™s Play!โ€

This is where A and B run the actual game app (e.g., PUBG, Fortnite).

  • This is the interface between the user and the network.

  • They use a browser or mobile app.

  • Protocols: HTTP, HTTPS, FTP, SMTP

๐Ÿ’ก In DevOps, you work with these protocols while managing servers and web apps.


๐ŸŽจ Layer 6: Presentation Layer โ€“ โ€œGraphics, Sounds, and Securityโ€

A and B are seeing graphics, using keyboard, listening to game sounds, and the data is encrypted.

  • It manages how the data is presented: format, encoding, encryption.

  • It converts data to be readable by the receiver.

  • Also responsible for SSL/TLS encryption (important in HTTPS).

๐Ÿ›ก๏ธ Think of this as the syntax and security formatting of the data.


๐Ÿ”Œ Layer 5: Session Layer โ€“ โ€œLetโ€™s Connectโ€

Before playing, a connection is established between A and B (like a game lobby).

  • This layer establishes, maintains, and ends communication sessions.

  • Responsible for authentication and session management.

๐Ÿ”ง Examples:

API sessions: when apps talk to each other (e.g., payment gateways).

Sockets: used for real-time communication like chat, games, etc.

๐Ÿ‘‰ API: Bridge between two apps (e.g., Google Maps inside Zomato app)

๐Ÿ‘‰ Socket: Real-time data channel (e.g., online multiplayer game, live chat)


๐Ÿ“ฆ Layer 4: Transport Layer โ€“ โ€œSend It Reliablyโ€

The game data like movements, actions, chat is now broken into packets and sent between A and B.

  • Responsible for reliable delivery, error checking, and flow control.

Protocols:

TCP (Transmission Control Protocol) โ€“ Reliable, connection-based

UDP (User Datagram Protocol) โ€“ Faster but no guarantee (used in live games, video calls)

๐Ÿงช Youโ€™ll hear this in DevOps when setting up ports, firewalls, or troubleshooting connection issues.


๐Ÿ›ฐ๏ธ Layer 3: Network Layer โ€“ โ€œFind the Wayโ€

A and Bโ€™s data has to travel across the globe. So it needs routing.

  • Responsible for IP addressing and routing.

  • It finds the best path for data.

Protocol: IP (Internet Protocol)

๐Ÿ“ Example: Your request goes from India to the US via routers using IPs.

You can trace this using:

traceroute google.com   # Linux/macOS
tracert google.com      # Windows

Now the data is being transferred within the same local network (e.g., from your laptop to your WiFi router).

  • Deals with MAC addresses, frames, and error detection.

  • Ensures data is sent to the right device on a local network.

๐Ÿ‘€ You can check your MAC address using:

ip link show

๐Ÿงฑ Layer 1: Physical Layer โ€“ โ€œThe Real Wiresโ€

Finally, all of this data flows through real hardware โ€“ like fiber optic cables, network cards, or WiFi signals.

  • Transmits 0s and 1s (binary data) over physical medium (cables, radio waves).

Includes: Cables, Switches, Hubs, Connectors, NICs.

๐Ÿ’ก Without this, the internet wouldnโ€™t exist physically.


๐Ÿ”„ Software vs Hardware in OSI Model

LayerHandled By
Application to Session (7โ€“5)Software (Apps, APIs, OS services)
Transport to Physical (4โ€“1)Hardware + OS + Network tools

๐Ÿงต Final Summary: Gaming the OSI Model

LayerGame AnalogyReal Function
7. ApplicationRunning the GameInterface for user apps
6. PresentationGraphics & EncryptionData formatting, encryption
5. SessionConnection SetupSession control (API/Sockets)
4. TransportSending ActionsReliable data delivery (TCP/UDP)
3. NetworkGlobal RoutingIP addressing and routing
2. Data LinkLocal NetworkMAC address & local delivery
1. PhysicalHardware/SignalsCables, NICs, electrical signals

โœ… Ready for DevOps?

OSI is more than theory. Youโ€™ll use it when:

  • Configuring ports (Layer 4)

  • Understanding IP routing and DNS (Layer 3)

  • Managing VPNs and proxies

  • Debugging with ping, traceroute, netstat, tcpdump, etc.


๐ŸŒ TCP/IP Reference Model

โœ… What is the TCP/IP Model?

The TCP/IP Model (Transmission Control Protocol / Internet Protocol) is the framework used in real-world networks, including the internet.

๐Ÿง  Fun Fact:

  • It was developed by the U.S. Department of Defense.

  • Itโ€™s more practical than OSI.

  • The entire internet works using this model!


๐Ÿ”ข TCP/IP vs OSI โ€“ Layer Comparison Table

TCP/IP ModelOSI ModelDescription
4๏ธโƒฃ Application LayerOSI Layers 7, 6, 5 (App, Pres, Sess)User-facing services like HTTP, FTP, DNS
3๏ธโƒฃ Transport LayerOSI Layer 4 (Transport)Ensures data delivery (TCP/UDP)
2๏ธโƒฃ Internet LayerOSI Layer 3 (Network)IP addressing and routing
1๏ธโƒฃ Network AccessOSI Layers 2 & 1 (Data Link, Physical)Deals with MAC, switches, physical data transfer

๐Ÿ” Layer-by-Layer Explanation

๐Ÿ”ผ 1. Application Layer (Userโ€™s World ๐ŸŒ)

  • Combines Application + Presentation + Session (from OSI)

  • This layer is where users interact โ€” web apps, emails, file transfers, etc.

๐Ÿ› ๏ธ Protocols:

  • HTTP/HTTPS โ€“ Browsing websites

  • FTP โ€“ File transfers

  • SMTP/POP3/IMAP โ€“ Emails

  • DNS โ€“ Resolving domain names

  • SSH โ€“ Securely accessing remote machines

๐Ÿ’ก DevOps relevance:

  • You deploy web apps via HTTP

  • Use DNS to map domains

  • Use SSH daily to connect to servers


๐Ÿšš 2. Transport Layer (Data Delivery ๐Ÿ“ฆ)

  • Same as OSI Layer 4

  • This layer is responsible for reliable or fast delivery of data between systems.

๐Ÿ› ๏ธ Protocols:

  • TCP โ€“ Reliable, ordered, connection-based

  • UDP โ€“ Fast, connectionless (e.g., video calls, gaming)

๐Ÿ’ก DevOps relevance:

  • Use TCP for SSH, HTTPS, etc.

  • Understand port numbers (like 80 for HTTP, 443 for HTTPS)

  • Configure firewalls and load balancers on this layer


๐Ÿ›ฐ๏ธ 3. Internet Layer (IP & Routing ๐ŸŒ)

  • Matches OSIโ€™s Network Layer

  • This layer decides how to send data from one device to another across networks.

๐Ÿ› ๏ธ Protocols:

  • IP (Internet Protocol) โ€“ Assigns addresses

  • ICMP โ€“ For diagnostics (used by ping)

  • ARP โ€“ Finds MAC address from IP

  • RIP/OSPF/BGP โ€“ Routing protocols

๐Ÿ’ก DevOps relevance:

  • IP configuration, subnetting

  • ping, traceroute, netstat, and ip commands

  • Setting up routing between VPCs in AWS


๐Ÿ”Œ 4. Network Access Layer (Local Network Transfer ๐Ÿงฑ)

  • Combines OSI Layers: Data Link + Physical

  • Handles local delivery within the same network โ€” like your PC to WiFi router.

๐Ÿ› ๏ธ Technologies:

  • Ethernet, Wi-Fi

  • Switches, Cables, Network Interface Cards (NIC)

  • MAC addresses

๐Ÿ’ก DevOps relevance:

  • Identify NICs

  • Work with MAC/IP mapping

  • Monitor hardware-based issues


๐Ÿ” End-to-End Flow Example

๐Ÿง‘โ€๐Ÿ’ป User A wants to open www.example.com

  • Application Layer: Browser sends HTTP request

  • Transport Layer: Data broken into TCP segments

  • Internet Layer: Adds IP header to route packets

  • Network Access Layer: Frames sent via Ethernet/Wi-Fi to local router


๐Ÿš€ Final Tip for DevOps Learners

Think of the TCP/IP model not just as theory, but as a troubleshooting tool.

If something goes wrong:

  • Is the domain not resolving? โ†’ DNS issue (Application layer)

  • Canโ€™t connect to server? โ†’ Port or firewall (Transport layer)

  • Packet not reaching? โ†’ Routing (Internet layer)

  • No connection at all? โ†’ Cable/Wi-Fi issue (Network Access layer)


๐ŸŒ IP Address & Subnets

๐Ÿ“ฆ What is an IP Address?

  • Imagine your device (laptop, phone, etc.) as a house, and the internet is the global postal service.

  • Just like each house needs a unique address to receive letters, every device needs a unique IP address to send and receive data.

๐Ÿง  Definition:

  • An IP address (Internet Protocol address) is a unique identifier assigned to a device connected to a network so it can communicate with other devices.

๐Ÿ–ฅ๏ธ Why Do Devices Need IP Addresses?

Today, we have a variety of smart devices:

  • ๐Ÿ“ฑ Smartphones

  • ๐Ÿ’ป Laptops

  • ๐Ÿ“บ Smart TVs

  • โŒš Smartwatches

  • ๐Ÿ“Ÿ Tablets

โžก๏ธ Each of them must be uniquely identifiable on the internet or local network. Without an IP address, the internet wonโ€™t know where to send the data.

๐Ÿ“ฌ IP = Digital Home Address for devices
Used by the TCP/IP model (real-world) and also fits into OSI Layer 3 (Network Layer)


๐Ÿงฎ Types of IP Address Versions

๐Ÿ“„ IPv4 โ€“ Internet Protocol Version 4

  • Format: 192.168.1.1

  • Uses 32 bits = ~4.2 billion addresses

  • โœ… Widely used today

  • โŒ Problem: Not enough IPs for all devices on Earth

๐ŸŒ IPv6 โ€“ Internet Protocol Version 6

  • Format: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

  • Uses 128 bits = 340 undecillion IPs (massive!)

  • โœ… Solves the address limitation

  • โŒ Still not adopted fully everywhere (IPv4 still dominates)


๐Ÿคฏ So Whatโ€™s the Problem With IPv4?

There are only about 4.2 billion IPv4 addresses. But with billions of people and multiple devices per person, we ran out fast!

Imagine if every device needed a real internet-facing IP, weโ€™d have been done by now!


๐Ÿ’ก Whatโ€™s the Solution? โ€“ Subnets & Private IPs

๐ŸŒ Solution 1: Private Networks + Subnets

Instead of creating one massive internet, we create many small internal networks (like mini-internets).

Each internal network can reuse private IP addresses (like 192.168.x.x, 10.x.x.x, etc.) behind a router or firewall using NAT (Network Address Translation).

These internal networks are called subnets.


๐Ÿงฉ What is a Subnet?

A subnet (sub-network) is a smaller section of a larger network โ€” like rooms in a house.

By dividing a large network into subnets:

  • Devices stay organized

  • Traffic is more efficient

  • IP addresses are reused smartly

๐Ÿ’ก In DevOps & Cloud:

  • Youโ€™ll often create subnets in AWS VPCs

  • Youโ€™ll assign private IPs and control traffic between them


๐Ÿ”ข IP Address Breakdown โ€“ Subnet Example

Letโ€™s say:

IP: 192.168.10.5
Subnet Mask: 255.255.255.0

Network part: 192.168.10
Host part: .5 (device number in network)

This means:

  • All devices in 192.168.10.X belong to the same subnet

  • The .5 is the unique address within that subnet


โœ… Final Summary

TermMeaning
IP AddressUnique number to identify a device on a network
IPv4Older version, 32-bit, ~4.2 billion addresses (e.g., 192.168.1.1)
IPv6Newer version, 128-bit, 340 undecillion addresses
SubnetA logical division of a large network
NATAllows many private IPs to use one public IP for internet access
Private IPsUsed inside local networks (not directly reachable from internet)

๐Ÿ‘จโ€๐Ÿ’ป As a DevOps Engineer, Youโ€™ll Use:

  • Private/Public IPs when deploying servers

  • Subnets when setting up cloud networks (like AWS VPC)

  • CIDR notation for subnetting (e.g., 10.0.0.0/24)

  • ping, ip addr, ifconfig, ipcalc, etc. to manage networks


โ˜๏ธ AWS Networking Essentials: VPC, Subnets, Security Groups, NAT & DNS

๐Ÿง  What is a VPC?

  • VPC (Virtual Private Cloud) is like your own private network inside AWS.

  • Imagine AWS as a huge city ๐Ÿ™๏ธ, and you get your own private colony inside it. Thatโ€™s a VPC.

๐Ÿ”‘ Key Points:

  • You control IP ranges, subnets, routing, and firewall rules.

  • VPCs are isolated, so IPs wonโ€™t clash between users.

  • Each EC2 instance you launch lives inside a subnet โ†’ inside a VPC.


๐Ÿงฉ VPC Structure Breakdown

Copy
Edit
๐ŸŒ AWS Cloud
    โ””โ”€โ”€ VPC (Your Private Network)
        โ””โ”€โ”€ Subnets (Smaller segmented networks: Public & Private)
            โ””โ”€โ”€ EC2 Instances (Virtual Machines)

โžก๏ธ You can have multiple subnets within a VPC โ€” think of them as rooms in your house.

๐ŸŒ IP Addressing Inside VPC

  • Every device (EC2 instance) inside a VPC gets a unique private IP.

  • If you enable auto-assign public IP, it gets a public IP too.

  • IPs donโ€™t conflict because each VPC has its own CIDR range.


๐Ÿ”ฅ What is a Security Group (SG)?

  • A Security Group is like a firewall for your EC2 instance.

๐Ÿ“Œ It controls:

  • Who can connect to your server

  • What type of traffic is allowed (HTTP, SSH, etc.)

๐Ÿ’ก SG is stateful โ€” if you allow incoming traffic on a port, the response is automatically allowed out.


๐Ÿ” Example: Allow Only Your PC to SSH

  • Letโ€™s say you want only your personal computer to connect to the EC2 instance via SSH:

  • Go to your SG in AWS.

Edit inbound rules:

  • Type: SSH

  • Port: 22

  • Source: Your IP Address/32 (get it from whatismyip.com)

โœ… Now, only your IP can access the EC2 server via SSH.


๐Ÿ–ฅ๏ธ Connecting to EC2 Using Public IP

Once the instance is launched:

  • Use AWS EC2 Connect (browser) or

  • Use terminal + .pem key and public IP

ssh -i mykey.pem ubuntu@<public-ip>

๐ŸŒ Live Webpage Hosting on EC2 (Ubuntu)

Now letโ€™s make your server public by installing a web server:

sudo apt update
sudo apt install nginx
cd /var/www/html
sudo vim index.html

# ๐Ÿ‘‰ Add HTML:

<h1>Hello, I am Prashant Gohel</h1>
Then save file (Esc + :wq)

# Check server:

sudo systemctl status nginx

โŒ Canโ€™t Access Page? Firewall (SG) is Blocking

By default, port 80 is blocked.

โœ… Fix: Add HTTP rule in Security Group

  • Type: HTTP

  • Port: 80

  • Source: Anywhere (0.0.0.0/0)

Now, open:

http://<your-ec2-public-ip>

# ๐ŸŽ‰ Your webpage is live!

๐Ÿ”„ What is NAT?

NAT (Network Address Translation) allows instances in a private subnet to access the internet securely.

๐Ÿ’ก Use Case:

  • You want backend servers to update software (apt, yum, etc.) but not be publicly accessible.

  • NAT Gateway allows outbound internet access without exposing them to the public.


๐ŸŒ DNS: Domain Instead of IP

Right now, your site is only accessible via IP โ€” but you want something like:

www.prashantgohel.in

Steps:

  • Buy a domain (e.g., from GoDaddy)

  • Point the domain to your EC2 public IP via DNS settings

  • Go to GoDaddy DNS manager

Add an A record:

Host: @
Type: A
Points to: <your-ec2-public-ip>
TTL: Default

โœ… Now, your website can be accessed using your domain!


๐Ÿง  OSI Model Behind the Scenes (Quick Review)

OSI LayerYour Activity
ApplicationOpen browser โ†’ EC2 Connect or Website
PresentationAWS encrypts data for security (HTTPS)
SessionYour browser session to EC2 remains active
TransportData sent via TCP (port 22 for SSH, 80 for HTTP)
NetworkIP routing (public/private IP)
Data LinkEthernet/WiFi to router
PhysicalFiber cables, routers, network cards

โœ… Summary

ConceptReal-World Meaning
VPCYour private AWS network
SubnetSmall segment of a VPC
Security GroupFirewall that controls traffic to/from EC2
NATAllows private instances to access the internet
DNSMaps a domain to your EC2 public IP

โ˜๏ธ AWS VPC Networking โ€“ Subnets, NAT, Gateways, and Route Tables

๐Ÿ” First, Some Handy CLI Commands

Before we dive into AWS concepts, here are two network diagnostic tools:

1๏ธโƒฃ Find IP Address of a Website:

nslookup google.com

# โœ… This queries DNS and gives you the IP address of the domain.

2๏ธโƒฃ Trace Route to a Website:

traceroute google.com   # Linux/macOS
tracert google.com      # On Windows

# โœ… Shows the path (hops) your data takes to reach the website โ€” useful to debug latency or blockages.

๐Ÿ” What is a VPC (Virtual Private Cloud)?

A VPC is your own private, isolated network inside AWS.

  • Imagine AWS as a massive city, and your VPC is your private gated colony.

  • Inside this colony, you can build homes (EC2), roads (subnets), guards (firewalls), and rules (route tables).

Structure:

AWS Cloud
โ””โ”€โ”€ VPC
    โ”œโ”€โ”€ Public Subnet (App Server)
    โ”œโ”€โ”€ Private Subnet (DB Server)

Public Subnet: Accessible from the internet (e.g., EC2 with web app)

Private Subnet: Not accessible directly from internet (e.g., RDS DB)


๐Ÿ›ก๏ธ Where to Keep Your Database?

Always place your Database (like Amazon RDS) in the private subnet.

Why?

  • You don't want end users (or hackers) to directly touch your database.

  • Only the application (in the public subnet) should access the database internally.


๐ŸŒ How App (Public Subnet) Talks to DB (Private Subnet)?

Hereโ€™s the challenge:

  • Both subnets are isolated from each other.

  • IPs in one subnet donโ€™t directly talk to another unless routes exist.

โœ… Solution: Use NAT Gateway

NAT (Network Address Translation) allows:

  • Instances in private subnet to access the internet

  • OR talk to resources in public subnet via IP translation.

So:

  • App (public) โ†’ NAT โ†’ DB (private) โœ… Allowed

  • User โ†’ App works because app is public

  • User โ†’ DB โŒ Blocked (secure by design)


๐ŸŒ But... How Does a User Access My App?

You said it right โ€” the user is outside AWS, so how can they reach your app which is inside a VPC?

  • That's where the Internet Gateway (IGW) comes in.

๐Ÿ”Œ Internet Gateway (IGW):

  • Acts like the main gate to your VPC colony.

  • Without IGW, your VPC is cut off from the internet.

โœ… Flow:

User (Browser)
    โ†“
Internet Gateway
    โ†“
VPC โ†’ Public Subnet โ†’ EC2 (App)

๐Ÿงญ What is a Route Table in VPC?

  • A Route Table is like a GPS system for AWS networks.

  • It tells AWS where to send traffic based on destination IP.

Example:

  • In a route table:

  • 0.0.0.0/0 โ†’ Internet Gateway (for public access)

  • 10.0.1.0/24 โ†’ Private Subnet (internal routing)

  • 0.0.0.0/0 โ†’ NAT Gateway (for private instances to access internet)

  • Each subnet must be associated with a route table.


๐Ÿ”„ Full Traffic Flow: End-to-End Example

Hereโ€™s a complete traffic journey from a user to your EC2 app and how your EC2 talks to RDS:

User
    โ†“
Internet Gateway (IGW)
    โ†“
VPC
    โ””โ”€โ”€ Public Subnet
          โ””โ”€โ”€ EC2 Instance (Web App)
              โ””โ”€โ”€ Talks to RDS (Private Subnet) via NAT Gateway

๐Ÿ“ถ Bonus: VPC Peering

What if you have two separate VPCs (maybe in different regions/accounts) and want them to talk?

  • Use VPC Peering โ€” like creating a private tunnel between two VPCs.

๐Ÿ’ก You need to:

  • Create peering connection

  • Accept it

  • Update route tables on both sides

  • Ensure security groups allow traffic


โœ… Summary Table

ConceptRole
VPCIsolated network in AWS
SubnetSmaller section of a VPC (public/private)
Public SubnetAllows internet access
Private SubnetInternal-only, secure (e.g., DB)
NAT GatewayAllows private subnet to access public subnet/internet
Internet GatewayLets external users access public subnet
Route TableRoutes traffic inside/outside the VPC
VPC PeeringConnects two VPCs privately

โš–๏ธ What is a Load Balancer? โ€“ With AWS Perspective

๐Ÿšฆ Basic Idea:

  • A Load Balancer acts like a traffic cop that:

  • Sits in front of your servers

  • Distributes incoming traffic across multiple instances

  • Ensures no single instance is overloaded

  • Automatically redirects traffic if one server fails

๐ŸŽฏ Why is it useful?

  • High Availability

  • Auto-Scaling support

  • Fault Tolerance

  • Smooth user experience even during heavy traffic


๐Ÿ—๏ธ Types of Load Balancers in AWS

You can find these in:

AWS Console โ†’ EC2 โ†’ Load Balancers

1๏ธโƒฃ Application Load Balancer (ALB)

Works at Layer 7 (Application Layer) of the OSI model

โœ… Use when:

  • You have web applications (HTTP/HTTPS)

  • You need to route based on URL paths (e.g., /api, /login)

  • You want host-based routing (e.g., admin.example.com, user.example.com)

๐Ÿง  Smart features:

  • Supports SSL/TLS termination

  • Can route based on cookies, user-agent, etc.

Example:


2๏ธโƒฃ Network Load Balancer (NLB)

Works at Layer 4 (Transport Layer)

โœ… Use when:

  • You need ultra-high performance

  • You're handling millions of TCP/UDP connections

  • For real-time gaming, high-frequency trading, IoT

Key Traits:

  • Faster, handles low latency

  • Routes traffic based on IP and port only

  • Supports static IP or Elastic IP

Real Example:

  • During Flipkart Big Billion Days or Amazon Prime Sale, millions of users connect.

  • A Network Load Balancer helps distribute massive TCP/UDP loads across backend servers.


3๏ธโƒฃ Gateway Load Balancer (GWLB)

Works with third-party virtual appliances (firewalls, monitoring tools)

โœ… Use when:

  • You want to insert security tools (like Palo Alto, Fortinet) into traffic flow

  • For inspection, filtering, or monitoring traffic


๐ŸŒ How Load Balancers Fit in AWS Architecture

Internet
    โ†“
Application Load Balancer (ALB)
    โ†“           โ†“
  EC2-1         EC2-2
    โ†“           โ†“
Private Subnet (RDS)
  • The ALB handles web traffic

  • Distributes to multiple EC2 instances

  • These may connect internally to a DB in private subnet

๐Ÿ’ก You define Target Groups in AWS to decide which EC2s your Load Balancer can send traffic to.


๐Ÿ“Š Layer Comparison: ALB vs NLB

FeatureALB (App LB)NLB (Network LB)
OSI LayerLayer 7 (Application)Layer 4 (Transport)
ProtocolsHTTP, HTTPSTCP, UDP
Smart RoutingYes (URL, headers, cookies)No (IP-based only)
Use CaseWeb apps, microservicesHigh-speed, high-volume apps
LatencySlightly higherUltra-low latency
SSL TerminationSupportedNeeds extra setup
Static IP supportNoYes

โœ… Real-World DevOps Relevance

  • ALB is common in microservices & containerized apps

  • NLB is used in enterprise or real-time data systems

  • Youโ€™ll use LB with:

    • Auto Scaling Groups

    • ECS / EKS (containers)

    • RDS or backend APIs


๐Ÿ› ๏ธ Quick Setup Steps (ALB):

  1. Go to EC2 โ†’ Load Balancers โ†’ Create ALB

  2. Select internet-facing

  3. Choose HTTP / HTTPS

  4. Create Target Group (EC2 or IP based)

  5. Register your EC2 instances

  6. Add Listeners & Rules (e.g., route /api to backend1)

  7. Launch and test via ALB DNS name

0
Subscribe to my newsletter

Read articles from Prashant Gohel directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Prashant Gohel
Prashant Gohel

DevOps & Cloud Enthusiast | Exploring Linux, AWS, CI/CD & Automation | Sharing hands-on notes, tips, and real-world learning as I grow into a DevOps Engineer