Back-End Development Basics of Back End Development 4 — Questions and Answers
Question 1: What is the purpose of database indexing?
- To enforce data type constraints on columns
- To speed up data retrieval by creating a fast-lookup data structure (Correct answer)
- To replicate data to a secondary server automatically
- To compress table rows to reduce storage size
Correct answer: To speed up data retrieval by creating a fast-lookup data structure
An index creates an auxiliary data structure (often a B-tree) that allows the database engine to find matching rows without scanning the entire table.
Question 2: Which design pattern separates an application into three concerns: data, business logic, and presentation?
- Singleton
- Observer
- MVC (Model-View-Controller) (Correct answer)
- Factory
Correct answer: MVC (Model-View-Controller)
MVC divides responsibility into the Model (data/business logic), View (presentation), and Controller (input handling), making code easier to maintain and test.
Question 3: What does the term 'N+1 query problem' refer to in back-end development?
- Running one query to fetch a list and then one additional query per list item (Correct answer)
- Executing a query with more than N join conditions
- Sending N identical queries to N different database replicas
- Writing a query that returns N+1 rows due to an off-by-one error
Correct answer: Running one query to fetch a list and then one additional query per list item
The N+1 problem occurs when code fetches a list of N items and then lazily runs a separate query for each, resulting in N+1 total queries that could be replaced by a single JOIN or eager load.
Question 4: Which of the following is a key benefit of using a message queue (e.g., RabbitMQ, SQS) in a back-end system?
- It eliminates the need for a database
- It decouples producers and consumers, allowing asynchronous processing (Correct answer)
- It provides end-to-end encryption for all API calls
- It replaces HTTP as the transport protocol between services
Correct answer: It decouples producers and consumers, allowing asynchronous processing
Message queues allow services to communicate without being tightly coupled, letting producers and consumers operate at different speeds and fail independently.
Question 5: What is the purpose of a reverse proxy like Nginx in a back-end setup?
- Directly executing application code on behalf of the server
- Sitting in front of application servers to handle routing, SSL, and load balancing (Correct answer)
- Replacing the database layer with in-memory storage
- Converting HTTP requests to binary protocol for faster transmission
Correct answer: Sitting in front of application servers to handle routing, SSL, and load balancing
A reverse proxy receives client requests and forwards them to one or more backend servers, also handling SSL termination, caching, and load distribution.
Question 6: In the context of back-end APIs, what is rate limiting?
- Limiting the size of JSON payloads a server will accept
- Restricting the number of requests a client can make in a given time period (Correct answer)
- Capping the maximum query execution time in the database
- Throttling CPU usage per Node.js worker process
Correct answer: Restricting the number of requests a client can make in a given time period
Rate limiting controls how many requests a client (identified by IP, API key, or user) can make within a window, protecting the server from abuse and ensuring fair usage.
Question 7: Which data serialization format is most commonly used for REST API request and response bodies?
- XML
- CSV
- YAML
- JSON (Correct answer)
Correct answer: JSON
JSON (JavaScript Object Notation) is the dominant format for REST APIs due to its lightweight syntax, human readability, and native support in browsers and most languages.
What is the purpose of database indexing?