Photo Storage (Karat)

Difficulty: EASYCategory: HLDFrequency: 1Asked On 2025-05-01

Problem Statement

We are running a simple photo storage and sharing service. People upload their photos to our servers and then give links to other users who can then view them. Instead of using a cloud service, we have our own server farms. You've been tasked with creating an estimate of the storage required over the coming year and the cost of that storage


What information would you need and what factors would you consider as you generate this estimate?


Solution

To estimate the storage requirements and associated costs for a photo storage and sharing service over the coming year, we would need to analyze several critical factors. First, we should gather data on the current upload patterns — specifically, how many photos are uploaded per day or month, the average size of each photo, and how many active users are contributing these uploads. Understanding the growth trend of uploads over the past months is also crucial, as this helps project future storage needs based on user and usage growth. Next, the average file size plays a significant role; for instance, if users are uploading high-resolution images, the average storage per photo might be much higher than expected. Additionally, the retention policy must be considered — whether photos are stored indefinitely or archived/deleted after a certain period — as this directly impacts total storage requirements over time.


Another major factor is redundancy. If the system replicates each photo two or three times for fault tolerance, the raw storage requirement would multiply accordingly. Similarly, if backups are maintained separately, that adds to the overall storage consumption. It’s also important to examine access patterns: if older photos are rarely accessed, they can be moved to colder, cheaper storage tiers, which could significantly reduce costs. Compression and deduplication strategies must also be considered, as they can help lower the actual space consumed compared to the raw file sizes. Lastly, infrastructure overhead from the file system, metadata storage, and operational logs must be accounted for, as they often consume a non-trivial amount of disk space.


When estimating costs, we need to factor in the price per terabyte for the types of storage used — whether SSDs for fast access or HDDs for bulk storage — and also include related costs like power, cooling, rack space, and hardware maintenance. If the infrastructure is owned, CapEx and depreciation come into play, while in a leasing or hybrid scenario, monthly OpEx needs to be projected. Combining all these inputs allows us to build a reasonably accurate projection of both the physical storage needs and the financial cost required to support the service’s growth over the next year.

Comments