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

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

问题描述

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

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 解决方案对我来说似乎更易于管理,有什么想法吗?

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

推荐答案

我不得不不同意这里的答案.虽然 Node 会做得很好,但如果配置正确,nginx 肯定会更快.nginx 在 C 中按照类似的模式(仅在需要时返回连接)以极小的内存占用有效地实现.此外,它支持 sendfile 系统调用以尽可能快地处理这些文件开始提供文件,因为是操作系统内核本身在做这项工作.

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.

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

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.:这假设文件确实是静态的",就像在请求时磁盘上的静止文件一样.

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天全站免登陆