No need to solve this problem only in PHP.
Queue of tasks (eg Gearman ). In her push "task" - a link to the file in this case. And the Workflow - Bash script - is constantly spinning and waiting for the receipt of a new task, and downloads the specified file with the wget
command and at the end of the execution it stuffs the url, the path, the date-time into the database.
And your front-end may be interested in ajax every second, the file is already loaded. or not yet.
wget does not eat memory. How to check (idea and code from here ). Open two terminals to the server. In one prepare something like this bash script and run:
while true do ps -eo size,command | awk '/wget/&&!/ps.*awk/{print $1, "KB", $2}' sleep 5 done
It will show every 5 seconds the memory taken by the wget process. In the second terminal, start downloading some large file with wget. For example I took the Debian distribution (3.7Gb):
wget http://cdimage.debian.org/debian-cd/8.3.0/i386/iso-dvd/debian-8.3.0-i386-DVD-1.iso
In the first window, I consistently showed the same modest memory:
./test.sh 428 KB wget 428 KB wget 428 KB wget 428 KB wget 428 KB wget 428 KB wget 428 KB wget
If you are downloading a disk-in-memory partition, then yes, it may eat memory — but not wget, but the file being downloaded.