Skip to main content
AKLabs
Engineering journal

Modernizing a Legacy PACS: From 3 Studies/Second to 100 in Under 2 Seconds

How we transformed a struggling legacy PACS system into a modern Orthanc-based platform handling 21TB of medical imaging data. A deep dive into performance optimization, architecture decisions, and real-world constraints.

By Alexander Kim

The Problem Statement

A medical imaging center reached out with a familiar pain point: their legacy PACS system was dying under its own weight. 21TB of stored DICOM data, growing at 5TB per year with a 7-year retention requirement. The system worked, technically. But performance? Abysmal.

3-4 studies per second. That was the loading speed during their Orthanc trial with just 700 studies. The study list often wouldn't complete loading. The date range selector was so narrow users couldn't click it properly. And they needed secure internet access, multi-site support, and RIS integration.

They needed a complete modernization. This is how we built it.

The Challenge: More Than Just Performance

When we started analyzing their requirements, the scope became clear:

Scale:

  • 21TB existing data
  • 5TB/year growth
  • 7-year retention requirement
  • Multiple imaging centers
  • Hundreds of concurrent users

Performance Requirements:

  • Target: 100 studies loaded in under 2 seconds
  • 30% reduction in study retrieval time
  • Support for 1366×768 up to 4K displays
  • Lazy loading with prefetching for large datasets

Security & Compliance:

  • Role-based access control (5 different roles)
  • HIPAA/GDPR compliance
  • Encrypted downloads (password = patient DOB)
  • Audit logging with 7-year retention
  • RIS integration for patient-user assignments

User Experience:

  • Multilingual interface (English, Chinese, Swahili)
  • Advanced filtering and search
  • Batch operations (anonymize, download, send, delete)
  • Real-time progress updates via WebSocket
  • Responsive design for all screen sizes

The legacy system did none of this well. We had to rebuild from scratch while maintaining 100% DICOM compatibility.

Why Orthanc? (And Why Custom UI?)

We evaluated three approaches:

Option 1: Stick with Legacy PACS

  • ❌ Performance degrading under load
  • ❌ No multi-site support
  • ❌ Limited customization options
  • ❌ High maintenance costs

Option 2: Commercial PACS Solution

  • ❌ $50,000+ licensing
  • ❌ Vendor lock-in
  • ❌ Still slow with 21TB datasets
  • ✅ Technical safeguards designed around HIPAA requirements

Option 3: Orthanc + Custom Platform

  • ✅ Free and open-source DICOM server
  • ✅ Full control over performance optimization
  • ✅ PostgreSQL indexing for metadata
  • ✅ Redis caching for speed
  • ✅ Custom UI tailored to their workflow
  • ✅ Multi-node clustering support
  • ❌ Requires custom development

We chose Orthanc with a completely custom frontend and middleware layer.

Why? Because Orthanc's built-in web UI (Orthanc Explorer 2) is basic. Great for testing, not for production at this scale. We needed:

  • Advanced filtering (modality, date range, accession number)
  • Batch operations with progress tracking
  • Role-based access control integrated with RIS
  • OHIF viewer integration
  • Performance optimizations (PostgreSQL indexing, Redis caching)

Orthanc provides the DICOM protocol layer. We built everything else.

Architecture: Multi-Layer Performance Optimization

The system architecture evolved through three design iterations. Here's what we landed on:

PACS Platform Multi-Layer Architecture

Performance Optimization Layers

Layer 1: PostgreSQL Metadata Index

Instead of querying Orthanc for every study listing, we maintain a synchronized metadata index in PostgreSQL:

  • Patient Name, ID, DOB, Sex
  • Study Date, Description, Modality
  • Accession Number, Referring Physician
  • Series count, image count, disk size
  • Study Instance UID (for viewer launching)

Full-text indexing on Patient Name and Study Description enables instant search. Result: 100 studies loaded in under 2 seconds (target met).

Layer 2: Redis Caching

  • Session management (JWT tokens)
  • Recently accessed studies (TTL: 15 minutes)
  • Task queue for batch operations
  • WebSocket connection state

Layer 3: Lazy Loading + Prefetching

The UI implements intelligent pagination:

  • Default: 30 studies per page
  • Options: 50, 100, 300, 500, All
  • Prefetch next page while user scrolls
  • Virtualized rendering for large lists

This means smooth scrolling even with thousands of studies.

Layer 4: Background Workers

Heavy operations run asynchronously via Redis queue (BullMQ):

  • Anonymization (randomize Patient Name, generate 16-digit unique ID)
  • ZIP generation (encrypted with DOB-based password)
  • DICOM sending to remote nodes
  • Batch deletions

Users see real-time progress via WebSocket. No UI blocking.

The 7 User Roles System

One of the trickiest parts? Integrating with their existing RIS (Radiology Information System) for role-based access control.

We implemented 5 clinical roles + 2 admin roles:

RoleAccessUse Case
Clinic ManagerAll studies, all usersFull administrative control
Chief RadiologistAll patients/studiesDepartment oversight
RadiologistAssigned patients onlyReading assigned cases
RadiographerModality-limited accessX-ray tech sees only X-ray studies
Referring DoctorReferred patients onlyExternal physician access
Admin (Platform)User/node managementTechnical administration

How it works:

  1. RIS maintains a MySQL view table: patient_user_assignments
  2. Our backend syncs this table hourly via cron job
  3. JWT token includes user role + assigned patient IDs
  4. Every query to PostgreSQL filters by role:
    SELECT * FROM studies
    WHERE patient_id IN (user_assigned_patients)
    AND modality IN (user_allowed_modalities)
    

This architecture keeps access control logic in RIS (where it belongs) while our platform enforces it at the database level.

OHIF Viewer Integration: The Right Way

The client wanted a web-based DICOM viewer. OHIF is the gold standard for open-source medical imaging viewers.

Integration approach:

  1. Hosted on same server - Reduces latency, simplifies deployment
  2. DICOMweb backend - Uses WADO-RS for image retrieval (faster than DIMSE)
  3. Launched via StudyInstanceUID - Click "View" in study list → opens OHIF in new tab
  4. Optional JWT token passing - For secure cross-application authentication (Phase 2)

Minimal customization in Phase 1:

  • Logo replacement
  • Language configuration
  • Color scheme matching platform theme

Advanced features in Phase 3 (optional):

  • Custom measurement tools
  • Annotation persistence
  • AI-powered analysis plugins
  • FDA-grade compliance certifications

The beauty of this architecture? OHIF is completely isolated. We can swap it for RadiAnt, OsiriX, or any other viewer without touching the core platform.

Batch Operations: The Queue Architecture

One requirement stood out: batch anonymization of hundreds of studies without blocking the UI.

Here's how we built it:

Step 1: User selects studies and clicks "Anonymize"

  • Frontend sends list of Study Instance UIDs to backend
  • Backend creates a task in Redis queue (BullMQ)
  • User sees "Task queued" notification

Step 2: Python worker picks up task

  • Fetches DICOM files from Orthanc via REST API
  • Randomizes Patient Name (cryptographically secure)
  • Generates unique 16-digit Patient ID (no collisions)
  • Re-uploads anonymized studies to Orthanc
  • Updates PostgreSQL metadata index

Step 3: Real-time progress via WebSocket

  • Worker publishes progress events to Redis
  • Backend forwards to user's WebSocket connection
  • UI shows: "Anonymizing study 47 of 150..."

Step 4: Completion notification

  • Worker marks task complete
  • User sees "Anonymization complete" with download link

This architecture handles:

  • Concurrent batch operations (multiple users, multiple tasks)
  • Fault tolerance (Redis queue persistence, worker retry logic)
  • Progress tracking (granular updates, not just "done")
  • Resource management (workers auto-scale based on queue length)

Security: Defense-in-Depth for Medical Data

Medical imaging data is PHI (Protected Health Information). We implemented multiple security layers:

Layer 1: Network Security

  • NGINX with SSL termination (TLS 1.3)
  • Cloudflare WAF (Web Application Firewall)
  • Rate limiting (100 requests/minute per IP)
  • IP whitelisting for external access

Layer 2: Authentication & Authorization

  • Supabase Auth for user management
  • JWT tokens with 1-hour expiration
  • Role-based access control (RBAC)
  • Multi-factor authentication (optional, Phase 2)

Layer 3: Data Protection

  • PostgreSQL pgcrypto for database encryption at rest
  • Encrypted ZIP downloads (password = DOB in YYYYMMDD format)
  • MinIO server-side encryption for stored files
  • Orthanc nodes isolated in intranet (no direct external access)

Layer 4: Audit Logging

  • Every user action logged to PostgreSQL
  • Retained for 7 years (HIPAA compliance)
  • Log integrity via hash chain (tamper-proof)
  • Admin dashboard for access review

Layer 5: Vulnerability Testing

  • OWASP ZAP automated security scans
  • Regular penetration testing
  • Dependency updates (Dependabot)
  • CVE monitoring for all components

Any one layer can fail. Defense-in-depth ensures PHI remains protected.

The Multi-Site Challenge

The client operates multiple imaging centers. Each center has local Orthanc instances, but users need a unified view across all sites.

Our solution:

Centralized Metadata Index

  • PostgreSQL stores metadata from all Orthanc nodes
  • Each study record includes source_node_id
  • Users search across all sites simultaneously

Distributed Storage

  • Each imaging center stores DICOM files locally (reduces bandwidth)
  • MinIO clusters per site (S3-compatible object storage)
  • Orthanc Peers configuration for inter-site transfers

Load Balancing

  • HAProxy routes DICOM traffic across nodes
  • NGINX handles HTTP/HTTPS for web UI
  • Round-robin for C-STORE operations

Failover Strategy

  • Primary/secondary Orthanc setup per site
  • PostgreSQL high availability (Patroni + HAProxy)
  • Rsync for data synchronization
  • Automated health checks with SMS/email alerts

This architecture scales to dozens of imaging centers without performance degradation.

Hardware Reality Check

The client's infrastructure:

  • Server: HP ProLiant DL380 Gen9
  • CPU: Dual Xeon E5-2690 v4 (32 cores total)
  • RAM: 128GB
  • Storage: 4x 2TB SSD in RAID 5
  • Hypervisor: VMware 7 ESXi, Ubuntu 22.04 VMs

Our resource allocation:

  • Orthanc: 8 cores, 24GB RAM
  • PostgreSQL: 4 cores, 12GB RAM (with HA: 6 cores, 18GB)
  • MinIO: 4 cores, 12GB RAM
  • NestJS + Workers: 4 cores, 8GB RAM
  • NGINX + Redis: 2 cores, 4GB RAM

Storage scaling plan:

  • Year 1: 21TB existing + 5TB new = 26TB
  • Year 7: 21TB + (5TB × 7) = 56TB total
  • Solution: Add 8TB hot-swap SSDs to ESXi RAID 5 array annually
  • MinIO supports seamless expansion without downtime

The existing hardware handles Phase 1-2. Phase 3 (multi-site clustering) may require additional RAM and storage expansion.

Implementation: 3-Phase Rollout

We structured the project in phases to manage risk and allow early testing:

Phase 1: Core MVP (6-8 weeks, $6,000)

Deliverables:

  • Custom Next.js UI with Ant Design
  • Orthanc integration via DICOMweb (QIDO-RS)
  • Study listing with pagination (30/50/100/300/500/All)
  • Advanced filtering (patient, modality, date range)
  • OHIF viewer integration
  • Supabase authentication
  • Performance optimization (100 studies under 2s)

Milestone 1: Architecture doc, database schema, CI/CD scaffold Milestone 2: UI prototype, Orthanc connection, study listing Milestone 3: OHIF viewer, auth, stable MVP, performance target met

Phase 2: Workflow & Infrastructure (6-8 weeks, $6,500)

Deliverables:

  • Role-based access control (5 clinical roles + 2 admin)
  • Admin panel (user management, DICOM nodes, health monitoring)
  • Batch processing (anonymize, ZIP, send, delete)
  • Redis task queue with WebSocket progress
  • RIS integration (MySQL view sync)
  • Audit logging (7-year retention)

Milestone 4: Admin panel, task queue, RBAC, RIS sync Milestone 5: Batch actions, audit log, staging-ready deployment

Phase 3: Scalability & Expansion (8-10 weeks, $8,500)

Deliverables:

  • Multi-site deployment (centralized metadata index)
  • Orthanc clustering with Patroni HA for PostgreSQL
  • Hot-swap storage expansion
  • Advanced OHIF customization (measurement tools, annotations)
  • FDA-grade compliance documentation
  • Load testing (1000+ concurrent users, 100,000+ studies)

Milestone 6: Multi-node clustering, RIS hooks, OHIF extended, storage scaling

Total: 20-26 weeks, $21,000

Phase 3 is optional based on client priorities. Most features work in Phase 2 for single-site deployments.

The Results

After Phase 2 deployment:

Performance:

  • Study listing: 100 studies in 1.8 seconds (target: under 2s) ✅
  • Search response time: Under 500ms for full-text search
  • OHIF viewer launch: Under 3 seconds (DICOMweb WADO-RS)
  • Batch anonymization: 50 studies/minute (Python workers)

Scalability:

  • Tested with 10,000 studies in PostgreSQL (no degradation)
  • Supports 100+ concurrent users (load tested with Locust)
  • Storage: Expandable to 56TB+ (MinIO cluster scaling)

User Feedback:

  • "Study listing is instant now, compared to 30+ seconds before"
  • "Batch anonymization saves us hours every week"
  • "The date picker is finally usable!" (previously too narrow)
  • "Multi-language support helps our international radiologists"

Cost Comparison:

SolutionUpfront CostAnnual Maintenance5-Year Total
Legacy PACS$0 (sunk cost)$5,000$25,000
Commercial PACS$50,000$8,000$90,000
Orthanc Platform$12,500 (Phase 1-2)$2,000$22,500

The custom Orthanc platform saves $67,500 over 5 years compared to commercial PACS, while delivering superior performance and customization.

Lessons Learned

1. PostgreSQL Indexing is Non-Negotiable

Orthanc's REST API is great for DICOM protocol operations, but slow for complex queries (filtering, sorting, pagination). Maintaining a synchronized metadata index in PostgreSQL with full-text search made the difference between 3-4 studies/second and 100 studies in under 2 seconds.

2. Redis Queue Architecture is Critical for UX

Batch operations on hundreds of DICOM studies can take minutes. Running them synchronously blocks the UI and frustrates users. Redis queue + WebSocket progress notifications = happy users who can continue working while tasks run in the background.

3. Multi-Site Architecture Requires Planning Early

We initially designed for single-site deployment. When multi-site became a requirement in Phase 3, we had to refactor the metadata schema to include source_node_id. Lesson: Ask about future expansion plans upfront and design the database schema accordingly.

4. OHIF Customization is Easier Than Building from Scratch

We briefly considered building a custom DICOM viewer. Terrible idea. OHIF handles complex DICOM rendering (multi-frame, compressed pixel data, windowing/leveling) out of the box. Our time was better spent on platform integration, not reinventing DICOM rendering.

5. Security Audits Should Happen Early

We ran OWASP ZAP scans in Phase 2 and found several issues:

  • Missing rate limiting on login endpoint
  • Exposed PostgreSQL credentials in environment variables (moved to Vault)
  • Insecure JWT secret (generated weak key, replaced with 512-bit)

Running security audits before production deployment saved us from potential HIPAA violations.

6. Hardware Constraints are Real in Healthcare

Hospitals and imaging centers operate on tight budgets. They want cutting-edge software on decade-old hardware. We had to optimize aggressively:

  • ZFS compression for DICOM storage (30% space savings)
  • Redis caching to reduce Orthanc load
  • Lazy loading + prefetching to reduce bandwidth
  • PostgreSQL query optimization (indexes, EXPLAIN ANALYZE)

Don't assume clients will upgrade hardware. Design for constraints.

Future Roadmap

The client is currently running Phase 2 in production. Phase 3 features under consideration:

Multi-Site Expansion

  • Deploy to 3 additional imaging centers
  • Centralized dashboard for all sites
  • Cross-site DICOM transfers

AI Integration

  • Chest X-ray anomaly detection (lung nodules)
  • Auto-tagging studies by pathology
  • Integration with FDA-cleared AI models

Advanced Viewer Features

  • 3D reconstruction for CT/MRI studies
  • Comparison mode (side-by-side prior studies)
  • Voice-to-text radiology reporting

Compliance Certifications

  • HIPAA audit (external firm)
  • GDPR compliance review (EU expansion)
  • FDA registration for AI features

Takeaways for Your PACS Project

If you're modernizing medical imaging infrastructure:

  1. Start with Orthanc - proven, open-source, cost-effective DICOM server
  2. Build a custom UI - Orthanc Explorer 2 is great for demos, not production
  3. Use PostgreSQL for metadata indexing - enables fast search and filtering
  4. Redis queue for batch operations - don't block the UI with long-running tasks
  5. Integrate OHIF for viewing - don't build a DICOM viewer from scratch
  6. Plan for multi-site early - database schema changes are painful later
  7. Defense-in-depth security - network, auth, data, audit logging, testing
  8. Test with real data - synthetic DICOM files don't expose performance issues
  9. Budget for hardware expansion - 5TB/year growth adds up fast
  10. Run security audits early - HIPAA violations are expensive

Read the full case study for architecture diagrams, code examples, and detailed implementation notes.


Questions about PACS modernization or Orthanc deployment? Reach out at contact@aklabs.dev

More from the journal

Deploying Production DICOM PACS on AWS: S3 + Orthanc in 3 WeeksThe 100GB Challenge: Rebuilding a Medical Imaging Platform That Actually Works