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
sessionttlparameter 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 (only for strict mode)
- The node has gone offline (except in norotate mode)
- Error limit is reached (in flex mode)
Session Modes
| Key | Value | Description |
|---|---|---|
| sessionmode | strict, flex, norotate | Controls session behavior on errors |
Strict Mode (Default)
By default, sessions 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 of using undefinedsessionmode, which defaults to sessionmode-strict:
sessionmode-strict explicitly defined:
Flex Mode
Sessions can 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-flex:
No-Rotate Mode
Sessions can operate in norotate mode where node errors cause immediate failure instead of rotation. This is useful when IP consistency is critical and you would rather fail than silently switch IPs. Note that TTL expiry still creates a new session (same as other modes).- Returns 502 on tunnel errors (node responds with an error) or 503 when the node has gone offline
- The
sessionerrparameter is ignored in norotate mode — any error fails immediately
sessionmode-norotate:
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 strict mode ensures immediate rotation on any error; use flex mode if you need IP stability; use norotate mode if you need IP consistency on node errors (TTL expiry still rotates)
- Monitor error rates: Adjust
sessionerrbased 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 durationsessionerr- Error limit for flex mode- Geographic parameters (
subdivision,zipcode, etc.)
Parameters Re-parsed on Every Request
sessionmode is evaluated on every request, not just at session creation (see the norotate warning above).Session-Breaking Parameters
Unlike other parameters that are ignored until rotation,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