Skip to main content

Scaling

The platform scales horizontally: more pods of a module handle more load. Four layers contribute.

Kubernetes​

  • The horizontal pod autoscaler adds or removes pods of a module according to CPU, memory or a custom metric.
  • The cluster autoscaler adds or removes nodes according to what the pods request.

To autoscale the portal between 1 and 10 pods, targeting 50% CPU:

kubectl autoscale deployment openent-portal --cpu-percent=50 --min=1 --max=10

Quarkus​

Modules start fast and use little memory, so a new pod takes traffic soon after it is created. Building a native executable shortens startup further; build with the native profile:

mvn -Pnative install

Service mesh (optional)​

A service mesh such as Istio is not required for horizontal scaling. Without one, the ingress load balancer distributes requests in round-robin. A mesh adds:

  • load balancing based on latency or error rate;
  • canary and blue-green releases, by sending a share of the traffic to a new version;
  • circuit breakers and retries between modules.

See Service mesh.

Clustered event bus​

Modules exchange messages on the Vert.x event bus, which is clustered with Hazelcast. Every new module pod joins the cluster automatically, and message consumers are spread over the members.

Clustering is switched on in the application.properties of each module:

# Activate cluster for Vert.x
quarkus.vertx.cluster.clustered=true

When a pod joins, the cluster logs its new membership:

Members {size:5, ver:79} [
Member [10.42.0.65]:5701 - 0de0b6a1-2ea8-4ce6-ab74-87e07cbb378e this
Member [10.42.0.69]:5701 - 34380ad1-52fa-45f1-9c8b-22321f70ad2c
Member [10.42.0.70]:5701 - 3b216303-77f7-4803-86c9-ac33f2653e04
Member [10.42.0.98]:5701 - faa437c7-610d-409e-894c-ecea6166fa5f
Member [10.42.0.101]:5701 - 003c90bc-458a-4a78-8829-6d247fbdd853
]

Why Hazelcast and not a message broker​

Hazelcast keeps data in memory. That makes it fast and elastic, and data is replicated across members so that losing one does not lose messages in flight. It is not a durable log.

The event bus carries short-lived messages for which durability is not required, so an in-memory grid fits. A use case that needs durable event streams would call for a broker instead:

CriterionHazelcastKafkaAMQP broker
StorageIn memoryDurable, on diskIn memory, with disk persistence
Horizontal scalingGood, automatic partitioningExcellentGood, bounded by queue management
ThroughputVery high, bounded by memoryVery highGood
Message durabilityNot the primary goalBy defaultDepends on configuration
Best suited toFast in-memory processing and cachingEvent streamingAsynchronous messaging