Full Lifecycle Administration of MySQL and MariaDB for Web Projects
Imagine: a WordPress site crashes with 1000 concurrent visitors, even though the server is powerful. Most likely, the issue is in MySQL—InnoDB buffer pool not configured, indexes missing on frequent queries, binary log filling the disk. Such scenarios are common: a typical project loses up to 30% performance due to suboptimal configuration. We solve these tasks daily, with over 50 successful projects in MySQL and MariaDB administration under our belt. We guarantee stable operation and a 20-50% performance boost after tuning.
Problems We Solve
Table fragmentation. MyISAM without regular OPTIMIZE slows down selects. InnoDB also fragments after frequent UPDATE/DELETE operations. The database size grows, performance drops. Slow queries. Missing indexes, N+1 queries in the application, suboptimal JOINs without keys. Replication. Setting up master-replica without lag control leads to desynchronization. Binary log overflow without rotation fills the entire disk—server stops. Load balancing. Without ProxySQL, reads and writes go to one server, creating a bottleneck.
How We Do It
Initial Audit
-- Assess state: database sizes, fragmentation, slow queries SELECT table_schema, ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS size_mb FROM information_schema.tables GROUP BY table_schema ORDER BY size_mb DESC; Then we analyze slow_query_log and config files. Based on the data, we select parameters. For example, for a 50 GB database with high write load, we increase innodb_log_file_size to 1 GB, reducing checkpoint time by 40%.
InnoDB Optimization
The key parameter is innodb_buffer_pool_size. For a dedicated server, we allocate 70-80% of RAM. We increase log file size to 512 MB—this reduces checkpoint frequency and speeds up writes. File per table (innodb_file_per_table = ON) simplifies backup and optimization. As a result, a typical 100 GB database gets a 30-60% query speed boost.
[mysqld] innodb_buffer_pool_size = 4G innodb_buffer_pool_instances = 4 innodb_log_file_size = 512M innodb_log_buffer_size = 64M innodb_flush_log_at_trx_commit = 1 innodb_file_per_table = ON innodb_read_io_threads = 8 innodb_write_io_threads = 8 innodb_io_capacity = 2000 innodb_io_capacity_max = 4000 How We Optimize the Database: Step by Step
- Audit current configuration and performance.
- Analyze slow queries and indexes (we detect up to 90% of suboptimal queries).
- Tune InnoDB parameters (buffer pool, log file, IO threads).
- Set up master-replica replication with lag control (target lag < 1 sec).
- Configure automatic backups (mysqldump for small databases, XtraBackup for large ones).
- Implement monitoring and alerts (Prometheus + Grafana, ProxySQL for load balancing).
- Document configuration and train your administrator.
Why Replication Matters
Master-replica replication provides fault tolerance: if the master fails, we switch to the replica. We configure it so that lag does not exceed 1 second. We use ROW-format binary log—it is safer than STATEMENT for applications with stored procedures. Example configuration:
-- On master CREATE USER 'replication'@'%' IDENTIFIED BY 'strong_password'; GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%'; SHOW MASTER STATUS; -- On replica CHANGE MASTER TO MASTER_HOST = '10.0.0.1', MASTER_USER = 'replication', MASTER_PASSWORD = 'strong_password', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 12345; START SLAVE; Backups: mysqldump vs XtraBackup
For databases up to 10 GB, we use mysqldump with --single-transaction—backup without locking InnoDB. For large databases, we use Percona XtraBackup: it physically copies data, works up to 3 times faster, and barely loads the server. Both methods are automated with rotation and integrity checks.
# mysqldump for small databases mysqldump --single-transaction --quick --routines --triggers --flush-logs -u backup -p mydb | gzip > /backups/mydb_$(date +%Y%m%d).sql.gz # XtraBackup for large databases xtrabackup --backup --user=backup --target-dir=/backups/full_$(date +%Y%m%d) Backup Method Comparison
| Parameter | mysqldump | XtraBackup |
|---|---|---|
| Database size | < 10 GB | ≥ 10 GB |
| Speed | Slow (logical) | Fast (physical) |
| Server load | Medium | Low |
| Locking | No (--single-transaction) | No |
| Recovery | Slow (SQL) | Fast (files) |
| License cost savings | – | Free, saving up to $2000/year |
Optimization and Monitoring
We regularly defragment tables using OPTIMIZE TABLE or pt-online-schema-change (without locking). Monitoring via performance_schema: we track top slow queries and locks. We set up alerts when disk usage exceeds 80%.
| Task | Frequency |
|---|---|
| mysqldump backup | Daily |
| Replica lag check | Every minute |
| Binary log rotation | According to expire_logs_days |
| OPTIMIZE tables | Weekly |
| Slow query log analysis | Weekly |
| Disk space check | Continuous (alert at >80%) |
What to Do When Binary Log Grows
Binary log grows if rotation is not configured. Set expire_logs_days = 7 in my.cnf, and regularly run PURGE BINARY LOGS BEFORE NOW() - INTERVAL 7 DAY. For replication, use ROW format: it is more compact under mixed load. Log size can be controlled with alerts—when disk reaches 80%, a notification triggers.
Example my.cnf configuration with rotation
[mysqld] expire_logs_days = 7 max_binlog_size = 500M binlog_format = ROW Estimated Work Timelines
Timelines depend on complexity: audit takes 1-2 days, configuration tuning 2-3 days, replication setup 1-2 days, backup setup 1 day. Full cycle—from 5 to 10 working days. Cost is calculated individually and pays off by reducing server load by up to 40%. Order a primary audit—we will show real growth points.
What’s Included
- Audit of current configuration and performance (with a report).
- InnoDB tuning for workload (optimize buffer pool, log file, IO).
- Master-replica replication setup with lag monitoring.
- Automatic backup configuration (mysqldump/XtraBackup) with rotation.
- Monitoring integration (performance_schema, disk and lag alerts).
- Documentation on configuration and recovery procedures.
- Training for your administrator (2-3 hours of consultations).
- 1 month warranty support after implementation.
Contact us for a primary audit of your database. Order MySQL/MariaDB tuning and forget about performance issues. Our team guarantees results: stable operation without surprises.
For additional information, refer to InnoDB documentation and Wikipedia on replication.







