Problem: Files fill up the server, performance drops
When users upload photos, documents, or videos directly to the application server, the disk quickly fills up. Response time spikes as the database and logs compete for I/O. The server trades performance for storage, users complain about slow loading, and the budget goes into expanding disks. An average site with 500 uploads per day fills 100 GB in a week; highload projects with 10,000 uploads fill it in a couple of days. Our team, with experience in highload, offloads storage to S3-compatible objects: AWS S3 or MinIO.
How does object storage work?
S3-compatible storage keeps files separate from the application server. The server only generates temporary URLs for upload and download. This reduces CPU and network load and simplifies scaling. For dev environments, we use MinIO—a self-hosted alternative to AWS S3 with an identical API. It starts in Docker in 5 minutes, which is 10 times faster than setting up S3 through the AWS console.
AWS S3: Terraform configuration
resource "aws_s3_bucket" "uploads" {
bucket = "myapp-uploads-production"
}
resource "aws_s3_bucket_public_access_block" "uploads" {
bucket = aws_s3_bucket.uploads.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
resource "aws_s3_bucket_versioning" "uploads" {
bucket = aws_s3_bucket.uploads.id
versioning_configuration { status = "Enabled" }
}
resource "aws_s3_bucket_server_side_encryption_configuration" "uploads" {
bucket = aws_s3_bucket.uploads.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_lifecycle_configuration" "uploads" {
bucket = aws_s3_bucket.uploads.id
rule {
id = "move-to-glacier"
status = "Enabled"
transition {
days = 90
storage_class = "GLACIER"
}
expiration {
days = 365
}
filter {
prefix = "temp/"
}
}
}
Presigned URLs for secure upload
The client uploads the file directly to S3, bypassing the server. The server generates a presigned URL with a limited lifetime. This is a standard approach for SaaS products.
// Laravel controller + usage example
use Aws\S3\S3Client;
class FileUploadController extends Controller
{
public function presign(Request $request): JsonResponse
{
$request->validate([
'filename' => 'required|string|max:255',
'content_type' => 'required|string',
]);
$key = 'uploads/' . auth()->id() . '/' . Str::uuid() . '/' .
pathinfo($request->filename, PATHINFO_BASENAME);
$s3 = app('aws')->createClient('s3');
$command = $s3->getCommand('PutObject', [
'Bucket' => config('filesystems.disks.s3.bucket'),
'Key' => $key,
'ContentType' => $request->content_type,
'ACL' => 'private',
]);
$presigned = $s3->createPresignedRequest($command, '+15 minutes');
return response()->json([
'upload_url' => (string) $presigned->getUri(),
'key' => $key,
]);
}
}
// In another part of the application:
$path = Storage::disk('s3')->putFile('uploads', $request->file('photo'));
$url = Storage::disk('s3')->temporaryUrl($path, now()->addMinutes(60));
How presigned URLs reduce server load?
Without presigned URLs, each file passes through the web server—reading the request, buffering the body, and sending to S3. This consumes CPU and memory, especially during parallel uploads. Presigned URLs turn the client into the direct data sender. The server only issues the key and URL, and S3 handles the heavy lifting. In one project, we replaced local storage with S3: with 10,000 uploads per day, LCP dropped from 4.2 to 1.8 seconds. Clients receive files directly from the CDN.
MinIO: self-hosted deployment
docker-compose.yml
services:
minio:
image: minio/minio:latest
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: ${MINIO_PASSWORD}
volumes:
- minio_data:/data
ports:
- "9000:9000"
- "9001:9001"
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 10s
volumes:
minio_data:
MinIO has an identical AWS S3 API—just change the endpoint. Connection configuration:
# .env
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=miniopassword
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=uploads
AWS_URL=http://minio:9000
AWS_ENDPOINT=http://minio:9000
AWS_USE_PATH_STYLE_ENDPOINT=true
// config/filesystems.php (Laravel)
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => true,
],
AWS S3 vs MinIO comparison
| Parameter | AWS S3 | MinIO |
|---|---|---|
| Deployment | Cloud-managed | Self-hosted (Docker/K8s) |
| Durability | 99.999999999% | Depends on configuration, up to 99.999% with replication |
| Price | Depends on volume, ~$0.023/GB/month | Free (only hardware) |
| Management | AWS Console | Web console or CLI |
How to set up lifecycle rules for automatic cleanup?
Lifecycle rules automatically move old files to cold storage or delete them. For AWS S3, this is done via Terraform (example above) or the console. In MinIO, rules are set via the mc CLI—for example, mc ilm rule add local/uploads --expire-days 365. This is especially useful for temporary files (avatars, logs)—they don't clutter storage or increase costs.
Why choose S3 over local disk?
Local disk delivers 50–100 IOPS, S3 delivers thousands. In one project, we replaced local storage with S3: with 10,000 uploads per day, LCP dropped from 4.2 to 1.8 seconds. Clients receive files directly from the CDN.
What's included in turnkey work?
- Audit of current file structure
- Bucket and access policy configuration
- Presigned URL implementation (Laravel / Node.js)
- MinIO deployment (Docker) or migration to AWS S3
- Lifecycle rules for automatic cleanup
- Integration with existing storage (Laravel Filesystem, Flysystem)
- Monitoring: size, file count, errors
- Documentation on access and upload process
Implementation timelines
| Option | Time |
|---|---|
| S3 + presigned URLs (Laravel/Node.js) | 1–2 days |
| MinIO self-hosted (Docker) | 1 day |
| Full lifecycle + monitoring | 3 days |
Cost is calculated individually—contact us to evaluate your project. We guarantee compatibility with your stack.
Your experience—our guarantee
Experience with object storage: over 50 projects. Certified AWS engineers. Get a consultation—describe your task, and we'll offer the best solution. Reach out to discuss your project details.
Article written based on real experience (Wikipedia S3 and Amazon S3).







