Performance
Seventeenth chapter of the "Fastify with TypeScript" series. Fastify is already fast by default, but a few architectural choices make a huge difference under real-world load, and most of them are things we've already done in this series for other reasons. This chapter names them, shows what a blocked event loop looks like, and adds the one piece that is still missing: knowing when the process is in trouble.
1. Response schemas: for safety first
For years the first performance tip for Fastify was "always define a response schema", because fast-json-stringify , the library that serializes through the schema, beat JSON.stringify . JavaScript engines have moved since then: the engine's own JSON.stringify has become very fast, and with its default settings the schema-based serializer is no longer faster on objects.
Keep the response schemas anyway.…