The Imperative of Elasticity in Critical Infrastructure

In the domain of asset management and Smart Cities, the demand for computational resources is non-linear. Load spikes induced by massive IoT sensor data ingestion, complex geospatial queries (e.g., buffer and ST_Intersects over petabytes of data), or the simultaneous generation of critical reports require an inherently elastic infrastructure. The rigidity of dedicated monolithic servers has given way to orchestrated microservices architecture, with Docker and Kubernetes being the canonical pairing for tackling this challenge.

Docker: The Foundation of Immutability and Portability

Docker is the underlying technology that enables containerization. A Docker container bundles an application together with all its dependencies (libraries, configurations) into a standard, immutable image. This guarantees that the execution environment across development, staging, and production is identical, eliminating the classic "it works on my machine" problem.

For a high-performance GIS system, specific services are containerized: one microservice for the route query API, another for telemetry streaming processing (MQTT), and a third for managing the geospatial database (PostGIS).

Kubernetes (K8s): The Container Orchestrator at Scale

Docker solves the packaging problem, but when you have hundreds of interdependent containers that need to be automatically deployed, monitored, restarted, and scaled, an orchestrator is needed: Kubernetes. K8s manages the complete application lifecycle.

Elastic Auto-Scaling: Horizontal Pod Autoscaler (HPA)

The heart of K8s's elasticity lies in the Horizontal Pod Autoscaler (HPA). The HPA monitors key metrics of the Pods (primarily CPU and memory usage, or custom metrics) and automatically adjusts the number of replicas based on the load.

  1. HPA Definition: A Deployment is defined with a minimum and maximum number of replicas, and a utilization threshold.

    • Example: Scale the GIS query microservice when the average CPU utilization exceeds 70%.

  2. Reaction Mechanism:

    • If the load exceeds the upper threshold , the HPA increases the number of replicas until the maximum limit is reached.

    • If the load drops below the lower threshold , the HPA reduces the number of replicas down to the minimum limit .

For extreme load spikes, K8s also supports the Cluster Autoscaler, which adds or removes nodes (VMs/physical servers) from the cluster if the HPA cannot meet demand because all existing nodes are full. This is the ultimate expression of cloud scalability.

Persistence and Challenges: The Role of StatefulSets

Most microservices, such as APIs or event processors, are stateless and directly benefit from Deployments. However, high-performance GIS systems often require persistent databases and message brokers (like Kafka or RabbitMQ) that are stateful.

K8s addresses this with StatefulSets. Unlike a Deployment, a StatefulSet guarantees:

Using StatefulSets for PostGIS ensures that when scaling or updating the database (consider read replicas), the cluster state remains coherent and disruptions are minimized. This architecture decouples compute (stateless microservices in Deployments) from persistence (stateful in StatefulSets), optimizing each layer for its specific mission.

This orchestration paradigm enables Maptainer to manage millions of assets and billions of events with an infrastructure that is robust, elastic, and economically optimized by only paying for the resources actually consumed in real-time.