What is the difference between Fastify and Express?
Why Interviewers Ask This
This is a differentiating question used for senior and lead roles. Interviewers want to see if you can explain not just what happens, but why — and what the trade-offs are in different approaches.
Answer
Express and Fastify are both Node.js web frameworks but with different design philosophies. Express (2010): minimal, widely adopted, huge ecosystem, synchronous middleware model, no built-in schema validation, no built-in serialization — it's the "safe" choice with the most tutorials, plugins, and community support. Fastify (2016): designed for performance from the ground up. Key differences: (1) Performance: Fastify is 2-4x faster than Express in benchmarks — it uses fast-json-stringify for serialization and find-my-way for routing; (2) Schema validation: Fastify has first-class JSON Schema support for request validation and response serialization (faster + safer); (3) Async/await: Fastify natively supports async route handlers without the wrapper pattern Express requires; (4) Plugins: Fastify uses an encapsulated plugin system with fastify-plugin for dependency scoping; (5) TypeScript: Fastify has excellent TypeScript support out of the box; (6) Error handling: more consistent async error propagation. Choose Express for familiarity/ecosystem; choose Fastify for performance-critical services or greenfield projects.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.
Previous
What is HTTP/2 and does Node.js support it?
Next
What is a Proxy in Node.js and how is it used?
More Node.js Questions
View all →- Advanced How does Node.js handle concurrency without multiple threads?
- Advanced What is the Node.js memory model and how does garbage collection work?
- Advanced What are memory leaks in Node.js and how do you detect them?
- Advanced What is the difference between process.exit() and throwing an uncaught exception?
- Advanced What is the N+1 query problem and how do you solve it in Node.js?