Backend Developer interview questions
100 real questions with model answers and explanations for Junior candidates.
See a Backend Developer resume example →Questions
REST is an architectural style for networked APIs built on HTTP.
- Stateless: each request carries all the information the server needs.
- Uniform interface: consistent resource naming and standard HTTP methods.
- Client-server separation, cacheability, and a layered system, with optional code on demand.
- In practice: expose resources as URLs like /users/42, GET to read, POST to create, no server-side session state.
Why interviewers ask this: The interviewer checks whether you understand REST as an architectural style with specific rules, not just any HTTP API.
PUT replaces a resource entirely, PATCH updates only part of it.
- PUT: send the full representation, the server overwrites whatever exists.
- PATCH: send only the fields that need to change.
- Example: updating an email with PUT needs the whole user object, PATCH needs just the email field.
- PATCH avoids accidentally wiping fields the client did not mean to change.
Why interviewers ask this: This tests whether you understand HTTP semantics precisely, which matters when designing APIs that clients rely on.
Pick status codes by their semantic meaning, not 200 for everything.
- 201 Created for a successful creation, usually with the new resource in the body.
- 404 Not Found for a missing resource.
- 400 Bad Request for a validation error, with a body describing what failed.
- 500 Internal Server Error for an unhandled server-side crash.
- Correct codes let clients handle failures programmatically without parsing messages.
Why interviewers ask this: Interviewers want to see that you pick status codes semantically rather than returning 200 for everything or guessing.
The server issues a signed token after login and verifies it on each request.
- The token has three parts: a header, a base64 payload with claims like user ID and expiry, and a signature.
- The client sends it in the Authorization header on later requests.
- The server verifies the signature with its secret key, so it trusts the payload without a database lookup.
- Because JWTs are self-contained, they suit stateless APIs.
Why interviewers ask this: A strong answer shows you understand the three-part structure, the signing mechanism, and the stateless benefit, not just that JWTs are used for auth.
Authentication proves who you are, authorization decides what you may do.
- Authentication: checking a password or validating a token.
- Authorization: granting permissions once identity is confirmed.
- Example: verifying a JWT is authentication, checking the admin role before a delete is authorization.
- A common mistake is conflating them, so endpoints identify users but never check permissions.
Why interviewers ask this: This is a foundational security concept, and interviewers use it to filter candidates who understand security in layers.
A foreign key references another table's primary key to enforce referential integrity.
- Example: an orders table has a user_id pointing to the users table.
- It prevents orphaned records, like an order for a user who no longer exists.
- The database rejects inserts or updates that would break the constraint.
- This is safer than enforcing the rule only in application code.
Why interviewers ask this: The interviewer checks that you understand relational data modeling beyond writing SELECT queries.
An index is a data structure that finds matching rows without scanning the whole table.
- It is usually a B-tree built on one or more columns.
- Add an index on columns used often in WHERE, JOIN, or ORDER BY.
- Every index slows down INSERT, UPDATE, and DELETE because it must be updated too.
- So add indexes selectively, where read performance matters most.
Why interviewers ask this: A good answer names both the read benefit and the write cost, showing you think about trade-offs, not just speedups.
N+1 happens when you load N records and then run one extra query per record for related data.
- Example: loading 100 posts and querying the author for each gives 101 queries.
- Fix it by loading related data in a single join or one bulk query.
- Most ORMs offer eager loading, like include in Sequelize or select_related in Django.
- That collapses the work into one or two queries.
Why interviewers ask this: This is a very common performance problem in real projects, and interviewers use it to assess whether you think about the SQL your code generates.
SQL uses fixed-schema tables, NoSQL uses flexible schemas and varied data models.
- SQL: tables with a fixed schema and structured queries for joins, aggregations, and transactions.
- NoSQL: document stores like MongoDB, key-value stores like Redis, column-family stores like Cassandra.
- SQL fits relational data with strict consistency needs.
- NoSQL often trades some ACID guarantees for horizontal scalability or schema flexibility.
- At junior level, start with a relational database unless there is a clear reason not to.
Why interviewers ask this: A strong answer goes beyond naming examples to explaining when you would choose each model.
Middleware is a function in the request-response pipeline that runs before or after your route handler.
- It can read or modify the request, call the next middleware, or short-circuit with a response.
- Common uses: parsing JSON bodies, verifying auth tokens, logging requests, handling CORS.
- In Express it receives (req, res, next) and must call next() to continue the chain.
Why interviewers ask this: Understanding middleware is fundamental to building real applications in any framework, so interviewers check both the concept and a concrete example.
A process is an independent program with its own memory, a thread shares memory within a process.
- A process has its own memory space managed by the OS.
- A thread is a smaller unit of execution sharing memory with other threads in the same process.
- Threads communicate easily via shared variables but can corrupt shared state without synchronization.
- Node.js runs on a single thread but can spawn worker threads or child processes for CPU-heavy tasks.
Why interviewers ask this: This tests your understanding of OS fundamentals that directly affect how your backend handles concurrency.
Async programming lets a program start an operation, keep running, and handle the result later without blocking.
- A synchronous blocking model would stall the server waiting for each database query.
- Async I/O lets a single thread serve many requests by yielding control while waiting on network or disk.
- In Node.js it is the default model; in Python you use asyncio.
Why interviewers ask this: The interviewer is checking whether you understand why async matters at a systems level, not just the syntax.
HTTPS is HTTP layered over TLS, encrypting traffic and verifying the server's identity.
- The client and server perform a TLS handshake on connection.
- The server presents a certificate, the client verifies it against a trusted certificate authority.
- They negotiate a symmetric key, and all later data is encrypted with it.
- This blocks eavesdropping and impostors; backend devs configure certificates via Let's Encrypt or a cloud load balancer.
Why interviewers ask this: A good answer covers both encryption and certificate verification; weak answers only mention that data is encrypted.
CORS is a browser security mechanism that controls cross-origin requests from JavaScript.
- It restricts JS on one origin (domain and port) from calling a different origin.
- The browser sends an Origin header, and the server replies with Access-Control-Allow-Origin to list permitted origins.
- Without it, a malicious site could make authenticated requests using a visitor's cookies.
- You configure it on the backend; non-browser clients like Postman ignore it.
Why interviewers ask this: Understanding that CORS is enforced by the browser, not the server, shows a level of security awareness beyond just adding the header.
Caching stores the result of an expensive operation so later requests skip the work.
- Cache-aside: the app checks the cache first, on a miss reads the database, then writes the result back to the cache.
- Write-through: every write goes to both the cache and the database at once, keeping them in sync.
- Cache-aside is the most common pattern and pairs well with Redis for query results or rendered responses.
Why interviewers ask this: Naming a strategy and explaining its mechanics separates candidates who have actually implemented caching from those who only know it exists.
Redis is an in-memory key-value store with rich data types, used mainly for speed.
- It supports strings, hashes, lists, sets, and sorted sets.
- Caching: store query results with a TTL to avoid expensive recomputation.
- Session storage: keep session data without hitting the main database every request.
- Rate limiting: increment a counter per user per time window.
- Memory storage makes reads and writes microsecond-fast versus a relational database.
Why interviewers ask this: Strong answers give concrete use cases rather than just saying Redis is fast.
A migration is a versioned, code-based change to the database schema stored in your repository.
- Examples: adding a column or creating a table, written as code.
- Tools like Flyway, Liquibase, or Alembic apply them in order and track which ran.
- This makes schema changes reproducible, reviewable, and tied to a commit.
- Without migrations, manual changes are hard to replicate across staging, testing, and production.
Why interviewers ask this: The interviewer checks whether you treat schema changes as first-class engineering artifacts rather than ad hoc SQL commands.
A transaction groups SQL operations into one unit that all commits or all rolls back.
- Use it when several tables must change atomically, like debiting one account and crediting another.
- Start with BEGIN, run your statements, then COMMIT on success or ROLLBACK on failure.
- Most ORMs wrap the logic in try-catch helpers that roll back on any exception.
Why interviewers ask this: A strong answer includes why atomicity matters and how rollback prevents partial updates that corrupt data.
An operation is idempotent if calling it many times gives the same result as calling it once.
- GET, PUT, and DELETE are naturally idempotent; POST is not by default.
- It matters because network failures make clients retry, which could double-charge or create duplicates.
- Make a POST idempotent with a client-generated idempotency key.
- Check whether that key was already processed before performing the operation.
Why interviewers ask this: This shows the interviewer you think about distributed system failure modes, not just the happy path.
The join type decides which non-matching rows you keep.
- INNER JOIN returns only rows with matches in both tables.
- LEFT JOIN returns all left rows plus matches from the right; missing matches give null columns.
- RIGHT JOIN is the mirror: all right rows regardless of a match on the left.
- LEFT JOIN is most common, like all users including those with no orders yet.
Why interviewers ask this: Interviewers use this to verify you can write multi-table queries without guessing.
Locked questions
- 21
How do you manage secrets and environment variables securely in a backend project?
secretsconfig - 22
What is Docker and why is it useful for backend development?
docker - 23
What is a Dockerfile and what does it contain?
docker - 24
What is the difference between a Docker image and a container?
dockercontainers - 25
What is the feature branch Git workflow and how does it work?
git - 26
What is a pull request and what is its purpose beyond merging code?
code-review - 27
How do you write a unit test? What should a single test verify?
unit - 28
What is the difference between unit tests, integration tests, and end-to-end tests?
unitintegratione2e - 29
What is dependency injection and why is it useful?
injectiondependencies - 30
What is an ORM and what are its trade-offs?
orm - 31
How would you secure an API endpoint that should only be accessible to logged-in users?
endpoints - 32
What is SQL injection and how do you prevent it?
sqlinjection - 33
What is XSS and does it affect backend code?
xss - 34
What is a rate limiter and why would you add one to an API?
rate-limiting - 35
How do you handle errors in a REST API consistently?
restsoft-skills - 36
What is pagination and why is it necessary for list endpoints?
endpointspagination - 37
What is the difference between synchronous and asynchronous code in Node.js?
async - 38
What is the Node.js event loop?
event-loop - 39
What is the difference between a callback, a Promise, and async/await?
asyncpromisescallbacks - 40
How would you handle rejected Promises and async/await errors properly?
asyncpromises - 41
How would you design a basic user registration and login flow?
design - 42
Why is bcrypt used for storing passwords instead of MD5 or SHA-256?
passwords - 43
What is a refresh token and how does it differ from an access token?
tokens - 44
What is API versioning and how do you implement it?
versioning - 45
What is the difference between horizontal and vertical scaling?
scaling - 46
What is a message queue and when would you use one?
queues - 47
What is connection pooling in databases?
databasepooling - 48
What is the difference between eager loading and lazy loading in an ORM?
ormlazy-loading - 49
What is a composite index in SQL and when is it useful?
sqlindexes - 50
How do you debug a slow database query?
databasequeries - 51
What is the difference between WHERE and HAVING in SQL?
sql - 52
When would you use a subquery versus a JOIN?
joins - 53
What are HTTP headers and name three important ones for backend APIs?
http - 54
What is a webhook and how does it differ from polling?
webhooks - 55
How should you name REST API endpoints?
restendpoints - 56
What is the difference between a monolith and a microservices architecture?
microservicesmonolith - 57
What is a CI/CD pipeline and what does it automate?
ci-cd - 58
What is GitHub Actions and how have you used it in a project?
ci-cd - 59
What is linting and why does it matter in a backend project?
linting - 60
What do you look for when reviewing a teammate's pull request?
code-review - 61
How do you approach a bug you cannot reproduce locally?
- 62
What should you log in a backend service and at what log levels?
logging - 63
What is a health check endpoint and why is it useful?
health-checksendpoints - 64
What is load balancing and how does it relate to running multiple backend instances?
load-balancing - 65
What might cause a 502 Bad Gateway error and how would you debug it?
gateway - 66
What is the difference between a .env file and application config files?
config - 67
What is the singleton design pattern and where does it appear in backend code?
design - 68
What is memoization and how does it differ from general caching?
cachingmemoization - 69
What is a hash table and why are lookups O(1) on average?
data-structures - 70
What is recursion and when is an iterative approach preferred?
recursioniteration - 71
What is time complexity and how do you think about it when writing API handlers?
algorithms - 72
What causes a stack overflow error in a backend process?
memoryconcurrency - 73
What is garbage collection and why does it matter for backend performance?
gc - 74
What is serialization and deserialization in the context of a backend API?
serializationapi - 75
What is the difference between TCP and UDP and which does HTTP use?
http - 76
What is a DNS lookup and how does it fit into an HTTP request lifecycle?
http - 77
What is a CDN and does it apply to backend APIs?
api - 78
What is Postman and how do you use it during API development?
api - 79
How do you document an API for other developers?
api - 80
What is the OpenAPI (Swagger) specification?
openapi - 81
What is gRPC and how does it compare to REST for internal services?
restgrpc - 82
What is the difference between session-based authentication and JWT authentication?
authjwtsessions - 83
How would you add a non-nullable column to a large production table without downtime?
schema - 84
What is a soft delete and when would you use it?
soft-delete - 85
How do you handle file uploads in a backend API?
soft-skillsapi - 86
What is a background job and how would you schedule one?
jobs - 87
How would you implement offset-based pagination in a SQL query?
sqlqueriespagination - 88
What is a database deadlock and how can you avoid it?
databaselocking - 89
What is the difference between an index scan and a full table scan?
indexes - 90
What is a schema in a relational database?
databaseschema - 91
Tell me about a project where you had to learn something new to complete it.
story - 92
How do you prioritize tasks when you have multiple deadlines?
prioritization - 93
Describe a time you introduced a bug to a codebase. How did you handle it?
- 94
How do you approach reading and understanding an unfamiliar codebase?
learning - 95
How do you communicate a technical blocker to your team or manager?
communication - 96
What do you do when a code review suggests major changes to your work?
code-review - 97
How do you keep up with backend development trends and best practices?
learning - 98
Describe how you would onboard yourself to a new backend project in your first week.
onboarding - 99
What is technical debt and how do you handle it as a junior developer?
soft-skillstech-debt - 100
Where do you want to grow as a backend developer in the next year?
growth