pread() 仅读取 yyyy 中的 xxxx

pread() 仅读取 yyyy 中的 xxxx

有时,nginx 不会将任何数据发送回浏览器(ERR_EMPTY_RESPONSE在 Chrome 中)。

检查服务器的 error.log 后,我发现了这些奇怪的消息:

2013/10/20 23:57:40 [alert] 29146#0: *35 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:57:45 [alert] 29146#0: *36 pread() read only 4653 of 4656 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:18 [alert] 29146#0: *38 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:18 [alert] 29146#0: *39 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/20 23:58:19 [alert] 29146#0: *40 pread() read only 4650 of 4653 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:21 [alert] 29146#0: *41 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:21 [alert] 29146#0: *42 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:23 [alert] 29146#0: *43 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:31 [alert] 29146#0: *44 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2013/10/21 00:02:46 [alert] 29146#0: *45 pread() read only 4629 of 4641 from "~/htdocs/index.html" while sending response to client, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

有人知道为什么会发生这种情况吗?过了一会儿,一切都恢复正常了。

答案1

我发现这个俄罗斯论坛主题这表明它与open_file_cache指令有关。

这是有道理的,因为我正在使用 Sublime Text 和它不进行原子文件保存

答案2

我遇到了同样的问题,经过多次搜索,终于解决了open_log_file_cache

open_log_file_cache      max=20000 inactive=30s min_uses=2;

这与您的问题无关,但对于其他寻找 nginx 文件缓存最佳实践的访问者来说,这是我经过多次搜索并进行多次基准测试后得出的完整文件缓存配置。

# cache information about FDs, frequently accessed files
aio                      threads; # linux kernel > 2.6.22
open_file_cache          max=10000 inactive=120s; # removed from the cache if it has not been accessed during `inactive` time
open_file_cache_valid    120s; # Sets a time after which open_file_cache elements should be validated.
open_file_cache_min_uses 2; # Sets the minimum number of file accesses during the period configured by the inactive parameter
open_file_cache_errors   off; # Enables or disables caching of file lookup errors by open_file_cache.
open_log_file_cache      max=20000 inactive=30s min_uses=2;

答案3

无论谁接下来遇到这个问题,该问题都与打开文件缓存有关。

大多数情况下,这是由于文件在被 Nginx 读取以进行缓存时被修改所导致的,正如 David 之前提到的。

这将导致循环,为了解决它,只需使用以下命令重新加载 Nginx

sudo nginx -t && sudo nginx reload

重新加载或重新启动 Nginx 之前务必进行测试,以确保一切正常,并且不会因配置错误而导致 Web 服务器崩溃。

相关内容