We have a web platform that allows users to upload and download their data stored in a storage connected to Linux via NFS. currently about 350GB data is stored.
I want to show each user their current storage usage on the web in real time like Google drive or Dropbox when you update a file, the remaining disk space is shown right away.
My idea was to run du command on Linux and send an update query to DB but du takes so long.
Is there any better idea that I can do this on real time?
Thanks
Given that users are only allowed to upload or download data, the sizes of files stored will not change while on your storage server since "Edits" are not possible.
If you store the name and location of the file upon insert into a database, it would be wise to include the size of the file uploaded too. In php, you can do this with filesize().
This way, if you need to fetch the size of all the users files, all you need to do is grab all records owned by them, and add the file size column. This would give you a precise size of the users files, even if the files are located across different servers.