# Rate Limits

The WebSocket API rate limits requests and connections by IP address.&#x20;

If you exceed a rate limit, an error is thrown and your requests will be blocked for 2 minutes.

Rate limits for the WebSocket API are as follows:

<table><thead><tr><th width="147">Type</th><th>Limit</th></tr></thead><tbody><tr><td><strong>Connections</strong></td><td><strong>10 active connections</strong> per IP address.</td></tr><tr><td><strong>Requests</strong></td><td><strong>40 requests per 1 minute</strong> per IP address. Requests are counted, in total, across your active connections.</td></tr></tbody></table>

## Best Practices

To avoid rate limiting, sFOX recommends following these best practices:

#### 1. Consolidate feeds per [subscribe/unsubscribe request](https://docs.sfox.com/websocket-api/subscribing-and-unsubscribing)

Subscribe/unsubscribe to multiple WebSocket feeds in a single request rather than sending subscribe requests per WebSocket feed.

<pre class="language-json" data-overflow="wrap"><code class="lang-json"><strong>// Request -> Subscribe to feeds
</strong>{
    "type": "subscribe", 
    "feeds": ["&#x3C;feed 1>", "&#x3C;feed 2>", ...] //Subscribe to N feeds in 1 request
}
</code></pre>

For example, if you want to subscribe to both the [open orders](https://docs.sfox.com/websocket-api/orders-and-account-data/orders) and [balances](https://docs.sfox.com/websocket-api/orders-and-account-data/balances) feeds:

<pre class="language-json"><code class="lang-json"><strong>// Request -> Subscribe to open orders and balances feeds
</strong>{
    "type": "subscribe", 
    "feeds": ["private.user.open-orders", "private.user.balances"]
}
</code></pre>

#### 2. Consolidate WebSocket consumption by [connection](https://docs.sfox.com/websocket-api/connecting)

Consuming the same data across >1 connection will result in duplicate requests. For example, if you want consume the BTC/USD order book, do so in a single connection.

{% hint style="info" %}
Please note: To ensure optimal performance, sFOX recommends using a separate WebSocket connection for each feed "type" you subscribe to.&#x20;

For example, consume [market data](https://docs.sfox.com/websocket-api/market-data) and [orders/account data](https://docs.sfox.com/websocket-api/orders-and-account-data) in separate connections.

This segregation ensures that time-sensitive updates, such as [balances](https://docs.sfox.com/websocket-api/orders-and-account-data/balances) or [open-orders](https://docs.sfox.com/websocket-api/orders-and-account-data/orders) messages, are not impacted by high-frequency feeds like [order books](https://docs.sfox.com/websocket-api/market-data/order-book).
{% endhint %}
