# Bounding Execution
Some operations may require significant compute time depending on the complexity of the Terms involved.
To prevent excessively long processing, the engine enforces a **server-side execution timeout**.

## The default timeout

Every operation is bounded whether or not you ask for it. When a request carries no `executionTimeout`, the engine applies the maximum your [plan](/plans-pricing) allows, which is **500 ms** on the Free plan. No request can run longer than that, so a pathological pattern can never hold a connection open indefinitely.

## Execution Timeout

You can lower that ceiling for a single operation by passing a maximum compute time in **milliseconds** as `executionTimeout`.

* If the limit is exceeded, the request aborts and returns a `TimeoutExceeded` error.
* The timeout is enforced **server-side**, so it bounds compute time rather than the round trip your client observes.
* Asking for more than your plan's maximum is rejected up front with `TimeoutTooLarge`.

Lowering the timeout is useful when you process patterns whose complexity you cannot predict and you want them to give up quickly, well before the plan maximum.

Example:

<CodeTabs defaultValue="java">
<CodeTabs.Tab value="java" label="Java">
```java
import com.regexsolver.api.exceptions.ApiException;

// Limit the server-side compute time to 5 ms
try {
    RegexSolverClient client = RegexSolverClient.builder()
        .apiToken(System.getenv("REGEXSOLVER_API_TOKEN"))
        .build();
    Term term1 = Term.regex(".*ab.*c(de|fg).*dab.*c(de|fg).*ab.*c(de|fg).*dab.*c");
    Term term2 = Term.regex(".*abc.*");

    OperationOptions options = OperationOptions.builder()
        .executionTimeout(5);

    Term out = client.difference(term1, term2, options);
} catch (ApiException e) {
    System.out.println(e.getMessage());
    // The operation took too much time.
}
```
</CodeTabs.Tab>

<CodeTabs.Tab value="javascript" label="JavaScript">
```javascript
import { RegexSolverClient, ApiError, Term } from "regexsolver";

// Limit the server-side compute time to 5 ms
const client = new RegexSolverClient({ apiToken: process.env.REGEXSOLVER_API_TOKEN });
client.difference(
    Term.regex(".*ab.*c(de|fg).*dab.*c(de|fg).*ab.*c(de|fg).*dab.*c"),
    Term.regex(".*abc.*"), 
    { executionTimeout: 5 }
  )
  .then(res => { /* ... */ })
  .catch(err => {
    if (err instanceof ApiError) {
      console.log(err.message);
      // The operation took too much time.
    } else {
      throw err;
    }
  });
```
</CodeTabs.Tab>

<CodeTabs.Tab value="python" label="Python">
```python
import os
from regexsolver import RegexSolverClient, ApiError, Term

# Limit the server-side compute time to 5 ms
try:
    client = RegexSolverClient(api_token=os.getenv("REGEXSOLVER_API_TOKEN"))
    res = client.difference(
        Term.regex(r".*ab.*c(de|fg).*dab.*c(de|fg).*ab.*c(de|fg).*dab.*c"),
        Term.regex(r".*abc.*"),
        execution_timeout=5
    )
except ApiError as error:
    print(error)
    # The API returned the following error: The operation took too much time.
```
</CodeTabs.Tab>
</CodeTabs>

## What the budget covers

The timeout bounds everything the server does for one request: reading the Terms you sent, running the operation, and building the response in the format you asked for. Those stages share the budget rather than each getting their own.

That sharing is what makes a heavy operation followed by a regex conversion worth splitting into two calls. See [Heavy Operations](/advance-usage/heavy-operations).
