Parking management system

CLIENT

Parking

SERVICES

Backend Development

TECHNOLOGIES

  • .NET
  • SQL Server,
  • MongoDB
  • Azure Cloud

Case studies

Other usecases

Description

A transport client in Norway operating multi-site parking systems faced scaling limitations, unstable operations, and rising cloud spend. As the business prepared for regional expansion, we had to stabilize production while reducing costs and addressing technical debt.

screenshot

Lars Kaasin
"Daniel is a highly professional and hardworking consultant. His strong performance, keen attention to detail, and dedication to delivering quality results made him a reliable and valued contributor to the team."
Lars KaasinProject Manager

Key Achievements:

  • Performance & Stability: Reduced MongoDB long-running queries from 15 minutes to 10 seconds; improved fast-path reads from ~400ms to ~250ms
  • Reliability: Brought production down to ~3 errors/month (from 500+ daily errors previously observed)
  • Cost Optimization: Cut Azure SQL and MongoDB Cloud costs by optimizing queries and right-sizing compute
  • Delivery: Launched a new microservice for a separate client segment, supporting multi-country rollout
  • Dev Efficiency: Unified branching for PROD/TEST, fixed integration tests, and stabilized CI/CD

Original context

The legacy system accumulated issues that directly impacted reliability and cost:

  1. Concurrency: Missing database transactions led to invalid state and frequent exceptions
  2. Monitoring: High error volume and uncorrelated logs made debugging slow and reactive
  3. Operational Costs: Inefficient SQL/MongoDB usage inflated Azure and MongoDB Cloud spend
  4. Technical Debt:
    • 700+ static references made testing and environment switching hard
    • 264 test suites incomplete or failing
    • Manual migrations and inconsistent integration tests
  5. Development Inefficiencies:
    • Separate PROD/DEV branches requiring manual rebases
    • Incomplete pipelines slowed delivery and increased risk

The rewriting problems

While not a greenfield rewrite, the live system’s state created production risk and slowed delivery. Query performance and logging noise masked real issues and inflated spend.

MongoDB queries duration distribution over 24h - before
MongoDB queries duration distribution over 24h - before
MetricBeforeAfter
Longest Query Duration15 minutes10 seconds
Average Fastest Query~400ms~250ms
MongoDB queries duration distribution over 24h - after
MongoDB queries duration distribution over 24h - after

Further bottlenecks were identified but deferred due to priorities.

Investigation & Discovery

To gain control in production without halting delivery, we:

  • Introduced correlation context to stitch logs across operations and services
  • Collected targeted metrics and query plans for the top 15 SQL queries
  • Profiled MongoDB slow queries and access patterns
  • Isolated integration scenarios with Testcontainers to reproduce issues deterministically
  • Established end-to-end checks for regression detection

Solution Approach

We stabilized first, then optimized iteratively with minimal risk:

  • Enhanced Monitoring
    • Added correlation IDs to enable end-to-end traceability and reduce MTTR
  • Azure SQL Optimization
    • Refactored hot paths and added minimal indexes guided by execution plans to balance I/O vs CPU
  • MongoDB Query Improvements
    • Tuned indexes and query shapes, cutting worst cases from minutes to seconds and improving p50 read latency
  • Branching & Delivery
    • Adopted a single branch for PROD/TEST to remove manual rebases and align environments
    • Repaired integration tests and completed CI/CD pipelines to reduce regressions

New developments

To unlock a new revenue stream, we built a dedicated microservice for rental vehicle data ingestion, regulatory compliance, client-facing API documentation, invoicing, and isolated infrastructure per market.

screenshot

The average query time was ~80ms; end-to-end latency was higher due to cross-cloud hosting (Azure app, Google-hosted DB) imposed by external constraints.

Architectural Approach

  • Domain-Driven Design for country-specific parking rules
  • CQRS to separate reads/writes and enable scale and caching
  • Test-Driven Development to ensure correctness despite tight timelines
  • MongoDB as the primary data store for flexible, high-throughput workloads

The microservice comprised:

  1. Public Client API for data access
  2. Private Administration API for internal operations
  3. Background Jobs for ingestion and invoice generation

Design Considerations

  1. API Security: Azure Identity for authN/Z
  2. RESTful API Design:
    • Consistent HTTP responses (200, 204, 401, 403, 422)
    • Tests enforce behavior; documentation reflects reality
  3. API Versioning for backward compatibility

Testing strategy

  1. Unit Testing
    • Covered business requirements; mutation testing via Stryker.NET around critical flows (e.g., invoicing)
  2. Isolated Integration Tests
    • Testcontainers for MongoDB to validate concurrency and data interactions
  3. Live Integration Tests
    • Read-only queries against live to detect regressions proactively

Technology Stack Used

  • .NET, Azure App Service
  • Azure SQL Server, MongoDB (Cloud)
  • Azure Identity
  • Testcontainers, Stryker.NET
  • GitHub/Azure DevOps CI/CD and unified branching

Conclusions

Multi-country deployments are live with country-specific rules. Peak throughput reached ~20,000 requests/sec. Reliability improved to ~3 errors/month. The platform now runs cost-effectively on Azure App Service with MongoDB Cloud (M10), delivering new revenue while keeping operational costs under control.

After 1 year of development, the system is already bringing money to the client, while keeps the operational costs down. Currently it runs on Azure App Service with MongoDb Cloud Option M10 - the most cost effective plan.