A
A
Anatoly2018-08-31 20:30:18
Nginx
Anatoly, 2018-08-31 20:30:18

How to solve the problem with the error "ERR_EMPTY_RESPONSE, which is supposedly due to open_file_cache?

The server is physically located next to my computer. On a Debian server with Nginx installed. php-fpm is also installed, it has nothing to do with it, since the problem arises even when accessing html files.
I use the Chrome browser, I haven't tested it with any other browser.
When accessing the index.html file, I sometimes get the "ERR_EMPTY_RESPONSE" error. All this I can observe about a couple of times a day. When updating a file on the server, I refresh the page with Ctrl + F5 and get an error, then after 15-20 seconds the page loads and works normally.
In the nginx log, there is an error like this:

2018/08/31 21:48:34 [alert] 12177#0: *7103 pread() read only 6570 of 6574 from "/var/www/XXXXXXXXXX/www/index.html" while sending response to client, client: 192.168.5.1, server: XXXXXXXXX, request: "GET /index.html HTTP/1.1", host: "XXXXXXXXXXX"

where XXXXXXXX is the domain of the site, and 192.168.5.1 is the ip-address of the router through which the server and computer are connected to the Internet.
A similar problem was discussed here: https://serverfault.com/questions/547421/pread-rea...
and here: www.scalescale.com/tips/nginx/nginx-pread-read-onl... open_file_cache
is blamed for the problem .
The Nginx config contains the following lines:
open_file_cache max=200000 inactive=20s; # max количество файлов, информация о которых будет содержаться в кеше
open_file_cache_valid 30s; # через какое время информация будет удалена из кеша
open_file_cache_min_uses 2; # Будет кешировать информацию о тех файлах, которые были использованы хотя бы 2 раза
open_file_cache_errors on; # Будет кешировать информацию об отсутствующих файлах

The problem is observed just 20-30 seconds, i.e. matches the open_file_cache settings.
Any suggestions on how to beat this other than not using open_file_cache?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2018-09-02
@Tolly

I decided to delve into the topic, here are the results:
The open_file_cache directive is used to cache information about static files: js, css, jpeg, html, ..
If the file does not exist, or has no read rights, then this information can also be stored in the cache.
Default: open_file_cache off;
Example with description:

# Информация о 1000 файлов, может хранится в кеше. Если не было активности к файлу в течение 5 мин, то информация о нем удаляется из кеша
open_file_cache max=1000 inactive=5m;  

# Активностью считается обращение к файлу хотя бы 2 раза. В кеш они также попадают, если было хотя бы 2 обращения к файлу
open_file_cache_min_uses 2;             

# Вся информация о файлах в кеше обновляться раз в 1 минуту
open_file_cache_valid 1m;               

# Сохранять ли информацию об ошибках, например, если файла, к которому вы обратились - нет, то это будет тоже в кеше, информация тоже обновится через 1 мин
open_file_cache_errors on;

When working with static files, when they change, for example, layout.
For the duration of the work, it is desirable to disable open_file_cache, or make the open_file_cache_min_uses parameter large enough so that the file does not get into the cache, but this is actually the same as disabling open_file_cache.
If the file is in the cache and the file is changed, the server will return an ERR_EMPTY_RESPONSE error, which means that the server denied access and did not return the content.
At the same time, the server itself works fine and if it accesses other files, they are easily loaded.
A noteworthy fact is that if you restore a modified file, the server starts to give it before checking open_file_cache_valid. Apparently the checksum of the file is checked, since the file modification date changes.
When working with an NFS file system, it is recommended not to enable open_file_cache, as file information may not be updated even after open_file_cache_valid.
Wrote, and then maybe someone will be interested or I'll forget :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question