# How create_request_batch_size Impacts Parallel Order Creation in biliTickerBuy

> Discover how create_request_batch_size affects parallel order creation in biliTickerBuy. Learn to balance speed and API rate-limit risk for optimal ticket purchasing.

- Repository: [Qizhuo Xie/biliTickerBuy](https://github.com/mikumifa/biliTickerBuy)
- Tags: performance
- Published: 2026-06-23

---

**The `create_request_batch_size` parameter controls how many simultaneous HTTP requests the biliTickerBuy tool dispatches when retrying failed ticket orders, directly balancing purchase speed against API rate-limit risk.**

The `create_request_batch_size` setting in the mikumifa/biliTickerBuy repository governs the concurrency level of order creation attempts. Defined in [`interface/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/interface/config.py) and consumed in the core buying logic, this integer value transforms the retry mechanism from sequential polling into parallel batch processing. Tuning this parameter allows users to optimize their buying strategy based on network conditions and BiliBili's API tolerance.

## What is create_request_batch_size?

The `create_request_batch_size` is a configuration parameter exposed through the `BuyConfig` class that controls the **number of concurrent create-order requests** issued during each retry cycle. According to the source code in [`interface/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/interface/config.py) (line 29), this value is read from user configuration and normalized to ensure positive integer behavior.

When the buying task initializes, it calculates an effective batch size to prevent invalid values:

```python
effective_batch_size = max(1, int(config.create_request_batch_size))

```

This calculation appears in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py) (lines 383–384), ensuring the system defaults to at least one concurrent request even if the configuration specifies zero or negative values.

## How Batch Size Controls Parallelism

The buying routine uses the effective batch size to determine how many retry attempts execute simultaneously. This logic spans three distinct phases:

### Calculating Batch Boundaries

Before dispatching requests, the runner calculates the upper limit of the current batch using the logic found in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py) (lines 544–546):

```python
batch_end = min(
    attempt + effective_batch_size - 1,
    effective_retry_limit,
)

```

This formula ensures the batch never exceeds the total allowed retry limit while respecting the configured parallelism level.

### Execution Behavior

The impact of `create_request_batch_size` manifests in two distinct execution patterns:

- **Serial Execution (value = 1):** When the effective batch size equals one, the system waits for each HTTP request to complete before initiating the next retry. This conservative approach minimizes resource usage and rate-limit triggers but increases total completion time.

- **Parallel Execution (value > 1):** When the effective batch size exceeds one, the runner launches multiple create-order requests concurrently. For example, setting the value to `3` dispatches three simultaneous HTTP requests, reducing latency but increasing instantaneous load on BiliBili's API.

## Performance Impact and Trade-offs

Selecting an appropriate `create_request_batch_size` requires balancing velocity against stability:

**Batch Size = 1**

- **Behavior:** Sequential retries with single-threaded execution
- **Advantages:** Minimal memory footprint, low CPU usage, reduced risk of rate-limit blocks
- **Disadvantages:** Slower overall order creation, higher latency between attempts

**Batch Size > 1 (e.g., 3, 5, 10)**

- **Behavior:** Parallel retries with concurrent HTTP connections
- **Advantages:** Faster completion when network latency dominates; higher probability of securing tickets before inventory depletion
- **Disadvantages:** Increased concurrent traffic may trigger API rate limits; higher memory and CPU consumption; more complex error handling requirements

## Configuring create_request_batch_size

You can modify this parameter through multiple interfaces depending on your deployment method.

### Configuration File Method

Set the value in your configuration YAML file:

```yaml
create_request_batch_size: 3

```

### Command Line Interface

Override the configuration using the CLI flag defined in [`app_cmd/config/BuyConfig.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/app_cmd/config/BuyConfig.py):

```bash
python -m biliTickerBuy --create-request-batch-size 5

```

### Web Interface

For GUI users, the parameter can be adjusted through the configuration tab implemented in [`tab/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/tab/config.py), allowing real-time modification without editing configuration files directly.

## Summary

- The `create_request_batch_size` parameter in [`interface/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/interface/config.py) controls how many create-order HTTP requests execute simultaneously during retry cycles.
- The system calculates an `effective_batch_size` in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py) (lines 383–384) by normalizing the input to a minimum value of 1.
- Batch boundaries are determined by `min(attempt + effective_batch_size - 1, effective_retry_limit)` in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py) (lines 544–546).
- Setting the value to 1 enforces sequential processing, while values greater than 1 enable parallel request batches.
- Higher values accelerate order creation but increase the risk of hitting BiliBili API rate limits and consuming additional system resources.

## Frequently Asked Questions

### What happens if I set create_request_batch_size to 0?

The normalization logic in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py) (lines 383–384) applies `max(1, int(config.create_request_batch_size))`, which converts any value less than 1 (including 0) to exactly 1. This ensures the buying routine always executes at least one concurrent request and prevents the system from entering an invalid state.

### Does a larger batch size guarantee faster ticket purchases?

While larger values reduce the time spent waiting for individual network round-trips, they do not guarantee success. Increased concurrency raises the probability of triggering BiliBili's rate-limiting mechanisms, which may temporarily block your requests. The optimal value depends on current network latency and the platform's API tolerance at purchase time.

### Where is create_request_batch_size defined in the codebase?

The parameter is defined in [`interface/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/interface/config.py) (line 29) as part of the `BuyConfig` class. It is consumed by the buying task in [`task/buy.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/task/buy.py), exposed through the CLI in [`app_cmd/config/BuyConfig.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/app_cmd/config/BuyConfig.py), and configurable via the web interface in [`tab/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/tab/config.py).

### Can I change the batch size without restarting the application?

Yes, if you are using the web interface implemented in [`tab/config.py`](https://github.com/mikumifa/biliTickerBuy/blob/main/tab/config.py), you can modify `create_request_batch_size` dynamically. However, changes made through the configuration file or CLI require a restart to take effect, as the value is read during the buying task initialization phase.