Download - SOLUTION BUNDLES

Transcript
Page 1: SOLUTION BUNDLES

SUN AND MYSQLSOLUTION BUNDLES

Guide to optimizing the Sun Fire™ X4100 M2 or X4200 M2 servers andthe Sun StorageTek™ 2530 Storage Array for MySQL applications

February 2008

Page 2: SOLUTION BUNDLES

Sun Microsystems, Inc.

Table of Contents

Optimizing MySQL® with Sun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Business Drivers – The Balance of Strategy and Operations. . . . . . . . . . . . . . . . . . . 1

The Sun MySQL Bundle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Sun Fire™ X4100 M2 and X4200 M2 – More than a Pizza Box . . . . . . . . . . . . . . . . . . 4Sun SAS HBA for HA and non-HA Storage Connectivity . . . . . . . . . . . . . . . . . . . . . . 5Sun StorageTek 2530 – Faster MySQL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Steps for Optimizing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Define and Assess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Preparation and Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Optimize for I/O Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Optimize MySQL Memory and CPU Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Optimize File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Benchmark and Adjust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Appendix A – Optimization Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14MySQL Sysbench Benchmark Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Hardware Installed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Software Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Sysbench Benchmarks for X4100 M2, X4200 M2, and StorageTek 2530. . . . . . . . . 1532 User Read-Only Test Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1532 User Read/Write Test Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16MySQL Settings for Benchmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Page 3: SOLUTION BUNDLES

Optimizing MySQL® with SunThe MySQL database has become the world’s most popular open source database

because of its world-class performance, high-reliability, and ease-of-use. It’s used in

more than 11 million installations ranging from large corporations to specialized

embedded applications on every continent in the world. Sun has teamed with AMD

to build optimized 64-bit, high performance server/connectivity/storage solution

bundles to meet the application demands of customers with of Web 2.0, SME and

departmental database requirements. The word “optimized” means different things

to different IT managers. In this paper, we provide framework for assessing, installing,

and configuring MySQL environments to run faster, safer, and more efficiently on Sun’s

AMD based platforms.

Business Drivers – The Balance of Strategy and OperationsMore than ever, IT is the engine that drives business operations. IT has become woven

into the very fabric of our businesses. The role of IT often shifts between strategic and

operational depending on the program in question. This year Web 2.0, Green IT,

Virtualization & Consolidation, and providing better IT Service Level Agreements (SLAs)

at lower costs are high on the list of topics.

• Web 2.0 with MySQL – Wiki’s, smashups, and social networking for business are at

the forefront of the Web 2.0 movement. Most of these applications need fast,

efficient, and flexible databases. These tools are growing because they help

businesses collect and leverage the “tribal knowledge” to make the entire organiza-

tion smarter and more effective. They help bridge groups of people to solve real

business challenges for development and customer support.

• Virtualization and consolidation – Nothing has had a more dramatic effect on IT in

the last two years than virtualization. Like a good smashup application that brings

new value to old data, virtualization, power and cooling costs, and multi-core CPUs

have created a “Perfect Storm” of opportunity. These technologies have appeared

at just the right time, addressing the ongoing need to improve IT efficiency,

process more transactions, store more data, and support more customers with

lower overhead.

• Green IT – Green IT is not just about saving the planet, it’s about the real hard dollar

costs of power, cooling, and rack space in datacenters. In many IT shops in major

metropolitan areas, such as London or in the financial district of New York City, extra

power is not available, or has multi-year waiting lists. According to IDC, power and

cooling costs will exceed $40B (USD) by 2010. IT managers need to partner with

vendors who can help them build a Green IT strategy.

Sun Microsystems, Inc.1 Sun and MySQL Solution Bundle Optimization Guide

Page 4: SOLUTION BUNDLES

• Higher SLAs, for less money – This is a theme that never goes away in any business.

Global competition is relentless. If your company does not optimize, then a new

company will. The secret to higher SLAs for less money is picking solutions that are

optimized, designed for lights out operation and support by a global player, ready to

deploy and ready to make the IT manager’s life easier.

Sun is working with leading technology partners to help IT managers meet these

strategic and tactical needs. Sun and AMD are leaders in virtualization, consolidation,

Green IT and providing higher levels of SLAs. The MySQL bundle is designed to simplify-

deployment and optimization to meet these growing IT needs.

The Sun MySQL BundleSun and AMD are leaders in innovative performance computing. Together they have

teamed to bring the world-class performance of the Sun Fire X4100 M2 and X4200 M2

servers and Sun StorageTek 2530 storage array in a pair of solution bundles that are

ideal for SMEs and departmental needs. For added value, Sun recommends customers

purchase a Sun Spectrum Service plan and take advantage of features such as

hardware service coverage, telephone and online technical support, SunVIP interop

support, and firmware updates to help reduce storage system management costs and

improve performance.

Sun Microsystems, Inc.2 Sun and MySQL Solution Bundle Optimization Guide

The growth of power costs in IT. Source: IDC, 2006.

Page 5: SOLUTION BUNDLES

Bundle details for optimized non-HA and HA MySQL applications:

Sun Microsystems, Inc.3 Sun and MySQL Solution Bundle Optimization Guide

MySQL Solution Bundle #1

One Sun Fire X4100 M2 server• AMD 2220 CPU, 8 GB DDR 400 RAM• Dual 146 GB SAS and DVD drives

One Sun SAS HBA

One Sun StorageTek 2530 array• 12 SAS, 73 GB, 15K RPM drives

Two Sun Fire X4200 M2 servers• AMD 2220 CPU, 8 GB DDR 400 RAM• Dual 146 GB SAS and DVD drives

Four Sun SAS HBAs

One Sun StorageTek 2530 array• 12 SAS, 146 GB, 15K RPM drives

MySQL Solution Bundle #2

Page 6: SOLUTION BUNDLES

Sun Fire X4100 M2 and X4200 M2 – More than a Pizza BoxThe venerable 1U server is often called the pizza box. Those are not words that

describe the Sun Fire X4100 M2 server, a traditional 1U form factor (Brooklyn Style) and

the Sun X4200 M2, a 2U (Chicago Deep Dish) server. In selecting the solution bundle

components from Sun’s portfolio of products, we chose a best-in-class platform that

helped set a world record for database performance. How do we define best-in-class

for running MySQL?

• More MySQL transactions with HyperTransport memory – For database applications,

the faster the memory, the better it can perform transactions. The HyperTransport

architecture of the X4100 M2 and X4200 M2 servers run MySQL faster with aggre-

gate bandwidth up to 24 GB/s per processor. The AMD Opteron processor with

HyperTransport provides a scalable direct connection between processors, I/O

subsystems, and other chipsets. HyperTransport technology helps reduce the

number of buses in a system, which lowers transaction overhead to improve

MySQL transactions and queries.

• Industry leading CPU performance1 – The AMD multi-core CPUs of the Sun Fire

X4100 M2 and X4200 M2 servers deliver industry leading x86 CPU horse power. This

enables greater consolidation of servers and more VMs of a single system, higher

performance at a lower cost with managers improve SLAs, lower acquisition costs,

and increased consolidation.

• Low power and cooling demands2 – The AMD family of CPUs are more power

efficient CPUs. The Sun Fire X4100 M2 and X4200 M2 servers also use a 2.5 inch

Serial Attached SCSI (SAS) enterprise class disk drive that offers IOPS performance

increase and 58 percent power savings compared to today’s 3.5 inch drive. This

helps IT managers build a Green IT strategy.

• More connectivity for better virtualization – The Sun Fire X4100 M2 and X4200 M2

servers are the only systems in this class with 4 native 1 GbE ports and embedded

SAS ports on the base board. The extra connectivity on the Sun Fire X4100 M2 and

X4200 M2 servers increase systems accessibility by clients and make it more capable

of hosting high performance applications, and supporting more VMs for a larger set

of clients. This increased connectivity allows for more bandwidth, without using

expansion slots and use less power.

1 sun.com/servers/entry/X4100M2andX4200M2/2 sun.com/servers/entry/X4100M2andX4200M2/

Sun Microsystems, Inc.4 Sun and MySQL Solution Bundle Optimization Guide

Page 7: SOLUTION BUNDLES

• More flexible RAS and HA options – The Sun FireX4100 M2 and X4200 M2 servers

provide the most flexible hot-swap components in its class. This increased

functionality, combined with our stand-alone ILOM, for lights-out operation makes

the Sun Fire X4100 M2 and X4200 M2 servers the leader for HA and RAS in the

x86 market.

Sun SAS HBA for HA and non-HA Storage ConnectivityThe MySQL HA bundle includes four high performance PCIe SAS Host Bus Adapters

(HBAs) and cabling that provide redundant storage connectivity across both servers.

This enables better load balancing and fail over using Suns tools or native OS features.

The non-HA MySQL bundle includes a single high performance PCIe SAS HBA and

cabling for easy connectivity to the Sun StorageTek 2530. Sun’s PCIe SAS HBA

addresses the need for SAS connectivity in the MySQL Bundle. This HBA offers out-

standing performance by matching 8-lanes of PCIe, with 8-lanes of 3 Gb/s SAS. The SAS

interface allows for point-to-point connection enabling higher performance, increased

aggregate bandwidth, higher availability with dual-ported drives, and enhanced

reliability when compared to parallel SCSI. The SAS interface provides universal

interconnect with Serial ATA (SATA), while still offering logical SCSI compatibility along

with the reliability, performance and manageability available in SAS drives. Common

electrical and physical connection allows for the application to dictate the technology

of choice for disk drives. The Sun StorageTek™ PCIe, SAS Host Bus Adapter, 8-port,

supports the following:

• Two x4 external miniSAS connectors (SFF-8088)

• Connects to both SAS and SATA HDDs

• Allows up to 244 end-point devices

• Enterprise-class HBAs ideal for large or mixed OS environments

• Features the award-winning Fusion-MPT HBA architecture from LSI

• Includes an installed low-profile bracket and full height bracket

• Simultaneous on-board support for x64/x86 BootBIOS (Windows and Linux) and

Solaris™ SPARC OpenBoot

Sun Microsystems, Inc.5 Sun and MySQL Solution Bundle Optimization Guide

Sun Fire X4100 M2 and Sun Fire X4200 M2 servers

Sun Fire X4100 M2For more detailed product images, visit sun.com/servers/entry/x4100

Sun Fire X4200 M2For more detailed product images, visit sun.com/servers/entry/x4200

Page 8: SOLUTION BUNDLES

Sun Microsystems, Inc.6 Sun and MySQL Solution Bundle Optimization Guide

Sun StorageTek 2530 – Faster MySQL QueriesStorage is a key component of optimizing MySQL performance. For this bundle, we

selected the SAS-based StorageTek 2530. SAS is the latest storage technology to be

globally adopted for the enterprise, because it brings the high performance and

reliability at a lower cost. The StorageTek 2530 is what SMEs and departments need to

build mission-critical applications on a frugal budget. The Sun StorageTek 2530 array is

an easy-to-use array that delivers better price/performance and greater rack density

than comparable solutions. The StorageTek 2530 is a leading example of Sun’s storage

expertise to provide best-of-breed technology, reliability, and affordability.

• Easy to configure and manage for MySQL – The Sun StorageTek 2530 is ready to

support MySQL out of the box, making storage management as easy as server

provisioning. The SMI-S-compliant Sun StorageTek Common Array Manager (CAM)

software ensures a friendly user interface from setup to administration. The Web-

based task management interface puts you in control of the array and significantly

reduces the complexity of installation, configuration, and management. Online

capacity expansion, data volume control creation, and host-to-volume mapping are

just a click away, making it easy to make changes quickly and efficiently. CAM is

accessible from anywhere in the world and includes automated diagnostics so you

can focus on precise, predictable, repeatable results. CAM also scales across Sun’s

entire modular disk portfolio.

• More MySQL transactions with 15K SAS Drives – The StorageTek 2530 supports

multiple sizes and speeds of drive. MySQL has multiple performance needs.

The Jet and Streaming databases that underlie the application need storage that is

optimized for random access, while log files require storage that is optimized for

sequential transactions. The StorageTek 2530, bundled with 73 GB or 146 GB SAS

drives, provide high performance write-through capability. Additional write-through

performance can be added by expanding to 36 drives.

• Data protection for MySQL – Managing growth and expansion doesn’t come

easily, especially when you’re operating within a budget. With dual-active RAID

controllers, high availability, and high density, the Sun StorageTek 2530 array

provides a cost-effective solution that lets you take advantage of improved perform-

ance and low-cost growth. The Active-Active configuration supports load balancing

and failover for improved performance and HA.

Page 9: SOLUTION BUNDLES

Sun Microsystems, Inc.7 Sun and MySQL Solution Bundle Optimization Guide

Steps for Optimizing MySQLOptimizing your MySQL environment takes planning and understanding of the specific

application running on the database—the SLAs required and the type of I/O required

for the specific application. MySQL can be used for a wide variety of applications and

data types; this means that one-size-dose-not-fit-all for optimization parameters and

settings. In this section we outline a way to evaluate the right settings of your

application.

Sun StorageTek 2530

Dual ActiveRAID Controllers• 12x Hot-Swap SAS drives• Bundle #1 – 73 GB @ 15K RPM• Bundle #2 – 146 GB @ 15K RPM

Dual Hot-SwapActive-ActiveRAID Controllers• Expansion connections• Management Ports

Dual Hot-SwapPower/Cool Modules• Dual Power connectors

Front View

Rear View

For more detailed product images, visit sun.com/storagetek/disk_systems/workgroup/2530/

Steps for optimizing MySQL.

Page 10: SOLUTION BUNDLES

Sun Microsystems, Inc.8 Sun and MySQL Solution Bundle Optimization Guide

Define and AssessUnderstanding the data is the first step in optimizing the bundled infrastructure to

support MySQL. The nature of the read/write activity and ratios is vital to establish

which settings will help optimize your solutions. The reason for this is to find the

optimal buffers and caches to reduce excess memory and I/O traffic that are tied to the

data characteristics.

• What data types – Knowing your data type helps you understand what type of

pipeline to create to optimize data transfers, pipeline data movement though the

server, reduce memory usage, optimize read/write operations out of cache to

improve performance and in and out of caches. Each data type requires different

pipelining through the servers and on the array.

Operation Block Size Mode

Write Small Random

Write Large Random

Write Small Sequential

Write Large Sequential

Read Small Random

Read Large Random

Read Small Sequential

Read Large Sequential

• User connections – Knowing this up front enables better understanding of the

overall work load on the server, what MySQL storage engine to load, how to set the

buffers and caches, how to distribute I/O across the SAS links to the storage, and

how to configure the array to support the applications. MySQL is a single-process,

multithreaded application. Besides one master thread with highest priority to con-

trol the server, it creates a dedicated user thread running at normal priority in the

thread pools for each simultaneous client request to process the user request and

send back the result to each client once the result is ready. And there is one single

user thread that waits for input from the console and a group of utility threads

running at lower priority to handle some background tasks.

Currently, MySQL cannot scale well with the number of the user threads handling

client requests. Performance scales up efficiently with each additional user thread

until it reaches the peak performance point. After that, increasing the number of

user connections will decrease MySQL performance because of thread concurrency

contention. For applications where the number of user connections is tunable,

you need to determine—for different workloads—the optimum number of user

connections for peak performance.

• Regulatory requirements – Is this application subject to any specific regulatory

or security/access control requirements? Does the data need to be stored in a

dedicated LUN? What are the business continuance requirements? Does the data

need to replicated synchronously or asynchronously, locally or remotely? It is

important to understand these requirements before the optimization is planned.

Page 11: SOLUTION BUNDLES

Sun Microsystems, Inc.9 Sun and MySQL Solution Bundle Optimization Guide

• SLA requirements – As with regulatory requirements, SLAs drive the type of storage

and data protection model that needs to be implemented on the array, how the

data is backed up, how often the backup/snapshot is run. SLAs also help set the

business continuance requirements for the application.

Preparation and InstallationThe preparation for installing the new Sun Fire X4100 M2 or X4200 M2 servers, and

the StorageTek 2530 starts with four basic items:

• Select server bundles – For My SQL applications that are under 1 TB and do not

require HA configurations we recommend the Sun MySQL Bundle #1 with one

Sun Fire X4100 M2 server and the StorageTek 2530 loaded with 73 GB drives. For

data based that require HA servers and are over 1 TB in size we recommend Sun’s

MySQL Bundle # 2 with two Sun Fire X4200 M2 servers, connected to storage via

4 SAS HBAs and has the data stored on the StorageTek 2530 loaded with 146 GB

drives.

• Physical location – Finding the right rack space, power and cooling to support the

hardware, and required switches and other infrastructure. This should be a simple,

but required step.

• Installing the Sun Fire X4100 M2 or X4200 M2, StorageTek 2530 and OS – Sun pro-

vides a detailed step-by-step installation and configurations guide for each product

at http://docs.sun.com/app/docs/prod/5b03d0ed-216d-11db-a023-080020a9ed93.

Next is to load the OS of choice for the applications and set up the basic RAID and

LUN configuration to hold new or migrated data.

• Protect, migrate and validate the data – If this hardware is replacing a current

server, make sure you have a complete backup of the data set to be moved,

preferably to another disk array for rapid access. Next, migrate the data from the

old server storage to the new StorageTek 2530 array and server. Finally, validate that

the data set was moved properly, especially if you have to erase the backup and

original copies.

• Load MySQL – The next step in the optimization process is to load MySQL onto the

new Sun Fire X4100 M2 or X4200 M2 server and test access to the data on the

new array.

Optimize for I/O TypesNow we are ready to begin the optimization process. We have identified that the I/O

types in our assessment phase.

• Baseline I/O loads – Next is to baseline the current workloads and I/O types on the

server. This will help measure optimizations in the final benchmarking phase.

• Group I/O types – As we have discussed, optimizations for random, small read/write

are not the same as larger sequential read/write. If you have multiple I/O types, try

to segment them on multiple servers or VMs.

• Leverage I/O settings – Grouping similar I/O types together will allow the proper

cache, files system settings and MySQL storage engines to be used for optimization.

Page 12: SOLUTION BUNDLES

Sun Microsystems, Inc.10 Sun and MySQL Solution Bundle Optimization Guide

Optimize MySQL Memory and CPU OptionsThe next step is to reduce unneeded functions that steal memory and CPU

performance. These include extra buffers that cause extra memory moves of data

and consume CPU resources.

• Reduce CPU and memory uses – One of the key advantages of Open Source

software solutions is the flexibility to optimize for any need. Using the

mysql> show variables will help identify the configuration and system variables.

You can then change values in the my.cnf configuration file, or mysql start up

options to remove or adjust the following MyISAM memory-related variables if

you have only Innodb tables in your system:

– bulk_insert_buffer_size

– key_buffer_size

– key_cache_age_threshold, key_cache_block_size

– key_cache_division_limit

– read_buffer_size, read_rnd_buffer_size

• Optimize tables – Make sure the tables in the database are optimized for the type of

queries and sorts required by the application.

• Identify common queries – MySQL query cache stores the identical SELECT queries

issued by clients to the database server. This makes it possible to locate and re-issue

the same queries without repetitive hard parsing activities. MySQL also stores the

query’s result set in the query cache, which can significantly reduce the overhead of

creating complex result sets for queries from the disk or memory caches, reducing

both physical and logical I/O. This can speed up applications where repetitive

queries of products are being issued. If you see a high value for qcache_hits

compared to your total queries at runtime or a low value for qcache_free_memory

seen from the mysql>show status, you probably need to increase the value of the

query_cache_size parameter accordingly. Otherwise, you would decrease the value

of the query_cache_size parameter to save memory resources for the other MySQL

cache buffers. If qcache_hit is 0 in the runtime, you would completely turn off

the query cache by setting query_cache_type as 0, together with setting

query_cache_size as 0, since there is some overhead caused by having the query

cache enabled besides wasting the memory resource.

Page 13: SOLUTION BUNDLES

Sun Microsystems, Inc.11 Sun and MySQL Solution Bundle Optimization Guide

If the application uses many simple SELECT queries without repeating, having query

cache enabled may actually impede performance by 5-10 percent. However, for

the applications having many repeated SELECT queries with large result set, the

performance increase set by the query cache can be 200 percent or more.

– table_cache – Size cache to keep most of tables open since opening tables can be

expensive. The optimum value for table_cache is directly related to the number

of tables that need to be open simultaneously in order to perform multiple-table

joins. The table_cache value should be equal to no less than the number of

concurrent connections times the largest number tables involved in any one join.

1024 is a good value for applications with couple hundreds tables (each connec-

tion has its own entry). You should check the Open_tables status variable to see if

it is large compared to table_cache.

• Select and configure the MySQL I/O engine – MySQL has many variables that can

be adjusted to change the MySQL behavior or for performance purpose. MySQL

includes several storage engines, including MyISAM, InnoDB, HEAP, and Berkeley DB

(BDB), some variables apply to one of the storage engines only, some variables are

used in the SQL layer applying to all the storage engines. There are several memory-

related variables apply for all storage engines. This allow you to optimize the

storage engine in MySQL:

– join_buffer_size – Buffer used for full join. In case there are large joins without

indexes, increase this buffer size to improve the efficiency.

– sort_buffer_size – Buffer used for sort result set allocated by each thread. This can

speed up ORDER BY and GROUP BY queries.

– query_cache_size – Set this variable to a nonzero value to enable query caching

query_cache_limit – The maximum size for cached result set, the larger result set

won’t be cached.

– query_cache_min_res_unit – Query cache allocate memory blocks with the

minimum size set by this variable. When the application has a lot of queries with

small results, default block size (4 KB) may lead to memory fragmentation. So,

with small resultsets, decreasing it to 2048 or 1024 bytes might improve perform-

ance; with large query resultsets, increase it to be 8192, 16384 or more, may

speed up the performance.

– query_cache_type – 0=OFF, 1=ON

• MySQL Innodb only memory-related variables

– innodb_buffer_pool_size – Set the amount of memory allocated to both Innodb

data and index buffer cache. MySQL doesn’t access the disk directly; instead, it

reads data into the internal buffer cache, read/write blocks, and flushes the

changes back to the disk. If the server requests data available in the cache, the

data can be processed right away. Otherwise, the operating system will request

that the data be loaded from the disk. The bigger the cache size, the more disk

accesses can be avoided. For the sysbench I/O bound workload test on the T2000

server with 8 GB RAM, increasing innodb_buffer_pool_size from 4 GB to 5 GB can

improve performance by around 11 percent.

Page 14: SOLUTION BUNDLES

Sun Microsystems, Inc.12 Sun and MySQL Solution Bundle Optimization Guide

– innodb_additional_mem_pool_size – Sets the amount of memory allocated to

the buffer storing the InnoDB internal data dictionary and other internal data

structures. This parameter does not affect performance much, so set it as 20M (in

the application with more tables, more memory needs to be allocated here) in the

sysbench OLTP test case.

– innodb_log_buffer_size – Set the amount of memory allocated to the buffer

storing InnoDB write-ahead log entries. For large transactions, before the

log buffer is flushed on each transaction commit, if your setting

innodb_flush_log_at_trx_commit is at 1, the log can be loaded into the log

buffer instead of flushing to the disk in the background to reduce the disk I/O. If

you see large log I/O in the show innodb status output at runtime, you probably

need to set a larger value for the innodb_log_buffer_size parameter. Since the

sysbench OLTP I/O bound workload doesn’t have long transactions, it is not

necessary to waste memory resources by setting a higher value for the log buffer,

so just set it as 8 MB.

• Other MySQL Innodb variables impacting I/O performance

– innodb_flush_log_at_trx_commit – InnoDB flushes the transaction log

to disk approximately once per second in the background. As a default,

innodb_flush_log_at_trx_commit is set as 1 to flush the log to the disk on each

transaction commit, which is the safest way avoiding transaction loss during

MySQL, OS, or HW crash. For workloads running with many short transactions,

you can reduce disk writing by setting the innodb_flush_log_at_trx_commit

parameter with different values. When setting this value at 0, there is no log

flushing on each transaction commit. It can reduce the disk I/O to improve

performance, however, the transaction might be lost if MySQL crashes.

– innodb_flush_log_at_trx_commit =0 – In the read-only test, this can improve

performance by 4 percent. When setting this value at 2, the log flushes to the OS

cache (file system cache) instead of the disk on each transaction commit. It can

also reduce the disk I/O and perform a little slower than when the value is set at

0; however, no transaction loss will probably occur with OS or hardware crashes).

– innodb_log_file_size – InnoDB writes to the log files in a circular fashion, so if the

log file has reached the configure limit set by the innodb_log_file_size parameter,

the checkpoint operation is executed at once to flush the modified database

pages. innodb_log_file_size is very important for write-intensive workloads,

especially for large data sets. Larger sizes reduces disk I/O in checkpointing for

better performance but increase recovery times. You will need to increase this

parameter when you see large page writes in the BUFFER POOL AND MEMORY

part of the show innodb status output.

Page 15: SOLUTION BUNDLES

Sun Microsystems, Inc.13 Sun and MySQL Solution Bundle Optimization Guide

Optimize File SystemsThe files system is the next part of the pipeline to optimize. Based on the MySQL

storage engine that was selected, I/O types, this will affect how the files system

should be configured to eliminate double buffering and disk flushing.

• Sync the file systems I/O engine read/write options – File system performance has a

big impact on the overall system performance, particularly when running I/O

bound workloads with a database size much bigger than system memory. How to

configure the file system for better performance is dependent on the workload

access pattern—random or sequential. For sequential workload, we can increase

the file system cluster size to allow reading ahead or writing back more data

from/to the disk to reduce the total number of I/O operations. For random work-

load, we can reduce the file system cluster size to match the innodb I/O size.

• Reduce double buffers and flushes to disk – Review the buffering model of the

MySQL I/O storage engine to remove double buffing. This typically occurs when

both the file’s system and the I/O engine are caching data. This causes extra

memory moves and uses extra CPU cycles. Before MySQL 5.0.42 and 5.1.18, it needs

to mount UFS with forcedirectio option. For the later MySQL 5.0.x and 5.1.x, the

directio can be enabled in my.cnf by setting innodb_flush_method as O_DIRECT.

Benchmark and AdjustThe final step is to put it all together and make any final adjustments. Using the

baseline we establish, run the same tests to measure your improvements. Some

additional tweaking may be required, but this process will help ensure that you get

the most out the Sun MySQL bundle.

Page 16: SOLUTION BUNDLES

Sun Microsystems, Inc.14 Sun and MySQL Solution Bundle Optimization Guide

Appendix A – An Optimization Benchmark

MySQL Sysbench Benchmark Configuration

Hardware Installed

Host server type Sun Fire X4100 M2 server

CPU: 4 x 2793 MHz

Memory: 7680 MB

Storage model StorageTek 2530

RAID level 5

Disk drives Twelve 73 Gb 15K SAS

Storage connectivity (Fiber Channel, SAS

SAS, SATA, iSCSI)

Number of storage groups/host One

Number of storage controllers Two

HBA model PCI-X SAS Host Bus Adapter

StorageTek 2530 configuration

Use the default storage CAMS profile for configuring the volume with RAID level 5,

we used the default segment size (512 KB) and enable read-ahead mode.

Software Installation

Host OS X4100 M2 server: Solaris OS 10 06/06

MySQL Database Server 5.0.45

Test applications sysbench

MySQL database server installation steps:

• shell> cd /usr/local

• shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

• shell> ln -s full-path-to-mysql-VERSION-OS mysql

• shell> cd mysql

• shell> scripts/mysql_install_db

• shell> chmod -R 777 *

• shell> bin/mysqld_safe --user=mysql &

Sysbench test installation steps:

• shell> cd /sysbench-version

• shell> ./configure

• shell> make

• shell> make install

Command to Load 100M-row test database:

• shell> sysbench –test=oltp –oltp-table-size=100000000 –mysql-db=sbtest100m –

max-requests=0 prepare

Page 17: SOLUTION BUNDLES

Sun Microsystems, Inc.15 Sun and MySQL Solution Bundle Optimization Guide

Sysbench Benchmarks for X4100 M2 and StorageTek 2530MySQL Sysbench OLTP I/O Bound Test on Sun Fire X4100 M2 server with

StorageTek 2530

32 User Read-Only Test Results

# of user connections Trans/Sec

2 104.73

4 251.33

8 451.56

16 555.64

32 577.96

64 563.84

128 558.66

256 519.96

Sysbench OLTP I/O bound read-only Test with 32 user connections on X4100 M2. The chart above showsthe MySQL performance improvement after tuning the innodb data and index buffer size, tuning SolarisUFS with maxcontig settings, and directio.

Sysbench OLTP I/O bound read-only test with 2-256 user connections on X4100 M2.

Page 18: SOLUTION BUNDLES

Sun Microsystems, Inc.16 Sun and MySQL Solution Bundle Optimization Guide

32 User Read/Write Test Results

# of user connections Trans/Sec

2 146.04

4 232.05

8 291.1

16 289.12

32 288.51

64 297.32

128 295.32

256 273.91

Sysbench OLTP I/O bound read-write Test with 32 user connections on X4100 M2.

Sysbench OLTP I/O bound read-only Test with 2-256 user connections on X4100 M2.

Page 19: SOLUTION BUNDLES

Sun Microsystems, Inc.17 Sun and MySQL Solution Bundle Optimization Guide

MySQL Settings for Benchmarks

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

log-error = /data/error.txt

user=root

skip-locking

max_connections = 3000

table_cache = 1024

max_allowed_packet = 1M

sort_buffer_size = 64K

thread_cache = 8

thread_concurrency = 16

query_cache_size = 0M

query_cache_type = 0

default-storage-engine = innodb

transaction_isolation = REPEATABLE-READ

tmp_table_size = 1M

innodb_data_file_path = ibdata1:100M:autoextend

innodb_buffer_pool_size = 5500M

innodb_additional_mem_pool_size = 20M

innodb_log_file_size =1900M

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit =1

innodb_lock_wait_timeout = 300

innodb_max_dirty_pages_pct = 90

innodb_thread_concurrency =16

Page 20: SOLUTION BUNDLES

Sun Microsystems, Inc.Sun and MySQL Solution Bundle Optimization Guide

© 2008 Sun Microsystems, Inc. All rights reserved. Sun, Sun Microsystems, the Sun logo, Sun Fire, StorageTek, and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States andother countries. Information subject to change without notice. SunWIN #522027 02/08

Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, CA 95054 USA Phone 1-650-960-1300 or 1-800-555-9SUN (9786) Web sun.com


Top Related