使用Socket.io连接Node.js服务器和Golang服务器的缺点是什么?

huangapple go评论94阅读模式
英文:

What is the disadvantage of using socket.io to conenct nodejs server and golang server?

问题

我正在开发一个包含饼图、柱状图、网格等可视化功能的Web应用程序。

注意:

应用程序包括以下内容:

  1. 两种技术:nodejsgolang

  2. nodejs用于执行简单操作、路由、验证等。

  3. golang用于数据库连接、数据处理等。

架构/流程:

  1. 客户端(angularjs)将与nodejs服务器通信。

  2. nodejs将使用socket.iogolang服务器通信以获取处理后的数据。

  3. nodejs在从golang获取处理后的数据后将响应给客户端。

这是我的问题:

在这种情况下,使用socket.io有什么缺点吗?

对于任何建议或想法,我都非常感激。

英文:

I am working on web application which includes visualization - pie, bar, grid etc.

Note:

Application includes

  1. Two technologies nodejs and golang.

  2. Nodejs is used for performing simple operations, routing, validation etc.

  3. Golang is used for db connection, processing data, etc.

Architecture/ Flow:

  1. Client(angularjs) will communicate to nodejs server.

  2. Nodejs will talk to golang server using socket.io to get processed data.

  3. Nodejs will respond to client after getting processed data from golang.

Here is my question

Is there any drawback of using socket.io in this case?

Any suggestion or idea will be grateful.

答案1

得分: 1

这主要是一个基于观点的问题,但我可以看到一些缺点。

Socket.io是一种旨在统一浏览器和服务器之间通信的解决方案。它对于实现高度动态的网站非常有用,并隐藏了浏览器对不同底层解决方案/协议的支持程度(如WebSockets、长轮询等)。

它并不是真正设计用于两个服务器之间的通信,即使它可能也可以用于这个目的。由于您可以开发Node.js和Go服务器,只需选择适当的协议即可,无需将其包装到像socket.io这样的层中。

Go通过第三方库(例如https://github.com/googollee/go-socket.io)支持socket.io。

这是您需要处理的额外依赖项。

英文:

This is mostly an opinion-based question, but I could see some drawbacks.

Socket.io is a solution designed to unify communications between a browser and a server. It is useful to implement highly dynamic web sites, and hides the different underlying solutions/protocols which are more or less well supported by the browsers (websockets, long polling, etc ...).

It is not really designed to communicate between two servers, even if it can probably be used for this as well. Since you can develop the node.js and Go servers, just choose an adequate protocol for that. You do not have to wrap it into a layer such as socket.io.

Go supports socket.io through third-parties libraries such as:
https://github.com/googollee/go-socket.io

It is an extra dependency you have to handle for your application.

答案2

得分: 0

如果您在同一台机器上有Node和Go应用程序,请考虑使用Unix套接字。这里是用于此目的的npm包:https://www.npmjs.com/package/socket-model。

英文:

If you have node and go apps on the same machine consider using unix sockets https://www.npmjs.com/package/socket-model here the npm package for that.

huangapple
  • 本文由 发表于 2015年1月29日 18:40:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/28212586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定