> For the complete documentation index, see [llms.txt](https://raiden-4.gitbook.io/raiden.wtf.docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://raiden-4.gitbook.io/raiden.wtf.docs/bolt-low-latency/http-submission/optimizations.md).

# Additional Optimizations

Performance tips to get the most out of Raiden

## Connection Keep-Alive

Avoid reconnecting by periodically pinging the server:

```
GET https://fra.bolt.raiden.wtf/ping
```

Send a `/ping` request every **60 seconds** to keep your connection active.

{% tabs %}
{% tab title="Python" %}

```python
import time
import requests

session = requests.Session()

while True:
    session.get("https://fra.bolt.raiden.wtf/ping")
    time.sleep(60)
```

{% endtab %}

{% tab title="Bash" %}

```bash
while true; do
  curl -s https://fra.bolt.raiden.wtf/ping > /dev/null
  sleep 60
done
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
This prevents idle disconnects. Avoid pinging more often than needed — every 60s is enough.
{% endhint %}

## HTTP Keep-Alive

Reuse connections to avoid TLS handshake overhead on every request:

```python
import requests

session = requests.Session()
session.headers.update({
    "Content-Type": "application/json",
    "api-x-token": "YOUR_API_KEY",
})

# Reuse session for all requests
for tx in transactions:
    response = session.post("http://fra.bolt.raiden.wtf/api/v1/sendTransaction", json={
        "jsonrpc": "2.0",
        "id": 1,
        "method": "sendTransaction",
        "params": [tx],
    })
```

## Use sendRawTransaction

The binary endpoint skips JSON-RPC parsing and base64 decoding — your bytes go straight into the routing pipeline. See [Send Binary Transaction](/raiden.wtf.docs/bolt-low-latency/http-submission/send-raw-transaction.md).

## QUIC 0-RTT Session Resumption

After your first QUIC connection, subsequent connections skip the full handshake. Enable a TLS session cache:

```go
tlsConf := &tls.Config{
    // ... certificate config ...
    ClientSessionCache: tls.NewLRUClientSessionCache(10),
}
```

This enables sending data on the very first packet of a reconnection.

## Multi-Region Redundancy

Send the same transaction to 2+ regions for higher landing probability. All regions route to the same validator network independently.

## Higher Tips = Higher Priority

Your tip amount directly affects routing priority. Higher tips get processed before lower tips during congestion.

## Error Handling with Backoff

```python
import time

def send_transaction(tx_data, max_retries=3):
    for attempt in range(max_retries):
        response = session.post(ENDPOINT, json={
            "jsonrpc": "2.0",
            "id": 1,
            "method": "sendTransaction",
            "params": [tx_data],
        })
        result = response.json()

        if "error" in result:
            code = result["error"]["code"]
            if code == -32005:  # Rate limited
                time.sleep(0.1 * (attempt + 1))
                continue
            elif code == -32603:  # Internal error
                time.sleep(0.5)
                continue
            else:
                raise Exception(f"API error: {result['error']['message']}")

        return result["result"]

    raise Exception("Max retries exceeded")
```
