5 exercises — core backend terms: middleware, caching, ORM, idempotency, and the N+1 query problem. Essential vocabulary for backend interviews and team discussions.
In backend development, middleware is best described as:
Middleware is a function in a request pipeline that can inspect, transform, or terminate a request/response — it runs before the final route handler. Examples: authentication middleware (checks the JWT), logging middleware (records the request), rate-limiting middleware, CORS middleware. In Express.js: app.use(myMiddleware). In Django: MIDDLEWARE = [...]. The term can also refer to infrastructure middleware (message brokers, API gateways), but in backend code the most common meaning is "pipeline layer".
2 / 5
Complete the sentence using the correct backend term: "To avoid overloading the database, we added a _____ layer using Redis so that frequently-requested data is served without hitting the DB every time."
Caching — storing the result of an expensive operation so future requests can be served from the fast cache instead of re-computing. Redis and Memcached are the most common caching solutions. Related terms: cache invalidation (the hard problem — deciding when to expire/update cached data); cache hit/miss (hit = found in cache; miss = had to fetch from DB); TTL (Time To Live — how long a cache entry lives); write-through vs. write-behind (when the cache is updated relative to the DB). Load balancing distributes traffic; sharding splits a database; indexing speeds up queries — all distinct.
3 / 5
What is an ORM (Object-Relational Mapper)?
An ORM maps database tables to objects in the application language, allowing queries like User.findAll({ where: { active: true } }) instead of raw SQL. Popular ORMs: Sequelize (Node.js), Prisma (Node.js), SQLAlchemy (Python), Django ORM (Python), Hibernate (Java), ActiveRecord (Ruby). Trade-offs: ORMs reduce boilerplate and SQL injection risk, but can generate inefficient queries and abstract away performance-critical details. Schema migration tools (like Alembic, Flyway, Liquibase) are a separate concern — though many ORMs include migration features.
4 / 5
In the context of APIs, what does idempotency mean?
Idempotency: performing the same operation multiple times has the same effect as performing it once. HTTP method idempotency: GET, PUT, DELETE, HEAD are idempotent (calling them again doesn't change state). POST is NOT idempotent (sending the same POST twice creates two resources). Why it matters: in distributed systems, network retries can cause operations to execute more than once. Idempotent operations are safe to retry. Related: Idempotency-Key header — used in payment APIs (Stripe) to safely retry a charge without double-charging.
5 / 5
What is N+1 query problem in backend development?
The N+1 problem: 1 query to get N records, then N separate queries to get related data for each record — N+1 total. Example: fetch 100 users (1 query), then for each user fetch their profile (100 queries) = 101 queries instead of 2. Fix: use eager loading (JOIN or include in ORM), or a DataLoader pattern (batch + cache). This is one of the most common backend performance problems and a frequent interview question. ORMs make N+1 easy to accidentally create because the lazy-loading behaviour is implicit.