I am quite new to MySQL and have a marathon task of making a huge database run fast in all ways
The database goes through ~50k row insertion per second. The average row size is 380. All the columns are big int unsigned not null.
The available memory is 4 GB.
Disk size 1.2 TB RAID 1.
The table is partitioned for every 1 hour, example: YYYYMMDDHH. There are not indexes on the table except for the large composite key with 5 columns starting with time stamp column as the first column in the key.
Engine: InnoDB only
The data that is getting inserted every seconds needs to be aggregated at the end of 1 hour for hourly summarization.
The hourly summarized data needs to be aggregated again at the end of the day for daily summarization.
There are set of queries(procedures) that can access data for real time analytics. The duration can be for last 10 minutes, last 1 hour and sometimes for a given time interval which is the past (Custom reports).
Insertion speed seems to be good with around 2 seconds for each file.
Query performance for 5 minutes seems to be just fine. Anything beyond this is completely not in the acceptable range.
Below is the My.cnf file snapshot:
# Optimized mysql configuration file with MySQL support inputs
# The following options will be passed to all MySQL clients
port = 3306
socket = /tmp/mysql.sock
# Set the open_files_limit to a higher number(partition with the innodb_file_per_table
# option enabled requires more open files
open_files_limit = 32768
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# Disable Federated by default
# Replication Master Server (default)
# binary logging is required for replication
# binary logging format - mixed recommended
# number of days to keep binary logs
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Try number of CPU's*2 for thread_concurrency
innodb_thread_concurrency = 32
innodb_table_locks = 0
innodb_file_per_table = 1
innodb_data_home_dir = /usr/local/var/
innodb_buffer_pool_size = 4G
# Set .._log_file_size to 25 % of buffer pool size
innodb_additional_mem_pool_size = 32M
innodb_log_buffer_size = 16M
innodb_lock_wait_timeout = 120
innodb_open_files = 32768
innodb_log_file_size = 512M
innodb_doublewrite = 0
innodb_file_io_threads = 16
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_checksums = 0
max_allowed_packet = 16M
# Remove the next comment character if you are not familiar with SQL