NoteTube

3. What is a Backend, how do they work and why do we need them?
19:01

3. What is a Backend, how do they work and why do we need them?

Sriniously

5 chapters6 takeaways20 key terms5 questions

Overview

This video explains the fundamental concept of a backend in web development. It details how a backend server functions, from receiving requests via domain names and IP addresses, through firewalls, to reverse proxies like Nginx, and finally to the application server. The video emphasizes the crucial role of backends in managing data, handling complex logic, and ensuring security, contrasting their capabilities with the limitations of frontends. It highlights why backends are essential for tasks like data persistence, real-time notifications, and efficient database interactions, which cannot be reliably or securely performed on the client-side.

How was this?

Save this permanently with flashcards, quizzes, and AI chat

Chapters

  • A backend is a computer that listens for incoming requests (HTTP, WebSocket, gRPC) on open ports accessible over the internet.
  • It serves content (static files, JSON) and accepts data from clients or frontends.
  • It's called a 'server' because it 'serves' resources and functionality.
  • Backends are essential for processing requests and managing data that frontends cannot handle.
Understanding the basic definition of a backend is crucial for grasping its role in the client-server architecture of the web.
A backend server listening on port 443 for HTTPS requests from a browser.
  • A request starts with a domain name, which is resolved by a DNS server to an IP address.
  • The IP address typically points to a cloud instance (e.g., AWS EC2) where the backend is hosted.
  • Before reaching the instance, requests pass through firewalls (e.g., AWS Security Groups) that must allow specific ports (like 80 for HTTP, 443 for HTTPS).
  • A reverse proxy (like Nginx) often sits in front of the application server, managing traffic, SSL certificates, and routing requests to the correct application port (e.g., 3001 for a Node.js app).
Tracing the path of a request reveals the complex infrastructure and security measures that ensure data reaches the intended backend server reliably.
A DNS record mapping 'backend-demo.senus.xyz' to an AWS EC2 instance's public IP address, with Nginx on the instance forwarding requests from port 80 to port 3001.
  • Backends are needed to manage and persist data, such as user information, actions, and application state.
  • They handle complex logic and interactions that occur between user actions and system responses (e.g., liking a post and triggering a notification).
  • A centralized backend holds all necessary information about all users and the system's state, unlike personalized frontends.
  • The core responsibility of a backend revolves around fetching, receiving, and persisting data, and performing actions related to that data.
This highlights the fundamental purpose of a backend: to be the reliable, centralized source of truth and logic for an application.
When a user likes a post on Instagram, the backend server saves this action, identifies the post owner, and triggers a notification to be sent to them.
  • Frontends (like Next.js apps) are fetched by the browser as HTML, CSS, and JavaScript files.
  • The browser then executes this code on the client's machine, rendering the UI and handling user interactions.
  • Unlike backends where processing happens on the server, frontends delegate execution to the client's browser.
  • Browsers are sandboxed environments, limiting access to the operating system, file system, and external resources due to security policies like CORS.
Understanding where code executes (server vs. client) is key to appreciating the distinct roles and limitations of frontends and backends.
A browser downloading JavaScript files for a Next.js application and then executing them locally to make buttons interactive.
  • Security: Browsers restrict access to sensitive resources like file systems and environment variables, making them unsuitable for backend operations.
  • API Access: Frontend JavaScript faces Cross-Origin Resource Sharing (CORS) restrictions, limiting its ability to call arbitrary external APIs without specific server configurations.
  • Database Interaction: Browsers lack native drivers and efficient connection management (like connection pooling) required for direct, high-volume database communication.
  • Computing Power: Client devices have variable and often limited processing power, making them unreliable for heavy business logic that needs consistent performance.
These limitations explain why certain functionalities *must* reside on a backend server for security, reliability, and performance reasons.
A browser being blocked by CORS policy from directly accessing a third-party API that doesn't explicitly allow requests from the frontend's domain.

Key takeaways

  1. 1Backends are the computational engines behind web applications, responsible for data management and complex processing.
  2. 2The journey of a web request involves multiple layers: DNS, IP addressing, firewalls, and reverse proxies before reaching the application.
  3. 3Centralized data storage and management on the backend are essential for application consistency and user experience.
  4. 4Frontends execute code in the client's browser, while backends execute code on a server.
  5. 5Browser security sandboxing and restrictions (like CORS) prevent frontends from performing many critical backend tasks.
  6. 6Efficient database interaction, secure access to resources, and scalable computing power necessitate dedicated backend servers.

Key terms

BackendFrontendServerRequestResponseHTTPWebSocketgRPCPortDNSIP AddressAWS EC2FirewallSecurity GroupReverse ProxyNginxSSL CertificateLocalhostDatabaseCORS

Test your understanding

  1. 1What is the primary function of a backend server in a web application?
  2. 2Describe the sequence of events and infrastructure components involved when a user's browser sends a request to a backend server.
  3. 3Why is it not feasible or secure to perform all application logic, such as database interactions, directly from the frontend?
  4. 4How do security measures like browser sandboxing and CORS policy influence the division of labor between frontends and backends?
  5. 5What role does a reverse proxy like Nginx play in the request flow to a backend application?

Turn any lecture into study material

Paste a YouTube URL, PDF, or article. Get flashcards, quizzes, summaries, and AI chat — in seconds.

No credit card required