在Express服务器上处理请求

时间:2019-09-20 03:54:53

标签: node.js

我有一个带有几个端点的简单Express API服务。前端使用这些API从Elasticsearch(ES)读取/写入数据。所述端点如下所述。

1. /api/storeCities # parses a CSV and writes 100,000 documents to the cities index in ES
2. /api/fetchCities # fetches 100,000 documents from the cities index in ES
3. /api/fetchStates # fetches 100,000 documents from the states index in ES
4. /api/fetchCountries # fetches 100,000 documents from the countries index in ES

第1季度。对于上述所有提取端点,将数据提取到UI中都没有问题/延迟。由于节点支持1000个并发请求,因此多个用户调用同一个API(?)不会有任何问题。

Q2a。。每当有人呼叫/api/storeCities端点时,节点都会解析CSV文件并将数据写入ES。但是,在此过程中,所有其他端点都停止响应,并且所有fetch端点都存在巨大的滞后。由于节点是非阻塞的,WRITE操作为什么会影响READ个节点?这是ES方面的问题吗?

Q2b。。我也在使用节点Cluster模块,因此Express应用程序有多个实例。但是,当有人呼叫/api/storeCities端点时,延迟仍然存在。似乎节点正在阻止来自ES的所有READ调用,直到WRITE调用结束为止。

我无法确定问题出在哪里,节点还是ES?

0 个答案:

没有答案