1

heys guys.

So... I have a website that needs to upload files like, 500MB large.

My question is... what kind of system requirements do I need? Specifically about memory. For uploading a 500MB file I need 500MB RAM? How much RAM will be necessary for ONE upload of that kind succeed?

lucaswxp
  • 2,031
  • 5
  • 23
  • 34

1 Answers1

1

PHP, or better the web server, will not buffer the whole upload in RAM.

Upload size depends not directly on RAM size. I cannot say what exactly your system should look like but I can say that I handled GB sized updates years ago with low cost work station.

Note that you'll have to change the following php.ini settings if you want to support big uploads:

upload_max_filesize = '500M';

post_max_size = '500M';

About memory again: Note that not PHP will consume the memory. The web server will handle the download. You won't worry about this in PHP.

If you use a Linux system you can view the tcp buffer size when typing

cat /proc/sys/net/ipv4/tcp_rmem

in terminal. You'll see 3 numbers. The minimum, medium and maximum buffer size in bytes. On my system it is:

4096    87380   4115680

Meaning that the maximum buffer size is ~3.9MB which is significantly smaller then the 500MB you have.

So don't worry about memory in this case. Its is very likely that the network is the bottleneck.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • I suspected... do you have any ideia of how much RAM will be buffered at time? – lucaswxp Feb 05 '13 at 18:25
  • Yes. I'm aware of upload_max_fielsize and post_max_size, now I need to know about memory usage. Should I worry about exhausting 128MB RAM? – lucaswxp Feb 05 '13 at 18:29
  • I would assume the amount of memory actually used will be quite low. The file is likely read in by the server as a stream and written directly to a tmp file which you then copy to the correct location with your language of choice. – Chris Christensen Feb 05 '13 at 18:30
  • I'm not sure how to test this... plus I don't have direct access to the server. – lucaswxp Feb 05 '13 at 18:30
  • On your dev box, set the max memory that your web server can use to 128MB and test it. You could go as far as creating a VM that matches your production environment if you wanted. – Chris Christensen Feb 05 '13 at 18:32