# I/O 线程池耗尽：没有可用线程处理连接

- **ID:** `redis/io-threads-pool-starvation`
- **领域:** redis
- **类别:** resource_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Redis 的 I/O 线程配置中线程数过少，无法处理当前连接负载，导致线程池耗尽。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 6.2 | active | — | — |
| 7.0 | active | — | — |
| 7.2 | active | — | — |

## 解决方案

1. ```
   Increase the number of I/O threads in redis.conf: io-threads 8 (adjust based on CPU cores) and restart Redis.
   ```
2. ```
   Reduce the number of concurrent connections by implementing connection pooling in client applications, e.g., using a pool with max 50 connections per client.
   ```
3. ```
   Enable I/O thread read/write by setting io-threads-do-reads yes (if not already enabled) to distribute load more evenly.
   ```

## 无效尝试

- **Increase maxclients to allow more connections.** — This does not increase the number of I/O threads; it only allows more connections to queue up, worsening the starvation. (70% 失败率)
- **Disable I/O threads entirely by setting io-threads to 1.** — This removes the thread pool but shifts all I/O to the main thread, potentially causing CPU bottlenecks and higher latency. (50% 失败率)
- **Restart Redis to clear the thread pool state.** — The pool exhaustion is due to configuration and load, not a transient state; restarting only provides temporary relief until the same load returns. (80% 失败率)
