Knowledgebase

Session Persistence and Stateless Design Print

  • internet, woocommerce, troubleshooting, guide, howto, solution, zillionkinghost, hosting
  • 0

Handling state behind a balancer.

WHAT THE PROBLEM IS

A user's requests may reach different backends, and state held on one is not available on another.

WHAT SESSION PERSISTENCE DOES

Directs a user consistently to the same backend.

HOW IT IS IMPLEMENTED

A cookie set by the balancer Hashing of the client address

WHY ADDRESS HASHING IS UNRELIABLE

Many users share addresses, and addresses change.

WHAT PERSISTENCE COSTS

Uneven distribution Sessions lost when a backend fails Difficulty draining a backend for maintenance

WHAT THE BETTER ANSWER IS

Stateless backends, with state in shared storage.

WHERE TO PUT SESSION STATE

A shared store, or a signed token held by the client.

WHAT A SIGNED TOKEN PROVIDES

No server-side lookup, at the cost of not being revocable without additional mechanism.

WHAT TO PREFER FOR ANYTHING REQUIRING REVOCATION

Server-side sessions.

WHAT STATELESSNESS ENABLES

Adding and removing backends freely Draining for maintenance without disruption Recovery from a backend failure with no user impact

WHAT TO TEST

Removing a backend during active use.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot