What are stateful and stateless processing modes in Service package

When you expose a Pega service, for example a REST API, the service package decides how each incoming request is handled. One of its key settings is the processing mode: stateless or stateful. It controls whether Pega remembers the caller between requests.

Stateless

Each request is treated on its own. Pega takes a requestor from a pool, handles the request, cleans it up and returns it to the pool. Nothing is remembered afterwards, so the client must send everything the service needs every time.

  • Simple and fast.
  • Scales well, because any server can answer any request.
  • Best for lookups and one-shot updates.

Stateful

Pega keeps a requestor, and its clipboard, alive across a series of requests from the same client. Later requests can use data left behind by earlier ones.

  • Needed for a multi-step conversation, such as a wizard-style exchange.
  • Uses more memory, because sessions stay open.
  • Needs care with load balancing, so that the same client reaches the same node or the session state is shared.

Comparison

StatelessStateful
Memory of earlier requestsNoneKept on the clipboard
ScalabilityHighLower
RequestorBorrowed from a poolHeld for the session
Typical useGet account balanceMulti-request application form

A worked example

A bank publishes two services.

  1. GET /accounts/{id}/balance needs nothing but the account number, so the package uses stateless mode. A thousand calls per second are served from the pool.
  2. A partner completes a mortgage application in five calls, each adding more data to the same case. The package for that service uses stateful mode so the partly built application stays on the clipboard between calls.

Which should you pick?

  • Choose stateless unless you have a clear reason not to. Design the API so each call carries its own context, such as a case ID.
  • Choose stateful only for genuinely conversational services, and set a sensible session timeout.

Interview tip

Explain that the setting is on the service package, define each mode in one sentence, and state a preference for stateless with the reason (scalability). Related: Explain Service REST integration in Pega.

No comments:

Post a Comment