Fastify 高性能 Node.js 服务实践
import Fastify from 'fastify'
const app = Fastify({ logger: true })
app.get('/api/ping', async (req, reply) => {
return { ok: true }
})
app.listen({ port: 3000, host: '0.0.0.0' })
要点
- 内置高性能序列化与插件体系
- 使用 `logger` 观察吞吐与错误,结合进程管理确保稳定性
总结
Fastify 在 Node.js 场景下具备优异性能与易扩展能力,适合网关与服务层 API。

发表评论 取消回复