转自: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.
分享到:
相关推荐
"Scalability Mastery" Scalability是指系统、软件或应用程序能够满足增长和变化的需求,而不影响其性能和可靠性。Scalability是一个非常重要的概念,在现代软件开发和 IT 行业中扮演着关键角色。下面是从《The Art...
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 pdf ...MySQL 8 - Scalability & High Availability MySQL 8 - Security Optimizing MySQL 8 Extending MySQL 8 MySQL 8 Best Practices & Benchmarking Troubleshooting MySQL 8
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 ...
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 ...
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...
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 ...
本文档《5 Scalability Poisons and 3 Cloud Scalability Antidotes》将深入探讨这些毒药和解药,并给出实际的解决策略。 首先,我们来探讨五个影响系统可扩展性的因素: 1. 对象关系映射器(Object Relational ...
### HDFS可扩展性:增长的极限 #### HDFS与Hadoop Hadoop Distributed File System (HDFS)作为Hadoop项目中的一个核心组件,是一种开放源代码系统,它被广泛应用于处理大规模数据集的场景中。...
Improving .NET Application Performance and Scalability provides an approach to engineering applications for performance and scalability.
##### 3.4 HA/Scalability Guide - **高可用性**: 包括 MySQL Thread Pool、MySQL Partitioning 等。 - **扩展性**: 如 MySQL Proxy、MySQL and Virtualization 等。 #### 四、安全与合规 ##### 4.1 Security - ...
- **HA/Scalability**: 高可用性和可扩展性解决方案,如MySQL和DRBD的集成。 - **Storage Engines**: 多种存储引擎支持,如InnoDB、MyISAM等。 - **Globalization**: 国际化支持,包括多语言环境和字符集管理。 ###...
- **HA/Scalability Guide**:介绍如何设置高可用性和可扩展性的 MySQL 架构。 - **Server Administration**:涵盖服务器管理的基础知识,包括安装、配置和日常维护。 - **MySQL Yum Repository**:介绍了如何使用 ...
8. MySQL Enterprise Scalability(第10部分):这部分内容可能讲述了如何利用MySQL企业版来扩展数据库应用,以应对高流量和高并发情况。 9. MySQL Enterprise High Availability(第11部分):讨论了如何使用MySQL...
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, ...
- **HA/Scalability Guide**:文档中还包含了一个关于高可用性和可扩展性的指南,这对于构建能够处理大量数据和高并发访问的应用程序至关重要。 - **MySQL Yum Repository**:为便于在Linux系统上安装MySQL及其相关...
5. **性能vs可扩展性(Performance vs Scalability)**: - 如果系统对单个用户响应缓慢,可能是性能问题;如果系统对单个用户快速响应,但在高负载下变慢,则是可扩展性问题。 6. **延迟能力vs吞吐量(Latency vs ...