`
DavisWang
  • 浏览: 51360 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

5 Ways to Boost MySQL Scalability

 
阅读更多

转自:http://www.iheavy.com/2011/07/28/5-ways-to-boost-mysql-scalability/

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

4. RAID Your Disk I/O

What is underneath your database? You don't know? Well please find out! Are you using RAID 5? This is a big performance hit. RAID5 is slow for inserts and updates. It is also almost non-functional during a rebuild if you lose a disk. Very very slow performance. What should I use instead? RAID 10 mirroring and striping, with as many disks as you can fit in your server or raid cabinet. A database does a lot of disk I/O even if you have enough memory to hold the entire database. Why? Sorting requires rearranging rows, as does group by, joins, and so forth. Plus the transaction log is disk I/O as well!

Are you running on EC2? In that case EBS is already fault tolerant and redundant. So give your performance a boost by striping-only across a number of EBS volumes using the Linux md software raid.

5. Tune Key Parameters

These additional parameters can also help a lot with performance.

innodb_flush_log_at_trx_commit=2

This speeds up inserts & updates dramatically by being a little bit lazy about flushing the innodb log buffer. You can do more research yourself but for most environments this setting is recommended.

innodb_file_per_table

Innodb was developed like Oracle with the tablespace model for storage. Apparently the kernel developers didn't do a very good job. That's because the default setting to use a single tablespace turns out to be a performance bottleneck. Contention for file descriptors and so forth. This setting makes innodb create tablespace and underlying datafile for each table, just like MyISAM does.

分享到:
评论

相关推荐

    Guide to Optimizing Performance of the MySQL Cluster Database

    This guide explores how to tune and optimize the MySQL Cluster database to handle diverse workload requirements. It discusses data access patterns and how to build distribution awareness into ...

    MySQL 8 Administrator's Guide

    MySQL 8 Administrator's Guide pdf ...MySQL 8 - Scalability & High Availability MySQL 8 - Security Optimizing MySQL 8 Extending MySQL 8 MySQL 8 Best Practices & Benchmarking Troubleshooting MySQL 8

    Guide to Scaling Web Databases with MySQL Cluster

    This provides unique insight into the challenges of scaling web databases, which in turn has driven the development of MySQL Cluster, integrating key technologies to enable the scaling of rapidly ...

    The Art of Scalability

    A Comprehensive, Proven Approach to IT Scalability from Two Veteran Software, Technology, and Business Executives, , InThe Art of Scalability,AKF Partners cofounders Martin L. Abbott and Michael T. ...

    MySQL V5.5帮助文档

    2.1.2. Choosing Which MySQL Distribution to Install 2.1.3. How to Get MySQL 2.1.4. Verifying Package Integrity Using MD5 Checksums or GnuPG 2.1.5. Installation Layouts 2.1.6. Compiler-Specific Build ...

    5 Scalability Poisons and 3 Cloud Scalability Antidotes.pdf

    5 Scalability Poisons and 3 Cloud Scalability Antidotes

    Java Performance and Scalability

    Each optimization discusses techniques to improve the performance and scalability of your code. Every claim is substantiated with hard numbers and an experience-based evaluation. Java(TM) Performance...

    HDFS scalability:the limits to growth

    一篇讲述apache hdfs扩展性限制的文章

    Scalability patterns

    Scalability patterns

    VS5ICM_M12_Scalability.pptx

    VS5ICM_M12_Scalability.pptx

    .NET Application Performace and Scalability

    Improving .NET Application Performance and Scalability provides an approach to engineering applications for performance and scalability.

    Scalability Patterns--2018

    Architect and develop applications so that they are easy to scale. Learn different scaling and partitioning options and the combinations. Learn techniques to speed up responsiveness. Deep dive ...

    MySQL Cluster Benchmarks

    Oracle and Intel have completed a series of benchmarks to test the performance and scalability of MySQL Cluster on commodity servers equipped with the latest-generation of Intel® Xeon® E5 processor ...

    MySQL5.6同步白皮书

    MySQL Replication enables users to cost - effecti vely deliver application performance, scalability and high availability. Many of the world's most trafficked web properties like eBay, Facebook, ...

    THE BOOST C++ LIBRARIES

    THE BOOST C++ LIBRARIES是一份自己编译的chm格式文档,描述了如何使用boost类库,目录如下: Front page Chapter 1: Introduction 1.1 C++ and Boost 1.2 Development Process 1.3 Installation 1.4 Overview ...

    MySQL High Availability 2nd 原版pdf by Bell

    MySQL High Availability and Scalability team. He is architect and implementor of several MySQL features. Dr. Lars Thalmann is the development director and technical lead of the MySQL Replication, ...

    mysql面试题.rar

    In order to take advantages of scalability and performance, SequoiaSQL - MySQL Storage Engine can be used to replace InnoDB and store user data/index/lob in the backend distributed database. ...

    Java Performance and Scalability Volume 1

    Java Performance and Scalability Volume 1

    《架构即未来》英文原版,The Art of Scalability

    架构即未来 现代企业可扩展的Web架构流程和组织 英文原版 第二版 The Art of Scalability 2nd.pdf

Global site tag (gtag.js) - Google Analytics