Skip to content

Instantly share code, notes, and snippets.

@tobalsan
Created July 29, 2014 11:32
Show Gist options
  • Save tobalsan/b1897bc7b9f39abb6079 to your computer and use it in GitHub Desktop.
Save tobalsan/b1897bc7b9f39abb6079 to your computer and use it in GitHub Desktop.

Improve memory usage on AMAZON EC2 Micro instance

Try to Change this setting in mysql configuration file (my.cnf)

key_buffer              = 8M 
max_connections         = 30 // Limit connections
query_cache_size        = 8M // try 4m if not enough 
query_cache_limit       = 512K
thread_stack            = 128K

Just to add to the other answer. I recently had this problem myself with the Amazon micro instance (not Ubuntu). The my.cnf file is almost empty so what I did was this:

cp /etc/my.cnf /etc/my.cnf.orig
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

Edit my.cnf and enable the innodb lines if applicable. Restart mysqld.

Also the micro instance has no swap, that might be a problem..

$ SWAPFILE=/mnt/swapfile.swap
$ dd if=/dev/zero of=$SWAPFILE bs=1M count=512
$ mkswap $SWAPFILE
$ swapon $SWAPFILE

Then in /etc/rc.local add:

swapon /mnt/swapfile.swap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment