Skip to content

Commit eb70d92

Browse files
committed
added new docs for os for devOps...
1 parent d6b0190 commit eb70d92

File tree

7 files changed

+568
-0
lines changed

7 files changed

+568
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Networking & Protocols",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Learn the rules of the road. Understand how data packets travel from a user's browser to your server using the OSI model and standard protocols."
7+
}
8+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
sidebar_position: 5
3+
title: "DNS & DHCP: The Internet's GPS"
4+
sidebar_label: "5. DNS & DHCP"
5+
description: "Learn how DHCP assigns IP addresses automatically and how DNS translates human names into machine IPs."
6+
---
7+
8+
In a large data center like the ones used by **CodeHarborHub**, there are thousands of servers. Manually assigning an IP to each one would be a nightmare. Furthermore, expecting users to remember `142.250.190.46` instead of `google.com` is impossible.
9+
10+
This is where **DHCP** and **DNS** come in.
11+
12+
## 1. DHCP (The Hotel Hostess)
13+
14+
**DHCP (Dynamic Host Configuration Protocol)** is the service that automatically assigns an IP address to a device when it joins a network.
15+
16+
### The "DORA" Process
17+
When your laptop or a new AWS server turns on, it performs a 4-step "handshake" to get an IP.
18+
19+
```mermaid
20+
sequenceDiagram
21+
participant C as 💻 New Server (Client)
22+
participant D as 🛡️ DHCP Server
23+
24+
C->>D: Discover (Is anyone there? I need an IP!)
25+
D->>C: Offer (I have 192.168.1.50 available.)
26+
C->>D: Request (I'll take it! Please book it for me.)
27+
D->>C: Acknowledge (Done. It's yours for 24 hours.)
28+
```
29+
30+
:::info The "Lease" Concept
31+
IP addresses from DHCP aren't permanent. They are **Leased**.
32+
If a server at **CodeHarborHub** goes offline for a week, the DHCP server will eventually take that IP back and give it to someone else.
33+
:::
34+
35+
## 2. DNS (The Global Phonebook)
36+
37+
**DNS (Domain Name System)** is a distributed database that translates a Domain Name (URL) into an IP Address.
38+
39+
### The Hierarchy of DNS
40+
41+
DNS doesn't live in one place. It is a tree structure:
42+
43+
1. **Root Servers:** The "Grandparents" who know where the `.com`, `.org`, and `.in` servers are.
44+
2. **TLD Servers:** Top-Level Domain servers (e.g., The `.com` server).
45+
3. **Authoritative Servers:** The server that actually holds the record for `codeharborhub.github.io`.
46+
47+
48+
## 3. How a DNS Query Works
49+
50+
When you type `codeharborhub.github.io` in your browser, this "Detective Work" happens in milliseconds:
51+
52+
$$Query \rightarrow Recursive Resolver \rightarrow Root \rightarrow TLD \rightarrow Authoritative \rightarrow IP$$
53+
54+
### Common DNS Record Types
55+
56+
As a DevOps engineer, you will manage these records often:
57+
58+
| Record Type | Purpose | Example |
59+
| :--- | :--- | :--- |
60+
| **A Record** | Points a name to an **IPv4** address. | `codeharborhub.github.io` -\> `1.2.3.4` |
61+
| **AAAA Record** | Points a name to an **IPv6** address. | `site.github.io` -\> `2001:db8::1` |
62+
| **CNAME** | An "Alias" (Points a name to another name). | `www` -\> `codeharborhub.github.io` |
63+
| **MX Record** | Directs **Emails** to the right server. | `mail` -\> `google-mail.github.io` |
64+
| **TXT Record** | Used for verification (e.g., proving you own the site). | `v=spf1 include...` |
65+
66+
## 4. DNS Caching (The Memory)
67+
68+
To save time, your computer and your ISP "remember" (Cache) the IP address for a certain amount of time. This is called the **TTL (Time To Live)**.
69+
70+
$$TTL = \text{Time in seconds the record stays in cache}$$
71+
72+
* **Low TTL (60s):** Good for when you are moving servers and need fast changes.
73+
* **High TTL (3600s):** Good for stable sites to reduce traffic.
74+
75+
## Summary Checklist
76+
77+
* [x] I understand that **DHCP** gives out IPs and **DNS** resolves names.
78+
* [x] I can remember the **DORA** steps for DHCP.
79+
* [x] I know the difference between an **A Record** and a **CNAME**.
80+
* [x] I understand that **TTL** controls how long DNS records are cached.
81+
82+
:::info DNS Propagation
83+
When you change your DNS records at **CodeHarborHub** and don't see the change immediately, it's usually because of **DNS Propagation**. The world's "Phonebooks" are still updating their cache based on your old TTL!
84+
85+
This can take anywhere from a few minutes to 48 hours, depending on the previous TTL settings. In DevOps, we often set a low TTL before making changes to speed up this process.
86+
:::
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
sidebar_position: 4
3+
title: "HTTP & HTTPS: The Language of the Web"
4+
sidebar_label: "4. HTTP & HTTPS"
5+
description: "A deep dive into request-response cycles, status codes, and why the 'S' in HTTPS is non-negotiable."
6+
---
7+
8+
**HTTP (HyperText Transfer Protocol)** is the foundation of the World Wide Web. It is a "Stateless" protocol, meaning the server doesn't remember who you are after a request is finished every request is a brand new start.
9+
10+
## 1. The Request-Response Cycle
11+
12+
Every interaction on **CodeHarborHub** follows this simple pattern:
13+
14+
```mermaid
15+
sequenceDiagram
16+
participant B as 🌐 Browser (Client)
17+
participant S as ☁️ Server (Nginx/Node.js)
18+
19+
B->>S: HTTP Request (GET /index.html)
20+
Note right of S: Processing...
21+
S->>B: HTTP Response (200 OK + HTML)
22+
```
23+
24+
### Anatomy of a Request:
25+
26+
1. **Method:** What do you want to do? (GET, POST, etc.)
27+
2. **Path:** Where is the resource? (`/blog/devops`)
28+
3. **Headers:** Extra info (e.g., "I am using Chrome").
29+
4. **Body:** The data you are sending (used in POST requests).
30+
31+
## 2. The HTTP "Verbs" (Methods)
32+
33+
As a Full-stack developer, you must use the right "Verb" for the right action.
34+
35+
| Method | Human Action | DevOps/DB Action |
36+
| :--- | :--- | :--- |
37+
| **GET** | "Show me this." | READ |
38+
| **POST** | "Create this for me." | CREATE |
39+
| **PUT** | "Replace this entirely." | UPDATE |
40+
| **PATCH** | "Fix a small part of this." | MODIFY |
41+
| **DELETE** | "Get rid of this." | DELETE |
42+
43+
## 3. Status Codes: The Server's Mood
44+
45+
When a server at **CodeHarborHub** replies, it starts with a 3-digit number.
46+
47+
* **2xx (Success):** "Everything went great!" (e.g., `200 OK`, `201 Created`).
48+
* **3xx (Redirection):** "The file moved, go here instead." (e.g., `301 Moved Permanently`).
49+
* **4xx (Client Error):** "YOU messed up." (e.g., `404 Not Found`, `401 Unauthorized`).
50+
* **5xx (Server Error):** "I messed up." (e.g., `500 Internal Server Error`).
51+
52+
:::info The Math of Errors
53+
Statistically, if your site has a 99.9% uptime (The "Three Nines"), it means it can only return a **5xx** error for a total of **8.77 hours per year**.
54+
55+
$$Uptime \% = \frac{\text{Total Time} - \text{Downtime}}{\text{Total Time}} \times 100$$
56+
57+
However, in DevOps, we aim for "Four Nines" (99.99%), which allows for only **52.56 minutes of downtime per year**! This is crucial for high-traffic sites like **CodeHarborHub**.
58+
59+
:::
60+
61+
## 4. Why the "S" Matters (HTTPS)
62+
63+
**HTTP** sends data in "Plain Text." If you type your password on an HTTP site, anyone on the same Wi-Fi can see it. **HTTPS** uses **TLS (Transport Layer Security)** to encrypt the data.
64+
65+
### How HTTPS Works (The TLS Handshake):
66+
67+
1. **The Hello:** Client asks for a secure connection.
68+
2. **The Certificate:** Server sends its **SSL Certificate** (The Digital ID).
69+
3. **The Key Exchange:** They agree on a secret code using fancy math.
70+
4. **The Lock:** All data is now scrambled. Even if a hacker steals the "Packets," they just see gibberish.
71+
72+
If you see a padlock in the browser, it means HTTPS is working. This is non-negotiable for any site that handles user data, including **CodeHarborHub**. In DevOps, we often use tools like **Let's Encrypt** to get free SSL certificates and automate the renewal process.
73+
74+
## Inspecting the Traffic
75+
76+
You don't need fancy tools to see this!
77+
78+
1. Open **CodeHarborHub** in Chrome.
79+
2. Press `F12` (Developer Tools).
80+
3. Click the **Network** tab.
81+
4. Refresh the page.
82+
83+
You are now looking at real-time HTTP requests! You can see the methods, status codes, and even the headers. This is how DevOps engineers debug issues and optimize performance.
84+
85+
## Summary Checklist
86+
87+
* [x] I understand that HTTP is **Stateless**.
88+
* [x] I can explain the difference between a **GET** and a **POST** request.
89+
* [x] I know that **404** is a user error and **500** is a server error.
90+
* [x] I understand that **HTTPS** encrypts data using a TLS Handshake.
91+
92+
:::info Testing with `curl`
93+
In DevOps, we often use a tool called `curl` to test HTTP.
94+
`curl -I https://codeharborhub.github.io`
95+
This command will show you just the "Headers" of the site without downloading the whole page!
96+
:::
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
sidebar_position: 3
3+
title: "IP Addressing & Subnets: Mapping the Network"
4+
sidebar_label: "3. IP & Subnets"
5+
description: "Learn the language of IP addresses, the difference between IPv4 and IPv6, and how to carve out networks using CIDR."
6+
---
7+
8+
If the **OSI Model** is the set of rules, the **IP Address** is the specific location. Without a unique address, a data packet has no destination. At **CodeHarborHub**, we use these addresses to identify our Web Servers, Databases, and Load Balancers.
9+
10+
## 1. Anatomy of an IPv4 Address
11+
12+
An IPv4 address is a **32-bit** number, usually written as four decimal numbers (octets) separated by dots.
13+
14+
* **Format:** `192.168.1.1`
15+
* **The Math:** Each octet is 8 bits. Since $2^8 = 256$, each number can range from **0 to 255**.
16+
* **Total Capacity:** $$Total \approx 2^{32} \approx 4.3 \text{ Billion addresses}$$ *(Which is why the world is moving to IPv6—we've run out of IPv4s!)*
17+
18+
## 2. Public vs. Private IPs
19+
20+
Not every IP address is visible to the internet.
21+
22+
* **Public IP:** Like your home's physical mailing address. It is unique globally.
23+
* **Private IP:** Like an extension number in an office (e.g., "Dial Ext. 102"). It only works inside your local network (LAN) or your Cloud VPC.
24+
25+
:::info Reserved Private Ranges
26+
You will see these constantly in DevOps:
27+
* `10.0.0.0` - `10.255.255.255` (Large Corporations)
28+
* `172.16.0.0` - `172.31.255.255` (Mid-size)
29+
* `192.168.0.0` - `192.168.255.255` (Home routers)
30+
:::
31+
32+
## 3. Subnetting & CIDR (The "Slicing" Logic)
33+
34+
As a DevOps engineer, you don't just get one IP; you get a **Block** of IPs. We define these blocks using **CIDR (Classless Inter-Domain Routing)** notation.
35+
36+
### What is the `/24` or `/16`?
37+
The number after the slash tells us how many bits are "Locked" (The Network part) and how many are "Free" (The Host part).
38+
39+
```mermaid
40+
graph LR
41+
A[192.168.1.0/24] --> B(First 24 bits are the Network Name)
42+
A --> C(Last 8 bits are for your Servers)
43+
C --> D(256 possible IPs)
44+
```
45+
46+
* **/24:** 24 bits for the network, leaving 8 bits for hosts. This gives you 256 total IPs (254 usable).
47+
* **/16:** 16 bits for the network, leaving 16 bits for hosts. This gives you 65,536 total IPs (65,534 usable).
48+
49+
### The Math of Subnets:
50+
51+
To find out how many servers (hosts) you can fit in a subnet:
52+
$$Hosts = 2^{(32 - \text{CIDR})} - 2$$
53+
*(We subtract 2 because the first IP is the **Network ID** and the last is the **Broadcast**).*
54+
55+
* **Example `/24`:** $2^{(32-24)} - 2 = 254$ available IPs.
56+
* **Example `/32`:** $2^{(32-32)} = 1$ IP (A single specific machine).
57+
58+
## 4. IPv6: The Infinite Frontier
59+
60+
Because we ran out of IPv4 addresses, **IPv6** was created. It uses **128-bit** addresses written in Hexadecimal.
61+
62+
* **Example:** `2001:0db8:85a3:0000:0000:8a2e:0370:7334`
63+
* **The Math:** $$Total = 2^{128}$$ This is enough addresses to give every grain of sand on Earth its own IP address!
64+
65+
## DevOps Best Practices
66+
67+
1. **Start Big:** When creating a VPC for **CodeHarborHub**, start with a large range like `/16` (65,536 IPs). You can always slice it into smaller subnets later.
68+
2. **Isolate:** Put your Databases in a **Private Subnet** (no Public IP) and your Web Servers in a **Public Subnet**.
69+
3. **Use Static IPs sparingly:** Only use a fixed (Static/Elastic) IP for things that truly need it, like Load Balancers.
70+
71+
## Summary Checklist
72+
73+
* [x] I can identify the 4 octets of an IPv4 address.
74+
* [x] I understand that a Private IP is not reachable from the internet.
75+
* [x] I know that a smaller CIDR number (like `/16`) means a **larger** network.
76+
* [x] I understand why we subtract 2 from the total host count in a subnet.
77+
78+
:::info Subnetting Analogy
79+
Think of **Subnetting** like a cake. The CIDR number is how many times you cut the cake. The more "locked" bits (higher CIDR), the smaller the individual slices (fewer IPs per subnet).
80+
:::
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
sidebar_position: 6
3+
title: "Load Balancers & Proxies: Managing the Flow"
4+
sidebar_label: "6. Load Balancers & Proxies"
5+
description: "Learn how to scale your applications and protect your servers using Reverse Proxies and Load Balancing algorithms."
6+
---
7+
8+
At **CodeHarborHub**, we don't want our users talking directly to our sensitive Databases or even our main App Servers. Instead, we put a "Security Guard" in front. This guard is either a **Forward Proxy**, a **Reverse Proxy**, or a **Load Balancer**.
9+
10+
## 1. Forward vs. Reverse Proxies
11+
12+
The word "Proxy" just means "on behalf of."
13+
14+
### Forward Proxy (The Client's Guard)
15+
16+
A Forward Proxy sits in front of the **Users**. It hides the user's IP from the internet.
17+
* **Use Case:** A school blocking social media sites or a VPN hiding your location.
18+
19+
::info The "Forward" Logic
20+
The "Forward" in Forward Proxy means it forwards the user's request to the internet while hiding their IP. It's like a "Mask" for the client.
21+
:::
22+
23+
### Reverse Proxy (The Server's Guard)
24+
25+
A Reverse Proxy sits in front of the **Web Servers**. Users think they are talking to the website, but they are actually talking to the Proxy (like **Nginx**).
26+
* **Use Case:** Hiding your server's private IP, handling SSL (HTTPS), and caching images to make the site faster.
27+
28+
::info The "Reverse" Logic
29+
The "Reverse" in Reverse Proxy means it does the opposite of a Forward Proxy. Instead of hiding the client's IP, it hides the server's IP. It's like a "Reverse Mask."
30+
:::
31+
32+
## 2. Load Balancers (The Traffic Cop)
33+
34+
When **CodeHarborHub** goes viral, one server isn't enough. A Load Balancer (LB) takes incoming requests and spreads them across a "Pool" of multiple servers.
35+
36+
```mermaid
37+
graph TD
38+
User((🌐 User)) --> LB{⚖️ Load Balancer}
39+
LB --> S1[☁️ Server A]
40+
LB --> S2[☁️ Server B]
41+
LB --> S3[☁️ Server C]
42+
43+
style LB fill:#f96,stroke:#333,stroke-width:2px,color:#000
44+
style S1 fill:#9f6,stroke:#333,stroke-width:2px,color:#000
45+
style S2 fill:#9f6,stroke:#333,stroke-width:2px,color:#000
46+
style S3 fill:#9f6,stroke:#333,stroke-width:2px,color:#000
47+
```
48+
49+
### How does it choose? (Algorithms)
50+
51+
The LB uses math to decide which server gets the next user:
52+
53+
1. **Round Robin:** Simply goes in order (A -> B -> C -> A).
54+
2. **Least Connections:** Sends the user to the server that is currently the least busy.
55+
3. **IP Hash:** Ensures that a specific user (based on their IP) always goes to the same server (Important for "Login Sessions").
56+
57+
If Server B is down, the LB will automatically skip it and send traffic to A and C until B is back up. This is called **Fault Tolerance**.
58+
59+
## 3. Layer 4 vs. Layer 7 Load Balancing
60+
61+
Remember the **OSI Model**? Load balancers work at different levels:
62+
63+
* **Layer 4 (Transport):** Faster. It only looks at IP addresses and Ports. It doesn't care if the request is for an image or a video.
64+
* **Layer 7 (Application):** Smarter. It looks at the actual HTTP request.
65+
* *Example:* It can send all `/api` requests to a powerful server and all `/images` requests to a storage server.
66+
67+
## 4. The Math of High Availability
68+
69+
In DevOps, we calculate the "Health" of our cluster. If we have $N$ servers and each can handle $R$ requests per second, our total capacity is:
70+
71+
$$Total\_Capacity = N \times R$$
72+
73+
However, a good DevOps engineer always plans for a "Failure State" ($N-1$):
74+
75+
$$Safe\_Capacity = (N - 1) \times R$$
76+
77+
:::info Health Checks
78+
The Load Balancer constantly pings your servers: *"Are you alive?"* If Server B doesn't respond, the LB immediately stops sending traffic there until it's fixed. This is called **Self-Healing**.
79+
:::
80+
81+
## Common Tools
82+
* **Nginx:** The world's most popular Reverse Proxy.
83+
* **HAProxy:** A high-performance Load Balancer.
84+
* **AWS ELB (Elastic Load Balancer):** The cloud version used by most startups.
85+
86+
## Summary Checklist
87+
* [x] I know that a **Reverse Proxy** protects the server.
88+
* [x] I can explain the difference between **Round Robin** and **Least Connections**.
89+
* [x] I understand that **Layer 7** Load Balancing is "Application Aware."
90+
* [x] I understand that **Health Checks** prevent users from seeing "404" or "500" errors.
91+
92+
:::success Networking & Protocols Complete!
93+
Congratulations! You've learned how to manage traffic and protect your servers using Load Balancers and Proxies. This is a critical skill for any DevOps engineer, especially when scaling applications like **CodeHarborHub**. In the next chapter, we will dive into **Monitoring & Logging** to keep an eye on our systems and catch issues before users do!
94+
:::

0 commit comments

Comments
 (0)