使用nodejs驱动程序获取简单选择查询的响应需要20秒。但是使用cqlsh只需不到一秒钟。
启用连接登录,并显示大量连接事件,如下所示
SELECT * FROM developer WHERE username=?
2015-06-13T05:48:39.635Z log event: info -- "ControlConnection"
2015-06-13T05:48:39.635Z log event: info -- "ControlConnection"
2015-06-13T05:48:39.637Z log event: info -- "Connection"
2015-06-13T05:48:44.641Z log event: warning -- "Connection"
2015-06-13T05:48:44.641Z log event: info -- "Connection"
2015-06-13T05:48:49.646Z log event: warning -- "Connection"
2015-06-13T05:48:49.647Z log event: info -- "Connection"
2015-06-13T05:48:49.647Z log event: verbose -- "Connection"
2015-06-13T05:48:49.648Z log event: verbose -- "Connection"
2015-06-13T05:48:49.648Z log event: verbose -- "Connection"
2015-06-13T05:48:49.651Z log event: verbose -- "Connection"
2015-06-13T05:48:49.651Z log event: info -- "Connection"
2015-06-13T05:48:49.652Z log event: verbose -- "Connection"
2015-06-13T05:48:49.652Z log event: verbose -- "Connection"
2015-06-13T05:48:49.652Z log event: verbose -- "Connection"
2015-06-13T05:48:49.653Z log event: verbose -- "Connection"
2015-06-13T05:48:49.654Z log event: verbose -- "Connection"
2015-06-13T05:48:49.654Z log event: verbose -- "Connection"
2015-06-13T05:48:49.654Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.654Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.654Z log event: verbose -- "Connection"
2015-06-13T05:48:49.655Z log event: verbose -- "Connection"
2015-06-13T05:48:49.662Z log event: verbose -- "Connection"
2015-06-13T05:48:49.662Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.662Z log event: verbose -- "Connection"
2015-06-13T05:48:49.663Z log event: verbose -- "Connection"
2015-06-13T05:48:49.663Z log event: verbose -- "Connection"
2015-06-13T05:48:49.684Z log event: verbose -- "Connection"
2015-06-13T05:48:49.684Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.684Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.684Z log event: verbose -- "Connection"
2015-06-13T05:48:49.684Z log event: verbose -- "Connection"
2015-06-13T05:48:49.684Z log event: verbose -- "Connection"
2015-06-13T05:48:49.690Z log event: verbose -- "Connection"
2015-06-13T05:48:49.718Z log event: verbose -- "Connection"
2015-06-13T05:48:49.718Z log event: verbose -- "Connection"
2015-06-13T05:48:49.719Z log event: verbose -- "Connection"
2015-06-13T05:48:49.725Z log event: verbose -- "Connection"
2015-06-13T05:48:49.725Z log event: info -- "ControlConnection"
2015-06-13T05:48:49.725Z log event: verbose -- "Connection"
2015-06-13T05:48:49.726Z log event: verbose -- "Connection"
2015-06-13T05:48:49.726Z log event: verbose -- "Connection"
2015-06-13T05:48:49.726Z log event: verbose -- "Connection"
2015-06-13T05:48:49.727Z log event: verbose -- "Connection"
2015-06-13T05:48:49.727Z log event: info -- "Connection"
2015-06-13T05:48:54.728Z log event: warning -- "Connection"
2015-06-13T05:48:54.729Z log event: info -- "Connection"
2015-06-13T05:48:59.734Z log event: warning -- "Connection"
2015-06-13T05:48:59.735Z log event: verbose -- "Connection"
2015-06-13T05:48:59.735Z log event: verbose -- "Connection"
2015-06-13T05:49:00.160Z log event: verbose -- "Connection"
result 1
知道为什么会这样吗?
答案 0 :(得分:0)
node.js driver功能节点自动发现。这表示即使只提供了一个联系点,驱动程序也会知道参与群集的其他节点。
查看原始帖子中的日志消息,我们会看到一些标有Connection
的警告消息。虽然我们在这里没有完整的日志消息,但我们可以猜测它在尝试移动到可访问的第三个节点之前尝试尝试两个不可用的节点。查看connection.js
中驱动程序的源代码,我们看到连接错误时会发出警告。
此外,在client-options.js
中,我们看到连接超时为5秒。这与输出中的日志消息之间的时间匹配。
如果尝试连接到每个节点的驱动程序失败,那么等待超时可能会占用大约20秒的查询时间。确保所有节点都可以单独访问,您将看到性能提升。
答案 1 :(得分:-1)
我使用docker https://github.com/pokle/cassandra运行3节点集群 并且只有一个节点暴露在外面。
使用单节点群集时,它的工作速度非常快。 我认为驱动程序尝试连接群集中的其他主机,尽管我在contactPoints选项中只放了一个主机。
现在显示日志
htmlStr+="<table><tr><td>"+ProgTitle+"</td></tr></table>";