Aug 19, 2025
Optimizing MySQL on Linux Server: Connection Limits, File Handles, and InnoDB Tuning
When running MySQL 5.7 on a high-performance server with 64GB of memory, the default configurations are often too conservative. Parameters like max_connections, open_files_limit, and InnoDB memory settings can significantly impact database performance under heavy workloads.
In this guide, we’ll walk through how to:
- Increase the system-level file descriptor and process limits.
- Adjust MySQL-specific configurations.
- Tune InnoDB settings for optimal performance.
1. System limits Configuration
By default, Linux distributions often set relatively low values for file descriptors and process limits, which can bottleneck MySQL under high concurrency.
Update the limits in /etc/security/limits.conf:
1 | * soft nproc 262144 |
Also, configure systemd limits specifically for MySQL:
Create or edit the override file:
1 | sudo systemctl edit mysql |
Add the following:
1 | [Service] |
Reload and restart:
1 | sudo systemctl daemon-reexec |
This ensures MySQL can actually use the increased file handle and process limits.
2. MySQL Configuration (my.cnf)
Next, tune MySQL parameters in /etc/my.cnf (or /etc/mysql/my.cnf depending on your distribution).
1 |
|
3. Why These Changes Matter
- max_connections = 2000: Allows more client connections. (Default is only 151, far too small for modern servers.)
- open_files_limit & innodb_open_files = 524288: Prevents “too many open files” errors under heavy workloads.
- table_open_cache & table_definition_cache = 20000: Keeps more tables cached in memory, reducing disk I/O.
- innodb_buffer_pool_size = 40G: Ensures most of your active dataset is cached in memory.
- innodb_log_file_size & innodb_log_buffer_size: Improve write performance and transaction throughput.
- O_DIRECT: Avoids double-buffering between OS cache and InnoDB buffer pool.
4. Example Performance Comparison
| Setting | Default (MySQL 5.7) | Tuned (64GB Server) |
|---|---|---|
| max_connections | 151 | 2000 |
| open_files_limit | 65535 | 524288 |
| table_open_cache | 2000 | 20000 |
| innodb_buffer_pool_size | ~128MB | 40G |
| innodb_log_file_size | 48MB | 1G |
| innodb_log_buffer_size | 8MB | 256M |
Result: Higher concurrency, reduced disk I/O, better transaction throughput, and more efficient use of memory.
5. Configuration Checklist ✅
- Increase system limits (
nofile,nproc) to match workload. - Adjust MySQL
open_files_limitandmax_connections. - Optimize InnoDB memory pool (
innodb_buffer_pool_size,instances). - Tune redo logs (
innodb_log_file_size,innodb_log_buffer_size). - Enable
O_DIRECTto avoid double buffering. - Match
innodb_open_fileswith systemopen_files_limit.
Conclusion
For a 64GB server, tuning MySQL beyond its defaults is not optional—it’s essential. By adjusting both system-level limits and MySQL configurations, you can eliminate connection bottlenecks, prevent file handle exhaustion, and maximize InnoDB performance.
This optimized setup ensures your MySQL 5.7 instance is production-ready for high concurrency and large datasets.
Other:
Cheap VPS Recommendations Page: