Skip to main content

Session Affinity

This page describes how to enable session affinity for cloud hosting services.

By enabling session affinity, cloud hosting strives to route requests carrying specific request headers to the same cloud hosting instance. Session affinity requires collaboration between the client and server to implement.

Configuring Session Affinity

. By enabling session affinity, cloud hosting strives to route requests carrying specific request headers to the same cloud hosting instance. Session affinity requires collaboration between the client and server to implement.

General Client

For general clients, after the first call to the cloud hosting service, the client needs to save the X-Cloudbase-Session-Id response header returned by cloud hosting. In subsequent requests, the client must carry the X-Cloudbase-Session-Id request header with the same value to route to the same cloud hosting instance. By default, the X-Cloudbase-Session-Id remains valid for 4 hours. Active X-Cloudbase-Session-Id headers will stay valid and will not be automatically cleared.

The following diagram illustrates the invocation:

MCP Client

Cloud hosting session affinity has built-in support for MCP Session as declared by the Model Context Protocol. For compliant MCP clients, cloud hosting automatically handles session affinity maintenance for Mcp-Session-Id without requiring additional request headers.

The following diagram illustrates the invocation: