Google app engine 应用程序引擎标准,无服务器VPC,云内存存储,导致大量超时
我们将我们的应用引擎标准python 3服务配置为通过无服务器VPC服务(根据文档和其他堆栈溢出线程)连接到Cloud Memorystore。(我已经包括了下面的app.yaml配置)。这一切都很有效,除非有一个实例暂时闲置。随着时间的推移,我们看到了大量的:Google app engine 应用程序引擎标准,无服务器VPC,云内存存储,导致大量超时,google-app-engine,redis,google-cloud-memorystore,google-vpc,Google App Engine,Redis,Google Cloud Memorystore,Google Vpc,我们将我们的应用引擎标准python 3服务配置为通过无服务器VPC服务(根据文档和其他堆栈溢出线程)连接到Cloud Memorystore。(我已经包括了下面的app.yaml配置)。这一切都很有效,除非有一个实例暂时闲置。随着时间的推移,我们看到了大量的: 打电话到Memorystore时,长时间无法解释的挂起,即使它们最终起了作用 redis.exceptions.ConnectionError:Error 110连接到10.0.0.12:6379。连接超时。 redis.except
- 打电话到Memorystore时,长时间无法解释的挂起,即使它们最终起了作用
redis.exceptions.ConnectionError:Error 110连接到10.0.0.12:6379。连接超时。
redis.exceptions.TimeoutError:从套接字读取超时
env_variables:
REDISHOST: <IP>
REDISPORT: 6379
network:
name: "projects/<PROJECT-ID>/global/networks/default"
vpc_access_connector:
name: "projects/<PROJECT-ID>/locations/us-central1/connectors/<VPC-NAME>
(我尝试了各种超时设置,但找不到任何有用的设置)我创建了一个Memorystore实例和一个无服务器VPC访问连接器,如文档()中所述,然后在做了一些修改后,将此示例()从Google云平台Python doc samples repo部署到App Engine Standard: 这是我的应用程序。yaml:
runtime: python37
# Update with Redis instance details
env_variables:
REDIS_HOST: <memorystore-ip-here>
REDIS_PORT: 6379
# Update with Serverless VPC Access connector details
vpc_access_connector:
name: 'projects/<project-id>/locations/<region>/connectors/<connector-name>'
# [END memorystore_app_yaml_standard]
我编辑了requirements.txt。我将“redis==3.3.8
”更改为“redis>=3.3.0
”
注意事项:
- 确保使用“gcloud beta app deploy”而不是“gcloud app deploy”,因为这是无服务器VPC访问连接器工作所必需的
- 确保为memorystore实例设置的授权网络与为无服务器VPC访问连接器选择的网络相同
如果将最小空闲实例设置为0,则在请求启动时,没有可用实例为您的流量提供服务,这可能是出现异常的原因。请共享用于连接Memorystore的代码好吗?你在使用哪个客户端库?@NahuelVarela添加了实例化客户端的代码,你试过玩吗?嗨,Joey,这基本上也是我们遵循的步骤。它最初确实可以工作,并且可以很好地连接到Redis。然而,一旦这些实例闲置了一段时间(但没有消失),它们就很难连接到Redis。如果将min idle设置为0,则在测试应用程序中可能看不到这么多。基本上,如果你点击该应用程序,等待5分钟左右,确保该应用程序仍在运行,然后再次点击,你将开始看到超时。我们在几天内看到了数千个这样的异常。嗨@chainicko,我不认为冷启动是我的问题,问题在于存在一段时间的实例,但它们是空闲的
runtime: python37
# Update with Redis instance details
env_variables:
REDIS_HOST: <memorystore-ip-here>
REDIS_PORT: 6379
# Update with Serverless VPC Access connector details
vpc_access_connector:
name: 'projects/<project-id>/locations/<region>/connectors/<connector-name>'
# [END memorystore_app_yaml_standard]
redis_client = redis.StrictRedis(
host=redis_host, port=redis_port,
password=redis_password,
retry_on_timeout=True,
health_check_interval=30
)