It's not uncommon for large files, or large numbers of files, to cause website slowness. Large files may not be cached, so every request for those files results in load on the website. Large numbers of files can cause problems with the file system itself, because the system has to look through the entire directory to find the correct data.
PHP has limits on the size of items that can be uploaded, as well as the amount of time it will hold a connection open. Videos and other files can be 1 Gb in size or more. PHP has several variables that come into play here:
- upload_max_filesize - in PHP, this defaults to 2Mb. Acquia Cloud is generally configured higher, but is still limited.
- post_max_size - this is often configured at a higher limit than upload_max_filesize, but it is still limited.
- max_execution_time - even if your website allows very large files, PHP may time out before the file has finished uploading.
Other PHP variables may affect your ability to upload files as well.
On Acquia Cloud, Varnish stores files up to a maximum size of 10 MB; files larger than this will not be cached. If you expect to have files larger than this available to a wide distribution of users, it's a good idea to store them on a dedicated external service. This helps ensure that your primary server(s) are not overloaded.
Acquia does not support file downloads of greater than one gigabyte. To download large files, use SFTP, scp, or rsync to access your Acquia environments.
Large numbers of files
There are two major ways to handle large numbers of files:
- Optimize file paths and move existing files reactively in a current website.
- Proactively organize files into subfolders proactively for new websites.
However, there may be websites with enough files that even file organization isn't enough to keep performance at an acceptable level. If you are finding that your website performance is degrading, and you suspect that having too many files may be the problem, there are some options:
Getting rid of old files
If you have files that are no longer in use, it's a good idea to remove them. It saves disk space and processing time. It may save additional time when caches are rebuilt, as well as simply making it easier to find content that is relevant to your current users. You may also have files that were uploaded, but are not in use. The Audit Files module may be useful in finding such files.
Using external storage
You may have a business need to keep all of your static assets on a long-term basis, so you may consider external storage for some or all of your website's files. If you have a large or very busy website, using a content delivery network (CDN) is a good idea for performance. If you're using a CDN, you can move your static files such as images, videos, and other media to a server that the CDN will pull from, rather than from the main website. This also reduces CPU and disk I/O on your primary server(s).
Here are some suggestions of Drupal modules that can help you integrate external storage: