Small SaaS US/EU Image Thumbnails: Object Storage, CDN, or Resize on Upload?
Short answer: keep the original and generated thumbnails in tenant-scoped object storage, and resize on upload when the thumbnail sizes are known and stable; use an image CDN when sizes or transformations are still changing, and do not put large media bytes through the application server.
That choice is less about image quality than about blast radius. A B2B SaaS serving customers in the US and EU needs a boring upload path, predictable storage keys, and a clear rule for who can read a thumbnail. The smallest architecture is the one that makes a tenant mix-up difficult to express.
The incident lesson: bytes are not application work
The production scenario I plan around is familiar: an upload request arrives, a worker generates a thumbnail, and a later retry runs the same job again. Missed jobs create missing previews. Duplicate deliveries create duplicate work. When I have been paged for both, the useful invariant was simple: the application should authorize and record a file, but it should not carry the file bytes through its request path.
The browser can upload directly to object storage using a short-lived, scoped upload capability. The application creates that capability after authenticating the user and checking the tenant. The browser then sends the large media file to storage. A completion event or explicit finalize call records the object, and a worker produces the thumbnail.
That split gives the system three independently testable boundaries. The API owns identity and policy. Object storage owns bytes and retention. The worker owns transformation. A failure in one boundary does not turn every upload into an application-server timeout.
The storage key is part of the security design, not a naming detail. I use a shape such as tenants/{tenantID}/assets/{assetID}/original and tenants/{tenantID}/assets/{assetID}/thumb/{profile}. The asset ID must be generated by the service, and a request must never be allowed to choose another tenant ID from the path without an authorization check. A private object plus an application-issued, expiring read URL is easier to reason about than a public bucket with hidden names.
The catch is that direct upload does not solve authorization by itself. A signed upload URL with a long lifetime, a reusable object key, or a completion endpoint that trusts browser metadata can still cross a tenant boundary. Test the negative case: tenant A must not upload to, finalize, or read tenant B's object, even when it knows the object ID.
How should a small SaaS choose object storage, an image CDN, or server resize on upload?
Start with the number of thumbnail variants the product actually needs. If the product has two fixed profiles, such as a small list preview and a detail preview, server resize on upload is usually the easiest operational choice. The worker creates those two derivatives once, records their keys, and every page reads a known object. There is no transformation decision hidden in a read request.
An image CDN is a better fit when the UI needs many widths, responsive delivery, format negotiation, or art-direction rules that are still moving. The source remains in private object storage, while the delivery layer derives or caches representations. That reduces migration pressure when design changes. It also adds another policy surface: the CDN cache key, origin access, invalidation behavior, and transformation limits all need an owner.
Keeping only the original and resizing inside the application on every request is the option I avoid for this scenario. It makes a thumbnail read expensive at exactly the moment a list page fans out across many assets. It also creates a cache and timeout problem in the web tier, where an image transformation competes with login, billing, and API traffic.
Here is the practical comparison:
| Approach | Good fit | Main operational cost | Tenant-isolation question |
|---|---|---|---|
| Resize on upload | A few stable sizes and a small team | Reprocessing when profiles change | Are source and derivative keys scoped by tenant? |
| Image CDN | Many sizes or frequent presentation changes | Cache, origin, and transformation policy | Can the delivery layer fetch only an authorized source? |
| Resize on read in the app | A prototype with little traffic | CPU, memory, and request latency | Can an image request bypass the same authorization as an API request? |
The recommendation changes when the workload changes. Stick with a CDN when responsive variants are a core product requirement. Use a separate media-processing pipeline when transformations are long-running or include video. Do not choose upload-time resizing just because the first implementation is short; choose it when the variant contract is stable enough that rebuilding derivatives is a controlled migration.
What does a tenant-safe thumbnail upload path look like?
The request sequence should be explicit:
- Authenticate the user and load the tenant from server-side membership data.
- Create an asset ID and the exact object key for the original.
- Issue a short-lived upload capability restricted to that key and expected content constraints.
- Let the browser upload directly to storage.
- Finalize only after the service verifies the object belongs to the expected tenant and asset.
- Enqueue thumbnail work using the asset ID as an idempotency key.
- Write each derivative to a deterministic key and mark its status in the database.
The worker should be safe to run twice. That is not an optimization. Queue delivery is often at-least-once, so a retry after a worker timeout must not create an unbounded set of files. A deterministic derivative key makes the second run a replace-or-confirm operation. The database record should also carry a generation or profile version, so a new thumbnail policy does not silently get mistaken for an old one.
The following Go sketch keeps the important policy in the application while leaving storage-specific signing behind an interface. It does not proxy the media body.
package thumbnails import ( "context" "fmt" ) type UploadGrant struct { URL string Object string Expires int64 } type ObjectStore interface { GrantUpload(ctx context.Context, objectKey string, maxBytes int64) (UploadGrant, error) Head(ctx context.Context, objectKey string) (int64, error) } type Asset struct { TenantID string AssetID string } func BeginUpload(ctx context.Context, store ObjectStore, asset Asset, maxBytes int64) (UploadGrant, error) { if asset.TenantID == "" || asset.AssetID == "" { return UploadGrant{}, fmt.Errorf("missing tenant or asset identity") } key := fmt.Sprintf("tenants/%s/assets/%s/original", asset.TenantID, asset.AssetID) return store.GrantUpload(ctx, key, maxBytes) } The sketch is intentionally incomplete at the storage adapter boundary. The adapter must bind the grant to the exact key, content limit, and expiry selected by the service. It must not accept a bucket or container name supplied by the browser. The finalize handler should also use a server-side asset lookup rather than reconstructing tenant ownership from request fields.
Where do failures hide after the first successful upload?
The happy path is not the runbook. Define states such as uploading, uploaded, processing, ready, and failed, then define which transitions are repeatable. A worker can safely claim uploaded twice if the output key is deterministic. A cleanup task can remove abandoned originals only after a retention window, because a slow client may still be finishing an upload.
Observe the boundaries separately. Count issued upload grants, completed uploads, rejected finalizations, processing attempts, derivative failures, and reads denied by tenant policy. Put the tenant ID in structured logs only when it is permitted by your privacy policy; never put the raw signed URL in logs. Track the asset ID and a request correlation ID instead.
Deletion needs the same discipline as creation. When a user deletes an asset, mark it deleted in the database first, revoke application access immediately, and remove original and derivative objects through an asynchronous task. Storage lifecycle rules can handle stale temporary objects, but they are not a substitute for authorization or a record of what the product believes exists. Object lifecycle management is useful precisely because abandoned intermediates are normal in upload systems, not because cleanup can be ignored.
For US/EU deployments, decide where tenant data is allowed to live before choosing a delivery pattern. A global CDN can make delivery faster while leaving the source in a regional storage location, but the exact data path, cache retention, and purge behavior need a written policy. Your mileage may vary here: residency requirements differ by customer contract and by the kind of metadata attached to an image. The decision cannot be inferred from a CDN's marketing label.
The decision rule I would put in the runbook
Choose upload-time resize with object storage when the team can name every thumbnail profile, accepts an asynchronous preview becoming ready, and can rebuild derivatives during a versioned migration. Keep the original private. Make the output key deterministic. Treat the worker as at-least-once.
Choose an image CDN when the product needs many responsive sizes or frequent transformation changes. Keep authorization at the origin boundary and document cache behavior before production. A cached image is still customer data; it does not become public because a proxy served it once.
Choose neither as a shortcut for an unclear data model. First write down the tenant, asset, original, derivative, and deletion relationships. The simplest architecture is the one whose failure modes fit the team's on-call capacity.

