mysql tuner reports that mySQL can use 166% of installed ram, how do I limit RAM usage ?
[!!] Maximum possible memory usage: 426.8M (166% of installed RAM)
You can either configure
Before allocating memory to either engine, it is good to reflect on what caching goes with each Storage Engine
Configuring for MYISAM
The main mechanism used is the key cache. It only caches index pages from .MYI files. To size your key cache, run the following query:
This will give the Recommended Setting for MyISAM Key Cache (key_buffer_size) given your current data set (the query will cap the recommendation at 4G (4096M). For 32-bit OS, 4GB is the limit. For 64-bit, 8GB.
Configuring for InnoDB
The main mechanism used is the InnoDB Buffer Pool. It caches data and index pages from InnoDB tables accessed. To size your InnoDB Buffer Pool, run the following query:
This will give the Recommended Setting for the size of the InnoDB Buffer Pool (innodb_buffer_pool_size) given your current data set.
Don't forget to resize the InnoDB Log Files (ib_logfile0 and ib_logfile1). MySQL Source Code places a cap of the combined sizes of all InnoDB Log Files must be < 4G (4096M). (NOTE: Percona Server binaries surpass this. I recently setup a large DB server with 4G for a single InnoDB Log File using innodb_log_file_size)
For the sake of simplicity, given just two log files, here is how you can size them:
At the End of both queries is a an Inline Query :
There is no substitute for common sense. If you have limited memory, a mixture of storage engines, or a combination thereof, you will have to adjust for different scenarios.
If you have 2GB RAM and 16GB of InnoDB, allocate 512M as
If you have 2GB RAM and 4GB of MyISAM Indexes, allocate 512M as
If you have 2GB RAM and 4GB of MyISAM Indexes and 16GB InnoDB, allocate 512M as
Possible scenarios are endless !!!
Remember, whatever you allocate for, leave enough RAM for DB Connections and the Operating System.
You should tweak
in case of Myisam Engine
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections
this value gives the total possible memory that mysql can consume.This should be less than your RAM or nearly 60 % of RAM. incase of innodb innodb_buffer_pool_size should be less than your RAM or 60% of your ram
Tune above values,so that RAM usage will be 60% of your RAM.