Node.js服务器服务于普通网站或仅用于后端

时间:2022-01-24 17:02:05

I'm studying node.js for a new website, that will have some real time functionality, for which I will use Socket.IO. You can use node.js for both the real time functionality and serving your normal website's files, such as HTML, CSS and JavaScript.

我正在研究node.js的新网站,它将具有一些实时功能,我将使用Socket.IO。您可以将node.js用于实时功能并提供普通网站的文件,例如HTML,CSS和JavaScript。

My questions are: is it better to have them on the same host (es. Heroku), so that node.js serves the files and work as a back end server; or to have the back end functionality as a node.js server on an host and the files' server on another, dedicated, one? Which solution is usually better in term of performance? and which one is usually a cheaper solution (just in term of hosting, not for implementing the file serving in node)?

我的问题是:将它们放在同一主机(例如Heroku)上会更好,这样node.js就可以提供文件并作为后端服务器使用;或者将后端功能作为主机上的node.js服务器和另一个专用的文件服务器?哪种解决方案在性能方面通常更好?哪一个通常是一个更便宜的解决方案(只是在托管方面,而不是实现节点中的文件服务)?

Both the website and the node.js server would not be really big.

网站和node.js服务器都不会很大。

This are the two possible solutions that came to my mind, if you use other, better, ones, feel free to suggest them.

这是我想到的两种可能的解决方案,如果您使用其他更好的解决方案,请随时提出建议。

Thank you.

谢谢。

1 个解决方案

#1


3  

Keep the setup simple; there's no reason to separate the two, especially given that neither half seem to be very large or sophisticated.

保持设置简单;没有理由将两者分开,特别是考虑到两者都不是很大或很复杂。

#1


3  

Keep the setup simple; there's no reason to separate the two, especially given that neither half seem to be very large or sophisticated.

保持设置简单;没有理由将两者分开,特别是考虑到两者都不是很大或很复杂。