Using sticky sessions
Key | Value | TTL | Examples |
---|---|---|---|
session | Any unique identifier of up to 255 characters (regardless of character encoding); Massive will make best efforts to route requests in the same session to the same egress node | Default: 15 minutes (customizable with sessionttl ) | session42, 1234 |
sessionttl | Customizable session TTL in minutes, up to 240 minutes | Default: 15 minutes | 30, 60, 120, 240 |
Session TTL Behavior
- Session TTL defaults to 15 minutes but can be customized using the
sessionttl
parameter up to 240 minutes (4 hours). - Important: Sessions use static TTL - they expire at creation time + TTL and are not extended by subsequent requests.
- For example, to set the TTL to 30 minutes:
Session Rotation
When a session identifier is specified and found, the server will perform a request via the same node unless:- TTL is expired (sessions expire exactly at creation time + TTL)
- The request limit per minute for the node is exceeded
- The node has gone offline
- Error limit is reached (in flex mode)
Session Modes
Key | Value | Description |
---|---|---|
sessionmode | strict , flex | Controls session behavior on errors |
Flex Mode (Default)
By default, sessions operate in flex mode where sessions persist through errors up to a configurable limit. In this mode:- Sessions continue through errors up to the error limit (default: 15)
- Error count resets to 0 on successful requests
- Provides better IP stability during transient failures
- May retry failing nodes multiple times
Note: The default error limit is 15. After 15 consecutive errors, a new node is assigned to the sticky session. You can customize this with the
sessionerr
parameter.sessionmode
, which defaults to sessionmode-flex
:
sessionmode-flex
explicitly defined:
Strict Mode
Sessions can operate in strict mode where any error immediately invalidates the session and triggers rotation to a new node. This ensures clean IP rotation on failures but may change IPs more frequently. Example withsessionmode-strict
:
Additional Parameters
Key | Value | Description | Default |
---|---|---|---|
sessionerr | Number (1-100) | Maximum consecutive errors before rotation in flex mode | 15 |
Customizing Error Limit
In flex mode, you can customize how many errors are allowed before rotation:Best Practices
- Plan TTL appropriately: Since sessions use static TTL (not extended by activity), set an appropriate duration for your use case
- Choose the right mode: Default flex mode provides IP stability; use strict mode if you need immediate rotation on any error
- Monitor error rates: Adjust
sessionerr
based on your tolerance for retries (default is 15) - Session ID naming: Use descriptive session IDs to help with debugging and monitoring
Advanced: Parameter Timing and Mutability
Advanced: Parameter Timing and Mutability
Parameters Applied at Session Creation/Rotation Only
The following parameters are only applied when a session is created or rotated, not on existing sessions:sessionttl
- TTL durationsessionmode
- Strict vs flex behaviorsessionerr
- Error limit for flex mode- Geographic parameters (
subdivision
,zipcode
, etc.)
Session-Breaking Parameters
Critical: Changing
country
or city
parameters creates a NEW session with a different identity, breaking session continuity. These are part of the session token itself.country
and city
are part of the session’s unique identifier. Changing them creates an entirely different session:Parameters Always Processed
Some parameters are processed on every request regardless of session state:subaccount
- For billing and trackinghttpredirect
- For HTTP to HTTPS redirect behavior