TL DR
not to do. Rails is not optimized for bulk upload, so do it out of range when you can.
Use FTP / SFTP
The best way to handle large file sizes is to use a completely out-of-band process rather than linking your Rails process. For example, use FTP, FTPS, SCP, or SFTP to upload your files in bulk. Once the files are on the server, process them using the cron job or use inotify to run the rake command.
Note. Be sure to pay attention to file locking when using this technique.
Use queue
If you insist on doing this through Rails, don't download hundreds of files. Instead, upload one archive containing your files that will be processed by the background job or queue. There are many alternatives, including Sidekiq and RabbitMQ among others.
After downloading the archive and sending the delivered queue, the queue process can unpack the archive and do everything that needs to be done. This type of solution scales very well.
source share