mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
docs: 更新文档
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
::: info
|
||||
This English version is translated by **Gemini 3 Flash**.
|
||||
:::
|
||||
|
||||
# Linux Low Memory Optimization
|
||||
|
||||
## Enable SWAP
|
||||
|
||||
1. Check current SWAP status
|
||||
```bash
|
||||
sudo swapon --show
|
||||
```
|
||||
|
||||
2. Create SWAP file
|
||||
```bash
|
||||
fallocate -l 4G /swapfile
|
||||
```
|
||||
|
||||
3. Set permissions
|
||||
```bash
|
||||
chmod 600 /swapfile
|
||||
```
|
||||
|
||||
4. Format and enable SWAP
|
||||
```bash
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
```
|
||||
|
||||
5. Set auto-mount on boot
|
||||
```bash
|
||||
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
|
||||
```
|
||||
|
||||
## Enable ZRAM
|
||||
|
||||
### Debian / Ubuntu
|
||||
|
||||
1. Install
|
||||
```bash
|
||||
apt update
|
||||
apt install zram-tools -y
|
||||
```
|
||||
|
||||
2. Modify configuration file
|
||||
```bash
|
||||
nano /etc/default/zramswap
|
||||
```
|
||||
|
||||
Add or modify the following:
|
||||
|
||||
```bash
|
||||
# Use zstd compression algorithm for the best balance of speed and ratio
|
||||
ALGO=zstd
|
||||
|
||||
# Use 60% of total memory as ZRAM size
|
||||
PERCENT=60
|
||||
|
||||
# [Crucial] Set priority to 100.
|
||||
# As long as this is higher than disk Swap (usually -2), the system will prioritize ZRAM.
|
||||
PRIORITY=100
|
||||
```
|
||||
|
||||
Press `Ctrl+O` Enter to save, `Ctrl+X` to exit.
|
||||
|
||||
3. Restart service
|
||||
```bash
|
||||
systemctl daemon-reload
|
||||
systemctl restart zramswap
|
||||
```
|
||||
|
||||
### CentOS / Arch Linux
|
||||
|
||||
Recommended to use `zram-generator` for these systems.
|
||||
|
||||
1. Install
|
||||
```bash
|
||||
# CentOS 8/9, Fedora, AlmaLinux, Rocky Linux
|
||||
dnf install zram-generator -y
|
||||
|
||||
# Arch Linux
|
||||
pacman -S zram-generator
|
||||
```
|
||||
|
||||
2. Modify configuration file
|
||||
Create or edit `/etc/systemd/zram-generator.conf`:
|
||||
|
||||
```ini
|
||||
[zram0]
|
||||
# Use 60% of total memory
|
||||
zram-size = ram * 0.6
|
||||
# Use zstd compression algorithm
|
||||
compression-algorithm = zstd
|
||||
# Higher priority than disk Swap
|
||||
swap-priority = 100
|
||||
```
|
||||
|
||||
3. Start service
|
||||
```bash
|
||||
systemctl daemon-reload
|
||||
systemctl start systemd-zram-setup@zram0
|
||||
```
|
||||
|
||||
### General Optimization
|
||||
|
||||
Regardless of the system, it is recommended to adjust `swappiness` to use ZRAM more aggressively.
|
||||
|
||||
```bash
|
||||
grep -q "vm.swappiness" /etc/sysctl.conf || echo "vm.swappiness=80" | tee -a /etc/sysctl.conf
|
||||
sysctl -p
|
||||
```
|
||||
|
||||
## Disable Site Isolation (fission.autostart)
|
||||
|
||||
For servers with extremely tight memory (e.g., 1GB RAM), if the system still crashes frequently after enabling SWAP and ZRAM, you can try disabling Firefox's Site Isolation as a **last resort**.
|
||||
|
||||
::: warning Risk Disclosure
|
||||
Disabling Site Isolation reduces the uniqueness of the browser fingerprint, potentially making it easier for high-level anti-bot systems to identify (e.g., by detecting single-process model or inter-process communication delays). Use only when necessary.
|
||||
:::
|
||||
|
||||
1. Modify `config.yaml`:
|
||||
|
||||
```yaml
|
||||
browser:
|
||||
# ...
|
||||
# Disable site isolation to significantly reduce memory footprint
|
||||
fission: false
|
||||
```
|
||||
|
||||
2. Restart WebAI2API service.
|
||||
|
||||
::: tip Tip
|
||||
After completing the configuration, it is recommended to restart the server to ensure all settings take effect.
|
||||
:::
|
||||
@@ -46,10 +46,35 @@ queue:
|
||||
|
||||
# Browser Configuration
|
||||
browser:
|
||||
# Path to browser executable (leave empty for default)
|
||||
# Modification is not recommended unless necessary, as you may need to handle extra dependencies
|
||||
# Windows example: "C:\\camoufox\\camoufox.exe"
|
||||
# Linux example: "/opt/camoufox/camoufox"
|
||||
path: ""
|
||||
|
||||
# Whether to enable headless mode
|
||||
headless: false
|
||||
|
||||
# Site Isolation (fission.autostart)
|
||||
# Keep enabled for standard Firefox behavior
|
||||
# Disabling this can significantly reduce memory usage and prevent crashes on low-end servers
|
||||
# ⚠️ Risk: Normal Firefox users have Fission enabled by default. While disabling it does not leak common fingerprints,
|
||||
# extremely advanced anti-bot systems might identify automated features via "single-process model" or "IPC delays".
|
||||
fission: true
|
||||
|
||||
# [Global Proxy] Used if an Instance does not have its own proxy configuration
|
||||
proxy:
|
||||
# Whether to enable proxy
|
||||
enable: false
|
||||
# Proxy type: http or socks5
|
||||
type: http
|
||||
# Proxy host
|
||||
host: 127.0.0.1
|
||||
# Proxy port
|
||||
port: 7890
|
||||
# Proxy authentication (optional)
|
||||
# user: username
|
||||
# passwd: password
|
||||
```
|
||||
|
||||
## Configuration Items
|
||||
@@ -86,6 +111,7 @@ browser:
|
||||
| --- | --- | --- | --- |
|
||||
| `path` | string | `""` | Path to Camoufox executable. Leave empty to use default. |
|
||||
| `headless` | boolean | `false` | Whether to enable headless mode. |
|
||||
| `fission` | boolean | `true` | Whether to enable Site Isolation (fission.autostart). |
|
||||
| `proxy` | object | - | Global proxy configuration. |
|
||||
|
||||
### Adapter Configuration (backend.adapter)
|
||||
|
||||
@@ -21,6 +21,10 @@ Before you start deploying WebAI2API, please ensure that your environment meets
|
||||
| **CPU** | 1 Core | 2 Cores or above | 2 Cores or above |
|
||||
| **Memory** | 1 GB | 2 GB or above | 4 GB or above |
|
||||
| **Disk** | 2 GB available | 5 GB or above | 7 GB or above |
|
||||
|
||||
::: tip Optimization Suggestions
|
||||
For low-end servers with 1-2 GB of RAM, it is strongly recommended to enable **SWAP** or **ZRAM** to improve system stability and performance. Refer to [Linux Low Memory Optimization](/en/admin/optimization) for details.
|
||||
:::
|
||||
|
||||
::: tip Real-world Performance
|
||||
- **Oracle Free Tier** (1C1G, Debian 12): Limited resources, can be laggy, suitable for testing or light use only.
|
||||
|
||||
Reference in New Issue
Block a user