Fixing a Request Timeout Error When Uploading Files To Rackspace Cloud Files
We’re storing user uploaded files using Rackspace’s Cloud Files. We have a process that allows the user to upload to our server and then we “lazy” upload it to Rackspace. We do this because there have been a couple cases where we can’t cleanly upload them (due to a bug in our code) and having the local copy has made people feel better (we’re going to slowly roll this back once we determine we’re in good shape). As part of this process, we verify the file has been uploaded (making sure the file size in Cloud Files matches the file size on disk) and then we upload the file to a separate container in a different region so we have a backup (some of these files can’t be recreated so we’re being overly cautious).
This script that does the second upload looked like this.
When we originally deployed the script it worked perfectly but as the number of files increased we started getting the following error randomly:
We weren’t able to find anything via Google that was helpful but after a lot of playing around we figure out it was actually a problem with the order we were doing things in. The call to findNewFile was taking several seconds to complete and this appears to be causing the timeout error. Our solution was to precalculate the list of files it was going to upload and now it works perfectly now.
It’s also a lot cleaner.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows