Skip to content

Commit 8f3277f

Browse files
committed
docs: update usage and concurrency tuning guidance
Closes #6 Closes #8
1 parent ad9323e commit 8f3277f

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This is a simple backup script for MySQL servers, designed to help you easily ba
1212
Before you can use this tool, make sure you have the following prerequisites installed on your system:
1313

1414
- **MySQL Client**: Ensure that you have the MySQL client installed to interact with your MySQL databases.
15+
- **GNU Parallel**: Required to run backup jobs concurrently.
1516

1617
## Setup
1718

@@ -33,21 +34,23 @@ Before you can use this tool, make sure you have the following prerequisites ins
3334
- `db_host`: The hostname or IP address of your MySQL server.
3435
- `db_user`: The MySQL user with backup privileges.
3536
- `db_pass`: The password for the MySQL user.
36-
- `max_parallel`: The maximum number of parallel database backups.
37+
- `max_parallel`: The maximum number of parallel database backups, or `auto`.
38+
- `max_parallel_cap`: Upper bound when `max_parallel=auto`.
39+
- `mysql_connection_reserve`: Number of MySQL connections reserved for non-backup traffic when `max_parallel=auto`.
3740
- `max_backups`: The maximum number of backup sets to retain.
3841

3942
4. Make sure the script file is executable.
4043

4144
```bash
42-
chmod +x backup.sh
45+
chmod +x dump.sh
4346
```
4447

4548
## Usage
4649

47-
To create database backups using this tool, simply run the `backup.sh` script:
50+
To create database backups using this tool, simply run the `dump.sh` script:
4851

4952
```bash
50-
./backup.sh
53+
./dump.sh
5154
```
5255

5356
The script will perform the following actions:
@@ -60,12 +63,36 @@ The script will perform the following actions:
6063

6164
4. **Cleanup Old Backups**: It checks the number of backup sets and removes old backups if the number exceeds the `max_backups` setting.
6265

66+
## Concurrency Tuning
67+
68+
For large MySQL servers (for example 400+ databases), set:
69+
70+
```bash
71+
max_parallel=auto
72+
max_parallel_cap=16
73+
mysql_connection_reserve=20
74+
```
75+
76+
With `auto`, the script computes parallel jobs from:
77+
78+
- detected CPU core count
79+
- MySQL `max_connections` minus `mysql_connection_reserve`
80+
- `max_parallel_cap`
81+
82+
The minimum of these values is used as job count.
83+
84+
Guidelines:
85+
86+
- Many small databases: increase `max_parallel_cap` carefully and observe DB load.
87+
- Few large databases: lower cap can reduce I/O contention and stabilize runtime.
88+
- Busy production DB: increase `mysql_connection_reserve` to protect foreground traffic.
89+
6390
## Example
6491

6592
Here's an example of how to run the backup script:
6693

6794
```bash
68-
./backup.sh
95+
./dump.sh
6996
```
7097

7198
## License
@@ -78,4 +105,4 @@ This backup tool is released under the MIT License. See the [LICENSE](LICENSE) f
78105

79106
---
80107

81-
That's it! You now have a simple backup tool to help you manage your MySQL database backups. If you encounter any issues or have suggestions for improvements, feel free to open an issue on GitHub or contribute to the project.
108+
That's it! You now have a simple backup tool to help you manage your MySQL database backups. If you encounter any issues or have suggestions for improvements, feel free to open an issue on GitHub or contribute to the project.

0 commit comments

Comments
 (0)