86 lines
3 KiB
Text
Executable file
86 lines
3 KiB
Text
Executable file
[mysqld]
|
|
# Connection Settings
|
|
# بهینهسازی برای 10000 کانکشن همزمان
|
|
max_connections = 5500 # برای 50 worker با pool_size=50, max_overflow=50 (50*100=5000 + buffer)
|
|
max_user_connections = 5500 # برابر با max_connections
|
|
connect_timeout = 10
|
|
wait_timeout = 300 # کاهش برای آزادسازی سریعتر connection های idle
|
|
interactive_timeout = 300 # کاهش برای آزادسازی سریعتر connection های idle
|
|
|
|
# InnoDB Settings
|
|
# بهینهسازی Buffer Pool برای بهتر Performance
|
|
# برای Production: innodb_buffer_pool_size باید 70-80% RAM باشد
|
|
# مثال: برای 32GB RAM = 22-25GB
|
|
innodb_buffer_pool_size = 18G # 56% از 32GB RAM برای بهینهترین Performance
|
|
innodb_buffer_pool_instances = 8 # برای RAM > 1GB
|
|
innodb_log_file_size = 512M
|
|
innodb_log_buffer_size = 64M
|
|
# innodb_flush_log_at_trx_commit = 2 # بهتر برای Performance (trade-off با Durability)
|
|
# در Production با احتیاط استفاده کنید - ممکن است دادهها در صورت Crash از دست بروند
|
|
innodb_flush_log_at_trx_commit = 1 # Safe default - بهتر برای Data Integrity
|
|
innodb_flush_method = O_DIRECT
|
|
innodb_file_per_table = 1
|
|
innodb_read_io_threads = 8
|
|
innodb_write_io_threads = 8
|
|
innodb_lock_wait_timeout = 50
|
|
|
|
# Table Cache
|
|
# برای 5500 connection، table cache باید بیشتر باشد
|
|
# فرمول: table_open_cache = max_connections * 0.5 (حداقل)
|
|
table_open_cache = 3000 # متناسب با 5500 connection
|
|
table_definition_cache = 3000 # افزایش از 2000
|
|
|
|
# Temporary Tables
|
|
tmp_table_size = 256M
|
|
max_heap_table_size = 256M
|
|
|
|
# Sort and Join
|
|
sort_buffer_size = 4M
|
|
join_buffer_size = 4M
|
|
read_buffer_size = 2M
|
|
read_rnd_buffer_size = 4M
|
|
|
|
# Binary Logging (برای Replication - Phase 2)
|
|
log_bin = /var/log/mysql/mysql-bin.log
|
|
binlog_format = ROW
|
|
expire_logs_days = 7
|
|
max_binlog_size = 500M
|
|
|
|
# Slow Query Log
|
|
slow_query_log = 1
|
|
slow_query_log_file = /var/log/mysql/slow-query.log
|
|
long_query_time = 2 # Log queries > 2 seconds
|
|
|
|
# Error Log
|
|
log_error = /var/log/mysql/error.log
|
|
|
|
# Character Set
|
|
character_set_server = utf8mb4
|
|
collation_server = utf8mb4_unicode_ci
|
|
|
|
# MyISAM (اگر استفاده نمیکنید)
|
|
key_buffer_size = 32M
|
|
|
|
# Threading
|
|
# برای 5500 connection، thread_cache_size باید بیشتر باشد
|
|
# فرمول: thread_cache_size = max_connections * 0.1 (حداقل)
|
|
thread_cache_size = 550 # متناسب با 5500 connection
|
|
thread_stack = 256K
|
|
|
|
# Network
|
|
max_allowed_packet = 64M
|
|
|
|
# File Limits
|
|
# برای 5500 connection، open_files_limit باید بیشتر از max_connections باشد
|
|
# فرمول: open_files_limit >= max_connections * 1.5
|
|
open_files_limit = 8250 # متناسب با 5500 connection
|
|
|
|
# Performance Schema (برای Monitoring)
|
|
performance_schema = ON
|
|
|
|
# Query Cache (MySQL 5.7 - در MySQL 8.0 حذف شده)
|
|
# اگر از MySQL 5.7 استفاده میکنید:
|
|
# query_cache_type = 1
|
|
# query_cache_size = 256M
|
|
# query_cache_limit = 2M
|
|
|