Welcome! Log In Create A New Profile

Advanced

Large file uploads don't always work

Posted by slingboy 
Large file uploads don't always work
July 12, 2010 09:05AM
I operate a file hosting site and I recently replaced my web server infrastructure with nginx/0.7.65, and php-fpm. I have a problem when users upload large files 300MB+. The file upload seems to be working fine as I can see the file upload complete when I monitor the path given in 'http-client-body-temp-path', but when the file uploads successfully, my PHP app is not able to receive it. It seems that the timeout values are affecting this. If not, then when I try to move the uploaded file to the destination, php throws an error that the file uploaded was not found. So, I really don't know where the error really is... I increased the time outs and it still doesn't help me. This problem only occurs when uploading large files, but it works just fine when files less than 100MB are uploaded. So, there is nothing wrong with the my web site's code. Since large file uploads tend to take longer to upload and so I have time out options to blame. I was wondering what changes I need to apply in order to enable large uploads? Please help!


Here are the error-log contents:

2010/07/12 00:54:36 [alert] 455818#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455819#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455821#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455820#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455822#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455823#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455824#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455825#0: recvmsg() truncated data
2010/07/12 00:54:36 [alert] 455943#0: recvmsg() truncated data
2010/07/12 00:54:09 [alert] 455436#0: socketpair() failed while spawning "worker process" (24: Too many open files)
2010/07/12 00:54:36 [alert] 455437#0: recvmsg() truncated data

Thanks!

Here are my fastcgi_params and nginx.conf files:

--------------------------------------------------------------------------------
FILE: fastcgi_params
--------------------------------------------------------------------------------

fastcgi_connect_timeout 60;
fastcgi_send_timeout 7200;
fastcgi_read_timeout 7200;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_pass_request_body off;
client_body_in_file_only clean;
client_body_timeout 7200;
proxy_read_timeout 7200;
client_max_body_size 2047m;
fastcgi_cache off;
fastcgi_ignore_client_abort on;

fastcgi_param REQUEST_BODY_FILE $request_body_file;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

# I ADDED THIS LINE
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
FILE: nginx.conf
--------------------------------------------------------------------------------

user www-user www-data;
worker_processes 2; #the number represents a core

error_log /log/nginx/error_log;
pid /dev/shm/nginx.pid;

events
{
use epoll;
worker_connections 32768;
}

http
{

include /etc/nginx/mime.types;
default_type application/octet-stream;

gzip off;

ignore_invalid_headers on;
limit_zone gulag $binary_remote_addr 1m;
limit_conn gulag 5;
recursive_error_pages on;
sendfile on;
#server_name_in_redirect off;
server_tokens off;
client_max_body_size 2047m;

## TCP options
tcp_nodelay on;
tcp_nopush on;

#access_log /log/nginx/access_log;

# Default Server
server
{

listen 80;
server_name 001-17.server.com;
root /www/001-17/www;

location /
{
index index.html;
}

# This is your php-fpm section. Replace it accordingly (For example if you decide to run it on a different port).
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}

location ~ /\.ht { deny all; }

}


}

--------------------------------------------------------------------------------
FILE: /usr/etc/php-fpm.conf
--------------------------------------------------------------------------------

<?xml version="1.0" ?>
<configuration>

All relative paths in this config are relative to php's install prefix

<section name="global_options">

Pid file
<value name="pid_file">/usr/logs/php-fpm.pid</value>

Error log file
<value name="error_log">/usr/logs/php-fpm.log</value>

Log level
<value name="log_level">notice</value>

When this amount of php processes exited with SIGSEGV or SIGBUS ...
<value name="emergency_restart_threshold">10</value>

... in a less than this interval of time, a graceful restart will be initiated.
Useful to work around accidental curruptions in accelerator's shared memory.
<value name="emergency_restart_interval">1m</value>

Time limit on waiting child's reaction on signals from master
<value name="process_control_timeout">5s</value>

Set to 'no' to debug fpm
<value name="daemonize">yes</value>

</section>

<workers>

<section name="pool">

Name of pool. Used in logs and stats.
<value name="name">default</value>

Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
<value name="listen_address">127.0.0.1:9000</value>

<value name="listen_options">

Set listen(2) backlog
<value name="backlog">-1</value>

Set permissions for unix socket, if one used.
In Linux read/write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
<value name="owner">www-user</value>
<value name="group">www-data</value>
<value name="mode">0666</value>
</value>

Additional php.ini defines, specific to this pool of workers.
<value name="php_defines">
<!-- <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> -->
<!-- <value name="display_errors">0</value> -->
</value>

Unix user of processes
<value name="user">www-user</value>

Unix group of processes
<value name="group">www-data</value>

Process manager settings
<value name="pm">

Sets style of controling worker process count.
Valid values are 'static' and 'apache-like'
<value name="style">apache-like</value>

Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">500</value>

Settings group for 'apache-like' pm style
<value name="apache_like">

Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name="StartServers">20</value>

Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MinSpareServers">5</value>

Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MaxSpareServers">35</value>

</value>

</value>

The timeout (in seconds) for serving a single request after which the worker process will be terminated
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
'0s' means 'off'
<value name="request_terminate_timeout">0s</value>

The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
'0s' means 'off'
<value name="request_slowlog_timeout">0s</value>

The log file for slow requests
<value name="slowlog">logs/slow.log</value>

Set open file desc rlimit
<value name="rlimit_files">1024</value>

Set max core size rlimit
<value name="rlimit_core">0</value>

Chroot to this directory at the start, absolute path
<value name="chroot"></value>

Chdir to this directory at the start, absolute path
<value name="chdir"></value>

Redirect workers' stdout and stderr into main error log.
If not set, they will be redirected to /dev/null, according to FastCGI specs
<value name="catch_workers_output">yes</value>

How much requests each process should execute before respawn.
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
<value name="max_requests">500</value>

Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
<value name="allowed_clients">127.0.0.1</value>

Pass environment variables like LD_LIBRARY_PATH

All $VARIABLEs are taken from current environment
<value name="environment">
<value name="HOSTNAME">$HOSTNAME</value>
<value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
<value name="TMP">/tmp</value>
<value name="TMPDIR">/tmp</value>
<value name="TEMP">/tmp</value>
<value name="OSTYPE">$OSTYPE</value>
<value name="MACHTYPE">$MACHTYPE</value>
<value name="MALLOC_CHECK_">2</value>
</value>

</section>

</workers>

</configuration>



Edited 2 time(s). Last edit at 07/12/2010 09:08AM by slingboy.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 139
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready