Posts

Showing posts from 2026

📘 Load Balancer – Complete Concept

              📘 Load Balancer – Complete Concept  🔹 1. What is a Load Balancer? A Load Balancer distributes incoming network traffic across multiple servers to ensure: High availability Better performance No single server overload 👉 Example: Instead of 1 server handling 10,000 users, LB splits traffic across 5 servers. 🔹 2. Why Do We Need It? Without LB: Server crash = whole app down  Slow response under heavy traffic  With LB: Fault tolerance  Scalability  High performance  🧠 First: What is IP & Port? IP address = identifies a machine 👉 like house address ( 192.168.1.1 ) Port = identifies a service inside that machine 👉 like room number 80 → HTTP 443 → HTTPS 3306 → MySQL 🔹 3. Types of Load Balancer (A) Based on Layer (OSI Model) 1. Layer 4 (Transport Level) Works on IP + Port Faster, less intelligent Example: TCP routing 2. Layer 7 (Application Level) Wo...

What is IP & Port?

  🌐 First: What is IP & Port? IP address = identifies a machine 👉 like house address ( 192.168.1.1 ) Port = identifies a service inside that machine 👉 like room number 80 → HTTP 443 → HTTPS 3306 → MySQL

🌐 When You Hit a URL (Full Flow)

  🔹 1. You Enter URL in Browser Example: https://example.com Browser parses: Protocol → HTTPS Domain → example.com 🔹 2. DNS Resolution (Domain → IP) Browser checks cache → OS cache → ISP DNS If not found, DNS lookup happens Domain resolves to IP (usually Load Balancer) 👉 Now browser knows where to send request 🔹 3. TCP Connection (3-Way Handshake) Browser connects to server IP: SYN SYN-ACK ACK 👉 Connection established 🔹 4. HTTPS / SSL Handshake (Security 🔐) Server sends SSL certificate Browser verifies it Encryption keys are exchanged 👉 Secure connection ready 🔹 5. Request Reaches Load Balancer Domain usually points to LB (public IP) Example tools: NGINX AWS Elastic Load Balancing 👉 LB decides which server should handle request 🔹 5. Request Reaches Load Balancer Domain usually points to LB (public IP) Example tools: NGINX AWS Elastic Load Balancing 👉 LB decides which server should handle request 🔹 7. Ap...

Which Database to Use, How to Decide?

  1. First ask these key questions Before choosing any database, be clear on: Data type → structured (tables) or unstructured (JSON, files) Scale → small app or millions of users Read vs Write → more reading or more writing Consistency vs Speed Relationships → complex joins needed or not 🧱 What is Structured Data? 👉 Structured data = data with a fixed format (schema) Stored in tables (rows & columns) Each field has a defined type Same structure for every record id name age salary 1 Ram 25 30000 2 Shyam 30 40000 👉 Here: Every row follows the same format Columns are fixed → id, name, age, salary Stored in: MySQL PostgreSQL 🧩 What is Unstructured Data? 👉 Unstructured data = no fixed format (“Unstructured means random data”) Data can vary for each record No strict schema Can be text, JSON, images, videos 📌 Example (JSON) {   "name": "Ram",   "age": 25 } {   "name": "Shyam",   "address...

Python - Variable

       🧠 Python Variables (in Python ) A variable is a name used to store data in memory. Creating a variable In Python, you don’t need to declare a type. x = 10 name = "Shivam" price = 99.5 👉 Python automatically understands the data type. 🔹 Rules for variable names ✔ Must start with a letter or _ ✔ Can contain letters, numbers, _ ❌ Cannot start with a number ❌ Cannot use keywords like if , for , class ✔ Valid age = 25 _user = "abc" total_amount = 100 ❌ Invalid 1name = "abc"   # ❌ class = 10      # ❌ keyword 🔹 Assigning multiple variables a, b, c = 1, 2, 3 🔹 Changing value (dynamic typing) x = 10 x = "Hello"   # type changed automatically 🔹 Check type x = 10 print(type(x))   # <class 'int'> 🔹 Variable types (basic) a = 10        # int b = 3.14      # float c = "Hello"   # string d = True      # boolean ⚠️ Common mistakes x = 10 print(X)...

Python Indentation

  🧠 Python Indentation (very important in Python ) In Python, indentation is not optional —it defines the structure of your code (instead of {} like in Java/C++).  What is indentation? Indentation means spaces at the beginning of a line . Python uses indentation to define blocks of code (like inside if , for , functions, etc.). 📏 Rules of indentation Use  4 spaces  (standard practice) Be consistent (don’t mix tabs and spaces) All lines in same block must have same indentation 🧠 Simple understanding Tab = shortcut key for indentation Spaces = actual characters (recommended in Python) 🔹 Basic Example if True:     print("Hello")   # indented → inside if block print("Outside")     # not indented → outside block ❌ Wrong (will give error) if True: print("Hello")   # ❌ no indentation 👉 Error: IndentationError 🔹 Example with loop for i in range(3):     print(i)     print("Loop running") print("...

Comments in Python

  📝 What are comments in Python ? Comments are lines in code that are ignored by the interpreter . They are used to explain code for humans.  1. Single-line comments Use # # This is a comment print("Hello")  # This is also a comment ✔ Used for short explanations ✔ Most common type 2. Multi-line comments (not official, but used) Python doesn’t have real multi-line comment syntax like other languages. Method 1: Multiple # # This is line 1 # This is line 2 # This is line 3 Method 2: Triple quotes (doc-style, not true comments) """ This looks like a comment but actually it's a string """ ⚠ This works only if not assigned to a variable (otherwise it's a string). 3. Docstrings (special comments for documentation) Used inside functions, classes, modules: def add(a, b):     """This function returns sum of two numbers"""     return a + b