Node.js · Senior · Question 12 of 75
Why can JSON.stringify of a large response be a bottleneck, and what helps?
- 1It can't handle objects bigger than 1 MB
- ✓Correct answer: It's synchronous and CPU-heavy; schema-based serializers (like Fastify's) or streaming JSON reduce the cost
- 3It runs on the network thread and blocks sockets
Explanation
Fastify compiles a serializer from the response schema, which is faster and also drops fields not in the schema. For huge lists, paginate or stream.