# Faster disk space calculation for upload heavy instances

**URL:** <https://meta.discourse.org/t/faster-disk-space-calculation-for-upload-heavy-instances/318997>\
**Category:** Feature\
**Tags:** performance, uploads, completed\
**Created:** [July 29, 2024, 11:17am UTC](https://meta.discourse.org/t/faster-disk-space-calculation-for-upload-heavy-instances/318997 "2024-07-29T11:17:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)\
**Post date:** [August 8, 2024, 2:07am UTC](https://meta.discourse.org/t/faster-disk-space-calculation-for-upload-heavy-instances/318997/2 "2024-08-08T02:07:01Z")

</div>

> [@Overgrow](#):
>
> was causing performance issues for my admin dashboard.

Do you have a rough idea how long the `du` was taking for you? I’m not really keen on this approach to resolve the performance issue and I think there are two alternatives:

1. Just use `Upload.sum(:filesize).to_i + OptimizedImage.sum(:filesize).to_i` to determine `uploads_used_bytes` like how we do for external stores.
2. Introduce a background job that periodically recalculates the bytes used by uploads and cache it in Redis.

Personally, I’m more keen on (1) as it is a much simpler solution. We do lose some accuracy but we don’t need 100% accuracy here. Still it will be much better than the approximation we get from `df`.

---

_[View the full topic](https://meta.discourse.org/t/faster-disk-space-calculation-for-upload-heavy-instances/318997)._
