This is a mirror of official site: http://jasper-net.blogspot.com/

5 Ways to Boost MySQL Scalability

| Tuesday, August 2, 2011
There are a lot of scalability challenges we see with clients over and over. The list could easily include 20, 50 or even 100 items, but we shortened it down to the biggest five issues we see.

1. Tune those queries

By far the biggest bang for your buck is query optimization. Queries can be functionally correct and meet business requirements without being stress tested for high traffic and high load. This is why we often see clients with growing pains, and scalability challenges as their site becomes more popular. This also makes sense. It wouldn't necessarily be a good use of time to tune a query for some page off in a remote corner of your site, that didn't receive real-world traffic. So some amount of reactive tuning is common and appropriate.

Enable the slow query log and watch it. Use mk-query-digest, the great tool from Maatkit to analyze the log. Also make sure the log_queries_not_using_indexes flag is set.  Once you've found a heavy resource intensive query, optimize it!  Use the EXPLAIN facility, use a profiler, look at index usage and create missing indexes, and understand how it is joining and/or sorting.

2. Employ Master-Master Replication

Master-master active-passive replication, otherwise known as circular replication, can be a boon for high availability, but also for scalability.  That's because you immediately have a read-only slave for your application to hit as well.  Many web applications exhibit an 80/20 split, where 80% of activity is read or SELECT and the remainder is INSERT and UPDATE.  Configure your application to send read traffic to the slave or rearchitect so this is possible.  This type of horizontal scalability can then be extended further, adding additional read-only slaves to the infrastructure as necessary.

3. Use Your Memory

It sounds very basic and straightforward, yet there are often details overlooked.  At minimum be sure to set these:

    innodb_buffer_pool_size
    key_buffer_size (MyISAM index caching)
    query_cache_size - though beware of issues on large SMP boxes
    thread_cache & table_cache
    innodb_log_file_size & innodb_log_buffer_size
    sort_buffer_size, join_buffer_size, read_buffer_size, read_rnd_buffer_size
    tmp_table_size & max_heap_table_size


Read more: SQL Zone
QR: 5-ways-boost-mysql-scalability

Posted via email from Jasper-net

0 comments: