Adding Memory Limit to increase

lightshirePRO

10 months ago

Hi,I want to be able to increase the memory limit in our PHP file we are already using this

[variables]
UPLOAD_MAX_FILESIZE = '1024M'
POST_MAX_SIZE = '1024M'
MEMORY_LIMIT = '2048M'

[phases.setup]
cmds = ['UPLOAD_INI_PATH=$(find /nix/store/*-php-*/lib -name php.ini -print0 | head -z -n 1 | rev | cut -c 9- | rev)/upload.ini; echo "upload_max_filesize=${UPLOAD_MAX_FILESIZE};" >> $UPLOAD_INI_PATH; echo "post_max_size=${POST_MAX_SIZE};" >> $UPLOAD_INI_PATH; echo "memory_limit=${MEMORY_LIMIT};" >> $UPLOAD_INI_PATH;']

Our application service is Laravel / PHP.I can't upload files more than 150mb because of the memory limit

Solved

11 Replies

10 months ago

Do you also have a custom nginx.template.conf file?

When you say "can't upload files more than 150mb" please describe the exact error you get.


lightshirePRO

10 months ago

Yes, here it is.```

worker_processes 5; daemon off; worker_rlimit_nofile 8192; events { worker_connections 4096; # Default: 1024 } http { fastcgi_read_timeout 600; proxy_read_timeout 600; include $!{nginx}/conf/mime.types; index index.html index.htm index.php; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /dev/stdout; error_log /dev/stdout; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; # this seems to be required for some vhosts client_max_body_size 1024M; server { listen ${PORT}; listen [::]:${PORT}; server_name localhost; $if(NIXPACKS_PHP_ROOT_DIR) ( root ${NIXPACKS_PHP_ROOT_DIR}; ) else ( root /app; ) add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; $if(IS_LARAVEL) ( location / { try_files $uri $uri/ /index.php?$query_string; } ) else () $if(NIXPACKS_PHP_FALLBACK_PATH) ( location / { try_files $uri $uri/ ${NIXPACKS_PHP_FALLBACK_PATH}?$query_string; } ) else () location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } $if(IS_LARAVEL) ( error_page 404 /index.php; ) else () location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param PHP_VALUE "upload_max_filesize = 1024M \n post_max_size=1024M"; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include $!{nginx}/conf/fastcgi_params; include $!{nginx}/conf/fastcgi.conf; } location ~ /\.(?!well-known).* { deny all; } } } ```


10 months ago

Okay, please answer the second question I asked.


lightshirePRO

10 months ago

Thanks for the response Brody, it says we exhausted the memory. its in bytes, but its around 130mb if converted. So when I did run `phpinfo()` on our PHP service, the memory_limit is in 128mb, even after adding the changes above.Thank you.


10 months ago

Please provide exact error messages.


lightshirePRO

10 months ago

Fatal error: Allowed memory size of 134217728 bytes exhausted

Attachments


10 months ago

Is there any reason you are buffering your uploads into memory? memory limit or not, that's not efficient.


lightshirePRO

10 months ago

That's going to be refactored soon, for now we're leaving this as is, but we are going to move this to a serverless function soon.


lightshirePRO

10 months ago

Hello, would like to follow up with anybody as well specially on railway team that can help?


lightshirePRO

10 months ago

Hello again, anyone from railway can assist, it has been 4 days and we cant proceed with usage if this is not fixed, just looking for atleast a guide how to move forward. Thanks


10 months ago

Hey, unfortunately this looks like an issue with something you've setup at the application level (aka, Nginx). The team can't help with application level issues.


Status changed to Solved railway[bot] 10 months ago


Adding Memory Limit to increase - Railway Help Station