Valet Key Design Pattern in 30 Seconds
Tags: cloudcomputing, technology, googlecloudplatform, designpatterns
Published: 2022-08-24 11:47:30

---
title: Valet Key Design Pattern in 30 Seconds
published: true
date: 2021-11-18 14:12:02 UTC
tags: cloudcomputing,technology,googlecloudplatform,designpatterns
canonical_url: https://medium.com/javarevisited/valet-key-design-pattern-in-30-seconds-4ab0715c7416
---

#### Do not waste your applications resources on big uploads.

![](https://cdn-images-1.medium.com/max/1024/1*VCTMbAPumFQnIiEHfRwa0g.jpeg)
_Photo by Old Money on Unsplash_

Routing large up- and downloads through your application absorbs valuable resources like bandwidth and CPU time. After the service authenticated the upload request, it uploads data to a storage system like Amazon S3 or Google Cloud Storage. Authentication is fast. **The service wastes most of its time while it waits for the file to be saved by the storage system.**

[![](https://cdn-images-1.medium.com/max/418/1*YgXElATpbbp92oNdIYUseQ.png)](https://www.java67.com/2018/05/top-20-system-design-interview-questions-answers-programming.html)
_The service wastes most of its time while it waits for the file to be saved by the storage system.Uploading via the service locks resources._

**Why waste so much valuable time?** The Valet Key Pattern creates a remedy for this problem.

Clients do not call your service anymore to upload things. They only call your service to get a specialized key with limited validity. Then, they use this key to upload their data directly to the storage system. The storage system must be able to verify that the key is valid. In this way, your application will not have to wait for the upload.

[![](https://cdn-images-1.medium.com/max/384/1*prEaN8gejARdz0xLxPOa9Q.png)](https://www.java67.com/2019/09/top-5-courses-to-learn-system-design.html)
_Use the Valet Key Pattern to reduce load on your system._

On the downside, you lose some control over your storage system. You have to ensure that the key has the lowest possible scope. Limit the maximum upload size, the reusability of the key and its validity. If possible, make the client notify you after the upload is finished, so that you can invalidate the key right away.

Do not forget to validate and sanitize all uploaded data before using it. You can achieve this with an own service which regularly scans all new uploads.

Use this pattern only if clients must upload extensive files often. It will save you resources. And this will save you money.

_Want to learn more about Cloud Design Patterns? Check out these articles:_

- [Fabulous Claim-Check Design Pattern explained in just one minute](https://medium.com/javarevisited/fabulous-claim-check-design-pattern-explained-in-just-one-minute-5bac14df0edc)
- [Circuit Breaker Pattern in 30 seconds](https://medium.com/javarevisited/circuit-breaker-pattern-in-30-seconds-79166ddedaed)
- [4+1 helpful and important Cloud Design Patterns explained in short time](https://medium.com/javarevisited/4-really-helpful-and-important-cloud-design-patterns-explained-in-short-time-4b087bebb97b)

* * *

**If this article was helpful for your, please consider to buy me a coffee :-)**
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y1EKYJI)