node.js本身还是用于服务静态文件的nginx前端? [英] node.js itself or nginx frontend for serving static files?

查看:207
本文介绍了node.js本身还是用于服务静态文件的nginx前端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有更快的基准测试或比较:将nginx放在节点前面,让它直接提供静态文件,还是仅使用node并使用它提供静态文件?

nginx解决方案对我来说似乎更易于管理,有什么想法吗?

解决方案

在这里,我将不同意答案.尽管Node可以正常运行,但是如果配置正确,nginx肯定会更快. nginx以相似的模式(仅在需要时返回连接)以很小的内存占用量在C中高效实现.此外,它支持 sendfile 系统调用来尽快提供这些文件.开始提供文件,因为完成工作的是OS内核本身.

现在,nginx已经成为事实上的标准,成为前端服务器.稍后,您可以使用它来提供静态文件,gzip,SSL甚至负载平衡的性能.

P.S .:假设文件实际上是静态的",就像在请求时位于磁盘上一样.

Is there any benchmark or comparison which is faster: place nginx in front of node and let it serve static files directly or use just node and serve static files using it?

nginx solution seems to be more manageable for me, any thoughts?

解决方案

I'll have to disagree with the answers here. While Node will do fine, nginx will most definitely be faster when configured correctly. nginx is implemented efficiently in C following a similar pattern (returning to a connection only when needed) with a tiny memory footprint. Moreover, it supports the sendfile syscall to serve those files which is as fast as you can possibly get at serving files, since it's the OS kernel itself that's doing the job.

By now nginx has become the de facto standard as the frontend server. You can use it for its performance in serving static files, gzip, SSL, and even load-balancing later on.

P.S.: This assumes that files are really "static" as in at rest on disk at the time of the request.

这篇关于node.js本身还是用于服务静态文件的nginx前端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆