我想只允许一个 IP 每天使用最多 1GB 的流量,如果超过该限制,则来自该 IP 的所有请求都将被丢弃,直到第二天。但是,在一定数量的请求后断开连接的更简单的解决方案就足够了。
是否已经有某种模块可以做到这一点?或者我可以通过像 iptables 这样的东西来实现这一点?
谢谢
这看起来像是 Nginx+uWSGI 超时的一个众所周知的问题,但我的设置不同,我找不到有关它的信息。
我在 uWSGI 上运行 Flask 应用程序,使用 http 协议(不是套接字)。当我查询 API 时,有时会收到错误消息:
uwsgi_response_write_body_do() TIMEOUT !!!
IOError: : write error
Run Code Online (Sandbox Code Playgroud)
我在“工作时间”收到它的频率更高,即在晚上不那么频繁。我正在查询长 JSON 数据(地理坐标,最多 50 MB),有时我根本没有得到响应,有时我得到了部分响应。这些是来自 Pythonrequests请求的错误:
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
ValueError: Expecting object: line 1 column 5590371 (char 5590370)
ValueError: Unterminated string starting at: line 1 column 20998536 (char 20998535)
ValueError: end is out of bounds
# when I set `timeout=None` in Python
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='mydomain.com', port=80): …Run Code Online (Sandbox Code Playgroud) 在 Web 服务器的“每秒请求数”和“每秒命中数”等指标中,术语“请求”和“命中”是同义词吗?你能想到一个请求没有成功的上下文吗?