Skip to content

02 Backend Questions

Backend interviews me architecture, database aur API design par focus hota hai.

Node.js πŸš€

Q1: Node.js Single Threaded hai ya Multi-threaded?

Technically Node.js ka Event Loop Single Threaded hai. Lekin heavy kaam (File I/O, Cryptography) ke liye ye C++ walebLibuv thread pool ka use karta hai jo multi-threaded hai. Isliye Node.js non-blocking hai.

Q2: process.nextTick() vs setImmediate()?

  • process.nextTick(): Ye current operation khatam hote hi turant chalta hai (sabse pehle).
  • setImmediate(): Ye Event Loop ke agle cycle (check phase) me chalta hai.

Q3: Streams kya hain?

Badi data handling ke liye. Poori file memory me load karne ki bajaye, streams data ko chunks (tukdon) me read/write karte hain. Example: YouTube video buffering.


Express.js πŸš‚

Q4: Middleware kya hota hai?

Ye ek function hai jo Request aur Response ke beech me aata hai. req -> Middleware -> res Use Cases: Authentication check, Error handling, Logging.

Q5: app.use() kya karta hai?

Ye global middleware lagane ke liye use hota hai. Jo har request par chalega.

app.use(express.json()); // Har req ki body parse karega

MongoDB πŸƒ

Q6: SQL vs NoSQL me kya farak hai?

  • SQL (MySQL): Table based, fixed schema (Structure change karna mushkil). Relations (Joins) strong hote hain.
  • NoSQL (MongoDB): Document based (JSON), flexible schema. Badi data aur speed ke liye acha hai.

Q7: Indexing kyun zaroori hai?

Bina index ke MongoDB ko poora collection scan karna padta hai (COLLSCAN) jo slow hai. Indexing se wo seedha data tak pahunch jata hai (IXSCAN).

Q8: Aggregation Pipeline kya hai?

Data ko process karne ka tareeka. Multiple stages hoti hain: $match (Filter) -> $group (Count/Sum) -> $sort (Order).


API Design 🌐

Q9: PUT vs PATCH me kya difference hai?

  • PUT: Poora resource replace karta hai.
  • PATCH: Sirf changed hissa update karta hai.

Q10: Status Codes ka matlab?

  • 200: OK (Success).
  • 201: Created (New data bana).
  • 400: Bad Request (Client ki galti).
  • 401: Unauthorized (Login nahi kiya).
  • 403: Forbidden (Login hai par permission nahi).
  • 500: Internal Server Error (Server phat gaya).

Tip: System Design questions ke liye β€œScalability” aur β€œDatabase Chunks” words use karein! πŸ—οΈ