concurrency - 如何使用谷歌云函数处理背压

标签 concurrency google-cloud-platform google-cloud-functions backpressure

使用谷歌云函数,有没有办法像 AWS Lambda 那样管理执行并发? ( https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html )

我的意图是设计一个使用任务文件并将这些任务发布到工作队列(发布/订阅)的函数。我想要一个函数来消耗工作队列(pub/sub)中的任务并执行任务。

以上可能会导致大量几乎并发的执行。我的下游消费者服务很慢,一次不能消耗很多并发请求。很有可能,它会返回 HTTP 429 响应以尝试减慢生产者的速度。

有没有办法像使用 AWS 那样限制给定 Google Cloud 函数的并发性?

最佳答案

此功能 is not available适用于 Google Cloud Functions。相反,由于您要求处理系统打开并发任务的速度,Task Queues是解决方案。

Push queues dispatch requests at a reliable, steady rate. They guarantee reliable task execution. Because you can control the rate at which tasks are sent from the queue, you can control the workers' scaling behavior and hence your costs.



在您的情况下,您可以控制调用下游消费者服务的速率。

关于concurrency - 如何使用谷歌云函数处理背压,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48646777/

相关文章:

typescript - 使用 typescript 从 web sdk 使用 firebase 函数

performance - "Google Cloud Tasks", 任务创建执行

java - 它是否正确? ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(numThreads);

google-cloud-platform - API 网关不返回响应

java - 在 Jython 2.5 中同时执行多个函数

google-app-engine - 缺少用于从 Google App Engine 标准环境连接到 Cloud SQL 的套接字

java - 如何使用服务帐户验证 `com.google.cloud.bigquery.BigQuery`

google-cloud-platform - 谷歌云 : deny access to a single file in a given bucket

c# - 如何在做某事时检查 C# 中的标准输入

sql-server - 使用 EF Core 2.1 和 SQL Server 进行正确的并发处理