是节点。对于成千上万人使用的web应用程序来说,js是一个不错的选择,但是只有其中一些人能够访问相同的数据

时间:2022-01-28 05:51:03

I'm trying to decide whether it's worth the time to invest into learning Node.js for a new program. The biggest benefit AFAIU is that Node makes the process of multiple users accessing the same data more efficient than using Apache and PHP.

我在考虑是否值得花时间在学习节点上。一个新的程序。AFAIU最大的好处是,节点使多个用户访问相同数据的过程比使用Apache和PHP更有效。

The program is meant to be used by groups, with all the data stored on our dedicated server. That said, the same data would be accessed by at most all the members of one group (up to 20), but the database itself might be accessed by anyone using the program (for fun, let's say up to 1 million).

该程序将由组使用,所有数据存储在我们的专用服务器上。也就是说,一个组的所有成员最多可以访问相同的数据(最多可以访问20个),但是任何使用这个程序的人都可以访问这个数据库(为了好玩,假设最多可以访问100万个)。

My idea of concurrency is basic at best. Would Node.js improve the experience for the groups (since they are accessing the same data), or for everyone (since they are accessing the same database)? Alternatively, is such a set-up even taking advantage of Node's benefits?

我对并发性的理解至多是最基本的。将节点。js提高了组的体验(因为他们访问相同的数据),或者对每个人(因为他们访问相同的数据库)?或者,这样的设置是否利用了Node的优点?

2 个解决方案

#1


2  

The answer is "probably".

答案是“可能”。

It sounds like you should play with Node and learn its strengths and weaknesses. Node excels at high throughput 'realtime' network services, as such there is almost always a use-case for Node in any web project. For your project this might mean handling web socket/ajax requests, or perhaps you'll boot up a node cluster to handle processing of tasks as a background service.

听起来你应该学习Node,了解它的优缺点。Node擅长于高吞吐量的“实时”网络服务,因此在任何web项目中几乎都有一个Node用例。对于您的项目,这可能意味着要处理web套接字/ajax请求,或者您将启动节点集群,以作为后台服务处理任务。

Like all tech, Node doesn't solve every problem and other technologies will (probably) get certain tasks done faster. It's about learning enough to know when to deploy Node (and when you might consider another tool).

像所有的技术一样,Node并不能解决所有的问题,其他技术(可能)会更快地完成某些任务。这是关于了解何时部署Node(以及何时考虑使用其他工具)。

At worst, you'll learn more about javascript; knowledge you can re-use on a myriad of devices, and every web browser. At best you'll learn to use a great tool that fits your needs.

在最坏的情况下,您将了解更多关于javascript的知识;你可以在无数的设备和每个web浏览器上重用知识。最好的情况是你会学会使用一个适合你需要的工具。

Also: your understanding of "multiple users accessing the same data" is incorrect. Yes, Node is good at many concurrent users/connections, but Node has no care (DNGAF) for what data you're accessing. That would be handled by your database or caching layer.

同样:您对“多个用户访问相同数据”的理解是不正确的。是的,Node擅长于许多并发用户/连接,但是Node对您正在访问的数据毫不在意(DNGAF)。这将由您的数据库或缓存层来处理。

#2


1  

Based on your description, you really don't need node, or any specific server stack so much as intelligent caching of data. There is nothing inherent in node which will make this easier than php, ruby, .net, etc.

根据您的描述,您确实不需要节点或任何特定的服务器堆栈,而需要智能数据缓存。在node中没有什么比php、ruby、.net等更简单的东西了。

The benefit you're referring to is likely that node can handle multiple concurrent requests very well and it can handle long requests that wait on IO well since node doesn't hang on IO (meaning the server can continue to handle other requests).

您所提到的好处很可能是node可以很好地处理多个并发请求,并且它可以处理IO上等待的长请求,因为节点不挂在IO上(这意味着服务器可以继续处理其他请求)。

If you want to learn node, GO FOR IT! I am working with it personally and I love it, but it isn't a magic bullet and if you are already invested in a server stack, you would probably be better served using that and spending your time learning about efficient caching.

如果你想学习node,那就去学吧!我个人也在使用它,我很喜欢它,但它并不是一颗魔弹,如果您已经在服务器堆栈中进行了投资,您可能会更好地使用它,并花时间学习高效缓存。

#1


2  

The answer is "probably".

答案是“可能”。

It sounds like you should play with Node and learn its strengths and weaknesses. Node excels at high throughput 'realtime' network services, as such there is almost always a use-case for Node in any web project. For your project this might mean handling web socket/ajax requests, or perhaps you'll boot up a node cluster to handle processing of tasks as a background service.

听起来你应该学习Node,了解它的优缺点。Node擅长于高吞吐量的“实时”网络服务,因此在任何web项目中几乎都有一个Node用例。对于您的项目,这可能意味着要处理web套接字/ajax请求,或者您将启动节点集群,以作为后台服务处理任务。

Like all tech, Node doesn't solve every problem and other technologies will (probably) get certain tasks done faster. It's about learning enough to know when to deploy Node (and when you might consider another tool).

像所有的技术一样,Node并不能解决所有的问题,其他技术(可能)会更快地完成某些任务。这是关于了解何时部署Node(以及何时考虑使用其他工具)。

At worst, you'll learn more about javascript; knowledge you can re-use on a myriad of devices, and every web browser. At best you'll learn to use a great tool that fits your needs.

在最坏的情况下,您将了解更多关于javascript的知识;你可以在无数的设备和每个web浏览器上重用知识。最好的情况是你会学会使用一个适合你需要的工具。

Also: your understanding of "multiple users accessing the same data" is incorrect. Yes, Node is good at many concurrent users/connections, but Node has no care (DNGAF) for what data you're accessing. That would be handled by your database or caching layer.

同样:您对“多个用户访问相同数据”的理解是不正确的。是的,Node擅长于许多并发用户/连接,但是Node对您正在访问的数据毫不在意(DNGAF)。这将由您的数据库或缓存层来处理。

#2


1  

Based on your description, you really don't need node, or any specific server stack so much as intelligent caching of data. There is nothing inherent in node which will make this easier than php, ruby, .net, etc.

根据您的描述,您确实不需要节点或任何特定的服务器堆栈,而需要智能数据缓存。在node中没有什么比php、ruby、.net等更简单的东西了。

The benefit you're referring to is likely that node can handle multiple concurrent requests very well and it can handle long requests that wait on IO well since node doesn't hang on IO (meaning the server can continue to handle other requests).

您所提到的好处很可能是node可以很好地处理多个并发请求,并且它可以处理IO上等待的长请求,因为节点不挂在IO上(这意味着服务器可以继续处理其他请求)。

If you want to learn node, GO FOR IT! I am working with it personally and I love it, but it isn't a magic bullet and if you are already invested in a server stack, you would probably be better served using that and spending your time learning about efficient caching.

如果你想学习node,那就去学吧!我个人也在使用它,我很喜欢它,但它并不是一颗魔弹,如果您已经在服务器堆栈中进行了投资,您可能会更好地使用它,并花时间学习高效缓存。