我的基于 Flask 的 GAE 应用程序已经运行了几周没有问题。今天我注意到根 URL 大部分时间都会产生 500 内部服务器错误。在日志记录中,我看到这似乎与 Flask 中的会话处理有关(使用 Flask-Session)。在过渡到 GAE 之前,这个应用程序在具有本地 Redis 实例的 VM 上运行了一年多,没有任何问题。
Memorystore 实例此时只有大约 1500 个键和 3 或 4 mb 的数据,因此负载并不重。服务器本身接收的流量很少(只有我和偶尔的机器人)。由于我是 GAE 和 Google Cloud 环境的新手,因此我正在寻找有关导致这种行为变化的原因或我应该采取哪些诊断程序的见解。
故障的典型回溯如下所示:
Traceback (most recent call last):
File "/env/lib/python3.7/site-packages/flask/app.py", line 1969, in finalize_request response = self.process_response(response)
File "/env/lib/python3.7/site-packages/flask/app.py", line 2268, in process_response self.session_interface.save_session(self, ctx.session, response)
File "/env/lib/python3.7/site-packages/flask_session/sessions.py", line 166, in save_session time=total_seconds(app.permanent_session_lifetime))
File "/env/lib/python3.7/site-packages/redis/client.py", line 1540, in setex return self.execute_command('SETEX', name, time, value)
File "/env/lib/python3.7/site-packages/redis/client.py", line 836, in execute_command conn = self.connection or pool.get_connection(command_name, **options)
File "/env/lib/python3.7/site-packages/redis/connection.py", line 1065, in get_connection if connection.can_read():
File "/env/lib/python3.7/site-packages/redis/connection.py", line 682, in can_read return self._parser.can_read(timeout)
File "/env/lib/python3.7/site-packages/redis/connection.py", line 295, in can_read return self._buffer and self._buffer.can_read(timeout)
File "/env/lib/python3.7/site-packages/redis/connection.py", line 205, in can_read raise_on_timeout=False)
File "/env/lib/python3.7/site-packages/redis/connection.py", line 173, in _read_from_socket data = recv(self._sock, socket_read_size)
File "/env/lib/python3.7/site-packages/redis/_compat.py", line 58, in recv return sock.recv(*args, **kwargs) ConnectionResetError: [Errno 104] Connection reset by peer
同样,这是新行为。服务器完美运行了几个星期。可能发生了什么变化,我应该去哪里看?
可能的相关问题:https ://github.com/andymccurdy/redis-py/issues/1186