Skip to main content

sapoche

Overview

  • Namespace: sapoche
  • Purpose: Main Sapoche application and microservices
  • Age: ~2 years
  • Status: Active - Largest application in cluster
  • Workloads: 38 deployments (36 active, 2 scaled to 0)

Architecture

Sapoche is the core medical platform with multiple components:

  • Consumers: Event consumers for various integrations
  • Workers: Background job processors
  • Backend Services: PHP-based application servers
  • Supporting Services: Redis, DICOM viewers, design system

Workload Categories

Event Consumers (13 deployments)

Consume events from message queues for various integrations:

NameReplicasPurpose
consumer-dicom1/1DICOM medical imaging
consumer-ecg1/1ECG data processing
consumer-employee1/1Employee data sync
consumer-lis-testresult1/1Lab test results
consumer-pat-dtc-homekit-register1/1Patient homekit registration
consumer-pat-test-result-update1/1Patient test result updates
consumer-revenue0/0Revenue processing (scaled to 0)
consumer-rfd-push-notification1/1RFD notifications
consumer-spc-aborted-booking1/1Aborted booking handling
consumer-spc-checkup-orders1/1Checkup order processing
consumer-spc-pdf-generate1/1PDF generation
consumer-spc-pdf-generate-examination1/1Examination PDF generation
consumer-spc-pos-orders1/1POS order processing
consumer-spc-sync-test-master-data1/1Test master data sync

Background Workers (16 deployments)

Process async jobs, generate PDFs, send notifications:

NameReplicasPurpose
worker-booking1/1Booking operations
worker-sapoche-batch-publisher1/1Batch job publisher
worker-sapoche-batch-publisher-notification0/0Batch notifications (scaled to 0)
worker-sapoche-checkup-audit-history1/1Checkup audit logging
worker-sapoche-default1/1Default worker queue
worker-sapoche-event-tracking1/1Event tracking
worker-sapoche-examination-audit-history1/1Examination audit logging
worker-sapoche-export-csv1/1CSV export generation
worker-sapoche-imaging-report1/1Medical imaging reports
worker-sapoche-notifications1/1General notifications
worker-sapoche-notifications-refdoc1/1Reference doctor notifications
worker-sapoche-pdf1/1PDF generation (general)
worker-sapoche-pdf-en1/1PDF generation (English)
worker-sapoche-pdf-svip-regen1/1SVIP PDF regeneration
worker-sapoche-pdf-svip11/1SVIP tier 1 PDFs
worker-sapoche-pdf-svip21/1SVIP tier 2 PDFs
worker-sapoche-pdf-vip11/1VIP tier 1 PDFs

Backend Application Services (5 deployments)

Main application servers:

NameReplicasPurpose
st-bnkd-php3/3PHP application backend (3 replicas)
st-bnkd-php-nginx3/3Nginx frontend for PHP (3 replicas)
redis-master-st-sp1/1Redis cache for application
sapoche-be--scheduler--stag1/1Task scheduler
orthanc-read-api1/1Orthanc DICOM API (with sidecar)

Frontend Services (2 deployments)

NameReplicasPurpose
diag-design-system-nginx1/1Design system/component library
diag-dicom-viewer-nginx1/1DICOM medical image viewer

Services

NameTypeCluster IPPortsPurpose
st-bnkd-phpClusterIP10.27.183.1879000, 80PHP application
st-sapoche-nginxClusterIP10.27.41.3980Nginx proxy
st-redis-spClusterIP10.27.62.1676379Redis cache
diag-design-system-nginxNodePort10.27.254.17180:30788Design system
diag-dicom-viewer-nginxNodePort10.27.16.17380:30120DICOM viewer
orthanc-read-api-serviceNodePort10.27.18.8480:30635Orthanc API

Access & Management

View all resources:

kubectl get all -n sapoche

Check specific workload type:

# All consumers
kubectl get pods -n sapoche | grep consumer

# All workers
kubectl get pods -n sapoche | grep worker

# Backend services
kubectl get pods -n sapoche | grep -E "st-bnkd|redis|scheduler"

View logs:

# Consumer logs
kubectl logs -f deployment/consumer-lis-testresult -n sapoche

# Worker logs
kubectl logs -f deployment/worker-sapoche-pdf -n sapoche

# Backend logs
kubectl logs -f deployment/st-bnkd-php -n sapoche

Scale workloads:

# Scale backend replicas
kubectl scale deployment st-bnkd-php -n sapoche --replicas=5

# Scale workers
kubectl scale deployment worker-sapoche-pdf -n sapoche --replicas=2

Restart services:

# Restart all backend pods
kubectl rollout restart deployment st-bnkd-php -n sapoche

# Restart specific consumer
kubectl rollout restart deployment consumer-lis-testresult -n sapoche

Monitoring

Resource usage:

kubectl top pods -n sapoche --sort-by=memory
kubectl top pods -n sapoche --sort-by=cpu

Check deployment status:

kubectl get deployments -n sapoche

View events:

kubectl get events -n sapoche --sort-by='.lastTimestamp' | head -20

Data Flow

External Requests

APISIX Gateway (other namespace)

st-sapoche-nginx (10.27.41.39:80)

st-bnkd-php-nginx (load balancer, 3 replicas)

st-bnkd-php (PHP application, 3 replicas)

st-redis-sp (cache)

External Databases / Storage

Events → Consumers → Process → Workers → Background Jobs → Notifications/PDFs

Special Components

Orthanc DICOM Server

  • Medical imaging server (PACS)
  • Read-only API exposed on NodePort 30635
  • Stores and retrieves DICOM images (X-rays, CT scans, MRI, etc.)

DICOM Viewer

  • Web-based medical image viewer
  • Exposed on NodePort 30120
  • Displays DICOM images from Orthanc

Design System

  • Shared UI component library
  • Exposed on NodePort 30788
  • Used across multiple applications

Recommendations

  1. High Availability:

    • Backend: 3 replicas (good)
    • x Most consumers/workers: 1 replica (consider 2+ for critical ones)
    • x Redis: 1 replica (consider Redis Sentinel or cluster mode)
  2. Scaling:

    • Backend auto-scales well with manual intervention
    • Consider HPA for:
      • st-bnkd-php (CPU-based)
      • Critical workers (queue depth-based with KEDA)
  3. Monitoring:

    • Monitor queue depths for consumers
    • Track PDF generation times
    • Monitor Redis memory usage
    • Alert on consumer failures
  4. Resource Optimization:

    • Review inactive deployments (consumer-revenue, worker-batch-publisher-notification scaled to 0)
    • Consider removing if permanently unused
  5. Logging:

    • Centralize logs from all 38 deployments
    • Implement structured logging
    • Track error rates per component

Troubleshooting

Consumer not processing:

# Check consumer logs
kubectl logs -f deployment/consumer-lis-testresult -n sapoche

# Check if connected to message queue
kubectl exec -it deployment/consumer-lis-testresult -n sapoche -- env | grep QUEUE

# Restart consumer
kubectl rollout restart deployment/consumer-lis-testresult -n sapoche

Worker backlog:

# Check worker logs
kubectl logs deployment/worker-sapoche-pdf -n sapoche --tail=100

# Scale up workers temporarily
kubectl scale deployment/worker-sapoche-pdf -n sapoche --replicas=3

# Check Redis queue depth
kubectl exec -it deployment/redis-master-st-sp -n sapoche -- redis-cli LLEN queue_name

PHP application issues:

# Check PHP pods
kubectl get pods -n sapoche | grep st-bnkd-php

# Check PHP logs
kubectl logs -f deployment/st-bnkd-php -n sapoche

# Check Nginx logs
kubectl logs -f deployment/st-bnkd-php-nginx -n sapoche

# Execute into PHP pod
kubectl exec -it deployment/st-bnkd-php -n sapoche -- bash

DICOM issues:

# Check Orthanc API
kubectl logs -f deployment/orthanc-read-api -n sapoche

# Test Orthanc API
kubectl port-forward -n sapoche service/orthanc-read-api-service 8042:80
# Access http://localhost:8042

Performance Considerations

  • Backend: 3 replicas handle concurrent requests
  • Workers: Process jobs asynchronously to avoid blocking
  • Consumers: Real-time event processing from message queues
  • Redis: In-memory cache for fast data access
  • PDF Generation: Multiple specialized workers for different tier levels

Dependencies

  • Message Queue: Likely Redpanda or Kafka (in separate namespace)
  • Databases: External MySQL/PostgreSQL
  • Object Storage: For DICOM images and PDFs
  • Redis: In-namespace cache