Search code examples
phpfilestoragelimitpartition

PHP uploads with 2Tb partition limit


Using PHP/Apache and now face a problem on Ubuntu linux where my web application's uploads are nearly 2Tb in total.

Does anyone have any experience in programming their PHP uploads to use multiple partitions? Maybe filling-up the partitions in a round-robin method to effectively give more storage?

The SAN I use has over 20Tb of storage, but I'm effectively being limited to only 10% of this!

Any help much appreciated!


Solution

  • PHP will hand off to the OS to handle the details and report any errors.

    I'm assuming the problem isn't that any one single file is bigger than 2TB. but that you have thousands of files that are taking up all the partition that your web-server is on.

    If you need to use multiple partitions, you should split your uploads folder using something that will split nicely according to your requirements.

    You might want to know where a file is without having to trawl the whole uploads tree

    e.g. you could split by something like:
    - upload date /year/month,
    - starting letter of file or
    - round(user-id/100)

    Then you can mount different partitions within uploads. You could have a folder called uploads and within that you could mount other partitions

     mount /dev/sdb2 /var/www/html/myapp/uploads/2014   
     mount /dev/sdb3 /var/www/html/myapp/uploads/2015
    

    Initially you might have to transfer files from your old location to those new partitions so that the older uploads will be available under the new scheme.

    To php this is transparent, I have done similar things even with mounted smb shares. You'll have to make sure the right permissions/users are set up so that PHP can write to those folders.