Skip to main content
AKLabs
Engineering journal

The 100GB Challenge: Rebuilding a Medical Imaging Platform That Actually Works

Real-world experience building a production-grade DICOM routing platform for US telemedicine. From a dying MVP to handling 100GB+ daily with FastAPI microservices.

By Alexander Kim

"Can you handle 100GB of medical data per day?"

That was the question in the initial message. The client had an MVP - a DICOM routing system for telemedicine platforms in the US. It worked, technically. But under real-world load? It was dying. They needed it rebuilt from scratch, and it had to be in Python for licensing reasons.

When I opened their codebase, I understood why they were desperate.

The Broken MVP

A handful of Python files. Everything running on async FastAPI. Sounds modern, right? Except they were using async FastAPI for everything - including heavy I/O operations like writing files, moving data, uploading to S3. That's not what FastAPI is designed for. The server was choking on file operations, blocking on uploads, dying under concurrent requests.

The client's use case made it worse: this was a B2B SaaS platform for telemedicine. Some customers had one small clinic with a few imaging devices. Others had distributed networks with dozens of machines pumping out studies 24/7. Unpredictable load. No way to scale the current setup.

But here's the thing - they didn't just need "optimization." They needed real architecture.

The Weekly Planning Calls

We started meeting multiple times a week. The client knew what they wanted functionally - DICOM routing, storage, configuration via API - but the "how" was open. I had full freedom on architecture.

I proposed microservices. Two options: Celery or FastStream.

Celery is the industry standard, but I'd worked with it before. Lots of configuration. Hard to scale when you have many nodes - each needs separate setup. Heavy.

FastStream felt more natural for FastAPI's async philosophy. Modern. Works cleanly with Redis. And here's the key: I chose Redis Streams instead of basic queues. Redis Streams are like a lightweight Kafka - they keep message history. In healthcare, where everything needs to be logged and auditable, this felt right. Plus, debugging distributed systems is much easier when you can look back at the message history instead of watching events disappear into the void.

The client gave me carte blanche on architecture. I kept some pieces of the old code in the services, but rewrote most of it into a modular microservices design.

Building the Node System

I started with the basics: receiving DICOM files (SCP) and storing them. Then gradually added nodes for sending (SCU), uploading to S3, routing logic.

The beautiful thing about the architecture? It was extensible. Want AI processing? Add a node. Want internal storage instead of S3? Add a node. The core routing logic didn't need to change. The client mentioned future features like AI analysis - I knew we could plug them in without touching the foundation.

The 7 Microservices

We ended up with 7 independent nodes:

  1. SCP Receiver - Accepts incoming DICOM studies
  2. SCU Sender - Sends DICOM to destinations
  3. S3 Uploader - Cloud storage integration
  4. Metadata Extractor - Parses DICOM tags
  5. Router - Routing logic based on rules
  6. Coordinator - Prevents race conditions
  7. API Server - FastAPI REST interface

Each communicates via Redis Streams. Simple. Modular. Scalable.

The Windows Disaster

Everything was going smoothly. I'd designed the system to deploy with Docker - easier than Kubernetes, simpler than bare metal installs. We tested with synthetic DICOM files first, then I built a dataset of 1000+ real files from various sources online. Then the client's real data. Mostly worked. Some legacy formats gave us trouble - rare or customized files that the pydicom library refused to handle. We logged those but never fully solved it. Edge cases in medical imaging are unavoidable.

Then came the curveball:

"Can you make a Windows installer?"

One clinic had old computers. Windows machines. Okay, Docker works on Windows, technically. I could even write an installer that deploys Docker containers. But then the problems started:

  • Library conflicts between Windows and Linux containers
  • Different ways of mounting external folders
  • Docker resource metrics calculated differently
  • WSL2 weirdness

Then the worst request: "Can you install it on old Windows without Hyper-V support?" No virtualization. No Docker.

I pushed back. Hard. Convinced them to use Ubuntu. That battle I won.

But another problem emerged: weak hardware. Some hospitals were running on ancient machines. Docker itself needs several GB of RAM. Spin up multiple microservice containers? Weak systems just froze.

In my mind, if you're deploying microservices, spend a little money on infrastructure. But hospitals are conservative about this stuff. They want cutting-edge medical software on decade-old computers.

This is where I learned: beautiful architecture meets ugly reality in healthcare IT.

Race Conditions and Coordination

The trickiest technical problem? Race conditions across distributed workers.

When multiple nodes are processing the same DICOM study - one receiving, one anonymizing, one uploading to S3 - you need coordination. What if the metadata gets written to PostgreSQL before the file finishes uploading to S3? What if two workers try to move the same file?

I built a coordination class in Redis. Each node marks its progress. Only after all nodes complete their part does the system finalize - delete temp files, update database, mark as complete.

class StudyCoordinator:
    def __init__(self, redis_client):
        self.redis = redis_client

    async def acquire_lock(self, study_uid: str) -> bool:
        key = f"lock:study:{study_uid}"
        return await self.redis.set(key, "1", nx=True, ex=300)

    async def mark_node_complete(self, study_uid: str, node_name: str):
        await self.redis.sadd(f"study:{study_uid}:completed", node_name)

    async def all_nodes_complete(self, study_uid: str) -> bool:
        required_nodes = {"scp", "metadata", "s3", "router"}
        completed = await self.redis.smembers(f"study:{study_uid}:completed")
        return required_nodes.issubset(completed)

Detailed logging and metrics everywhere. Because debugging microservices is always about tracing communication between nodes. Redis Streams' history saved me multiple times during this phase.

Load Testing with HAProxy

HAProxy was in the original requirements. I needed to prove the system could handle concurrent load.

frontend dicom_frontend
    bind *:11112
    mode tcp
    default_backend dicom_backend

backend dicom_backend
    mode tcp
    balance roundrobin
    server scp1 127.0.0.1:11113
    server scp2 127.0.0.1:11114
    server scp3 127.0.0.1:11115

I wrote scripts to blast DICOM files in 20 parallel threads. The system stayed stable at 5 concurrent requests per SCP node. Need more? Spin up additional nodes. I tested up to 20 parallel streams - smooth.

That's peak load, though. In real hospital usage, the load is much lower and spread out. A few studies here and there. The system was more than ready.

Production

We deployed to the first clinic. It worked. Handles their daily load without issues. Now the client wants to expand it into a true multi-tenant SaaS solution - sell it to more clinics as a service.

The architecture proved its worth. We can add new features (AI processing, custom storage backends, advanced routing rules) without touching the core system. Just add nodes.

What I Learned

1. Microservices aren't free

The architecture is flexible and scalable, but you pay for it in deployment complexity. Docker resource usage. Coordination overhead. If your client has weak infrastructure, that's a real problem.

2. Healthcare IT is conservative

They want modern software. On old hardware. With Windows XP. Without upgrading. You have to push back on impossible requirements, but you also have to meet them halfway.

3. Redis Streams are underrated

Everyone uses basic queues or goes straight to Kafka. Redis Streams hit a sweet spot - message history, good performance, simpler than Kafka. Perfect for medical systems where auditability matters.

4. FastStream > Celery (for this use case)

Celery is proven, but FastStream felt more natural with FastAPI's async patterns. Less configuration. Easier to scale. Modern. No regrets on this choice.

5. The UI always grows

"Just make something simple" always becomes "can you add 10 more features?" Plan for it. What started as a basic dashboard became a full monitoring system with graphs, logs, configuration screens, animations, progress bars, and file management.

6. DICOM is a beast

3000+ pages of specification. Legacy formats. Vendor-specific implementations. Compressed pixel data. Edge cases everywhere. You learn by doing. I found datasets online, tested with real hospital data, logged every failure. That's how you learn DICOM - through painful trial and error.

7. Extensible architecture pays off

Starting with a node-based design where you can plug in new functionality without touching the core? That was the win. The client keeps coming back with "can we add X?" and the answer is always "yes, add a node."

The Result

The system works. One clinic in production, more coming. The client is happy. I proved that you can build a production-grade DICOM routing system with modern Python tools - FastAPI, FastStream, Redis Streams - and have it actually handle real-world healthcare load.

Would I do anything differently?

Maybe consider the Windows deployment story earlier. Maybe push harder on hardware requirements upfront. Maybe build more automated tests (though manual testing worked fine given the timeline).

But the architecture? The technology choices? I'd make the same decisions again.


Tech Stack

  • FastAPI - Async API server
  • FastStream + Redis Streams - Microservices communication
  • PostgreSQL - Metadata storage
  • Redis - Coordination, queuing, caching
  • pynetdicom / pydicom - DICOM protocol
  • HAProxy - Load balancing
  • Docker - Deployment
  • React + Ant Design - UI

Final Stats

  • 7 microservices
  • 155 Python modules
  • 400-500 hours over 4 months
  • Handles 100GB+ daily DICOM data
  • 5+ concurrent SCP connections per node
  • Production deployment in US telemedicine clinic

Read the full case study for architecture diagrams and deeper technical details.


Questions? Thoughts? Reach out at contact@aklabs.dev

More from the journal

Deploying Production DICOM PACS on AWS: S3 + Orthanc in 3 WeeksModernizing a Legacy PACS: From 3 Studies/Second to 100 in Under 2 Seconds