---
title: "Khắc phục lỗi File I/O khi Build"
url: https://phatdev.net/docs/sl-migrations/how-to-resolve-file-io-related-build-issues
lang: vi
updated: 2026-10-20
alternate:
  en: https://phatdev.net/en/docs/sl-migrations/how-to-resolve-file-io-related-build-issues
markdown: https://phatdev.net/docs/sl-migrations/how-to-resolve-file-io-related-build-issues.md
---

# Khắc phục lỗi File I/O khi Build

Thuộc bộ tài liệu: [SL Migrations](https://phatdev.net/docs/sl-migrations.md)

> Build chậm hoặc fail với lỗi I/O.

## File I/O Issues khi Build

## Triệu chứng

- Build phase ARCHIVE chạy rất chậm
- Fail với "Cannot open file" / "Disk read error"
- Build dừng ở giữa chừng (50-80%) không tiến triển
- Server load tăng cao

## Nguyên nhân và cách fix

### 1. Disk chậm

Build phải đọc hàng trăm nghìn file → tốc độ IOPS quan trọng hơn bandwidth. SSD nhanh hơn HDD nhiều lần. Trên shared hosting, bạn không kiểm soát được - có thể chuyển sang hosting có SSD nếu cần.

### 2. Quá nhiều file nhỏ

Site có vài trăm nghìn file ảnh nhỏ → metadata IOPS trở thành bottleneck. PHP ZipArchive rất chậm với pattern này.

**Fix**:
- Chuyển sang **DupArchive** engine (default)
- Loại trừ folder cache nhiều file:
  - `wp-content/cache/`
  - `wp-content/uploads/cache/`
  - `wp-content/litespeed/`
  - Folder cache của plugin caching đang dùng

### 3. Tmp folder không đủ disk

Build extract tạm vào `wp-content/backups-slm/tmp/`. Cần disk free >= 2× kích thước site.

Kiểm tra disk free trước khi build.

### 4. Quá nhiều process đồng thời

Web server workers + database queries + build process → cạnh tranh IOPS.

**Fix**: Build vào giờ thấp điểm. Tạm tắt cron jobs nặng khác trong khi build.

### 5. File bị lock bởi process khác

Antivirus, search indexer, hoặc plugin khác đang lock file → build skip + log warning.

## Tối ưu PHP

Trên server có quyền chỉnh PHP:

```ini
realpath_cache_size = 256K
realpath_cache_ttl = 600
opcache.enable = 1
opcache.memory_consumption = 256
```

## Tham khảo

- [Các engine zip](https://phatdev.net/docs/sl-migrations/how-to-work-with-the-different-zip-engines)
- [Server resources](https://phatdev.net/docs/sl-migrations/how-to-manage-server-resources-cpu-memory-disk)
