It skips hydrating full Mongoose documents and returns plain JS objects. Faster when you only need to send JSON to the client, since you skip building model instances and virtuals.
Express Server Performance Tips for Production
What does Mongoose lean() do?
The answer
More FAQs in Express Server Performance Tips for Production
Use cluster or PM2, add compression middleware, cache with Redis, use DB connection pooling, keep handlers async, use Mongoose lean queries, add indexes in MongoDB, stream large responses, limit payload size, and use HTTP/2 with Nginx.
PM2 spawns one worker per CPU, restarts on crash, and lets you reload without downtime. It keeps the server alive and uses all available cores. PM2 is a small addition with big production payoff.
express.json({ limit: '10kb' }) prevents oversized payload attacks. Without a limit, a malicious client can send huge bodies, eating memory and slowing the server down.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.