0

我正在尝试执行第 3 方 API 请求以获取大量分页数据(约 16k 个对象的数组,每个对象具有约 25 个键/值对),我认为我的速率受到限制,但请求在本地和在手动触发时也可以生产

但是当他们按计划运行时,我得到了这些随机连接错误

errorMessage: 'Client network socket disconnected before secure TLS connection was established',
errorStack: 'Error: Client network socket disconnected before secure TLS connection was established\n' +
  '    at connResetException (node:internal/errors:691:14)\n' +
  '    at TLSSocket.onConnectEnd (node:_tls_wrap:1585:19)\n' +
  '    at TLSSocket.emit (node:events:402:35)\n' +
  '    at endReadableNT (node:internal/streams/readable:1343:12)\n' +
  '    at processTicksAndRejections (node:internal/process/task_queues:83:21)'
errorMessage: 'socket hang up',
errorStack: 'Error: socket hang up\n' +
  '    at connResetException (node:internal/errors:691:14)\n' +
  '    at TLSSocket.socketOnEnd (node:_http_client:471:23)\n' +
  '    at TLSSocket.emit (node:events:402:35)\n' +
  '    at endReadableNT (node:internal/streams/readable:1343:12)\n' +
  '    at processTicksAndRejections (node:internal/process/task_queues:83:21)'
errorMessage: 'read ECONNRESET',
errorStack: 'Error: read ECONNRESET\n' +
  '    at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20)'
errorMessage: 'write ECONNRESET',
errorStack: 'Error: write ECONNRESET\n' +
  '    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:98:16)'

我在 Cloud Run 上运行 Nest.js 服务器

这是我的 Docker 配置

FROM node:16-alpine as build

WORKDIR /app

# Copy and install dependencies first so that they can be cached
COPY package.json .
COPY yarn.lock .
RUN yarn install

# Copy rest of the files and build
COPY . .
RUN yarn build
RUN ls -a

FROM node:16-alpine

WORKDIR /app

# Copy and install dependencies first so that they can be cached
COPY package.json .
RUN yarn install --prod

# Copy files and dist folder from build image
COPY . .
COPY --from=build /app/dist ./dist
RUN ls -a


EXPOSE 3000

CMD ["node", "dist/src/main.js"]

该实例有 4GiB 内存,2 个 CPU,请求超时设置为 2400 秒,每个容器的最大请求数为 80,最小和最大实例数分别设置为 1 和 25。

所有流量都通过 VPC 连接器路由,它是一个f1-micro实例,最小实例设置为 2,最大实例设置为 10。

对于公牛,有 5 个不同的工人设置,它们被随机分配到工作中

我在之前部署到的 App Engine 上没有收到这些错误

有谁知道这是什么原因造成的?

4

1 回答 1

0

我建议查看 Cloud Run 中设置的并发值。默认情况下,每个 Cloud Run 容器可以同时接收 80 个请求,但您最多可以增加到 1000 个,您可以根据您的代码是否可以同时处理并行请求来修改此值,在此链接中您可以找到如何将您的并发值设置为 Cloud Run

于 2022-01-20T16:55:07.343 回答