Leveraging MySQL Features for Availability & Scalability ABSTRACT: By Srinivasa Krishna Mamillapalli MySQL is a popular, open-source Relational Database Management System (RDBMS) designed to run on almost any hardware. Its popularity can be attributed to its ease of use as well as its speed, reliability, and scalability. There are other databases out there in the world, so what makes MySQL unique when compared with other database management systems? How can you best leverage MySQL s features for ensuring you have a database with high availability that is also scalable? This Datavail white paper will examine the benefits of using MySQL, how to optimize it for high availability, how to configure it for scalability, and how to use diagnostic tools for measuring database performance. We'll also look at some cool new features in MySQL 5.7.9.
Leveraging MySQL Features for Availability and Scalability
content The Benefits of Using MySQL... 1 MySQL is Simple but Effective... 1 Replication for High Availability... MySQL Scalability... Measuring MySQL Performance... What s New in MySQL 5.7.9... MySQL Support... 1 2 2 2 3 About Datavail... 4
The Benefits of Using MySQL What are some of the compelling benefits associated with MySQL? Here's the short list: Open source Free to use Runs on almost any hardware Easy to install Easy to manage Easy to maintain Fast Reliable Scalable Used by numerous corporations of all sizes worldwide. MySQL is very easy to use. It s very flexible and runs on all the major operating systems, including UNIX, Linux, and Windows. Its open-source nature allows it to be easily customized to meet an organization s unique data requirements and application needs. This is why it has been deployed by many companies and organizations in sectors as varied as education and healthcare, telecommunications and social networking. These companies include Twitter, YouTube, NASA, Kayak, LinkedIn, and Virgin America. Since the software s release in May 1995, the installed base of MySQL users has continued to grow. Originally used for e-commerce, the use cases migrated to online analytical processing (OLAP) and data warehousing. Today, people use MySQL as a solution service, both for delivering platform-as-a-service (PAAS) and for providing infrastructure-as-a-service (IAAS). Many companies, including Google and Facebook, have customized MySQL and contributed to the open-source community group. This growth has also involved the release of several forks, such as Percona, MariaDB, Galera, and Drizzle. The newest version of MySQL is MySQL 5.7.9, which was released by Oracle Corporation in October 2015. MySQL is Simple but Effective Users have to be able to retrieve their data whenever and wherever they need it. They should be able to retrieve it immediately and using as few resources as possible. The data should be reliable and consistent: the correct and accurate data has to be retrieved each and every time a user enters a query (instead of stale or inconsistent data). It is also essential for an organization to have a cost-effective, scalable database management solution. This is where MySQL comes in. It doesn t need any fancy hardware or high-end processing. In fact, it can run with as few as 250 megabytes of memory and can even run on a single core system. It is also portable. It can run on any hardware or any cloud solutions. It is easily installed, managed, and maintained; a MySQL installation can be up and running with the server ready for its first query within less than 10 minutes. That s how simple it is. Because MySQL is open source, users don t have to worry about paying expensive licensing fees, tremendously reducing their databases operational costs. To be certain the data is available and meeting the continuous growth needs of the application is a big challenge. How can MySQL can meet all these demands? Replication for High Availability Replication is a key feature in MySQL that enables users to develop a database with high availability. In a nutshell, replication is as simple as a master-slave set up. Rather than having the data on a single piece of hardware, the data is replicated on another server such that, if anything happens to the primary server, the data can be found and easily recovered. There are several different replication topologies possible within MySQL. These include single master-slave replication and master-master replication. The latter type of replication can be executed with some constraints. With the release of MySQL 5.7, multi-source replication is possible. This enables several different replication technologies that provide different types of read-write distributions. These include: single master to multiple slaves replication chained replication multi-layer replication Multi-source replication, no matter which topology you use, is fairly reliable, even across environments in which hundreds of servers are running. You are familiar with replication from a single master to multiple slaves or a one-to-many approach; but what if you want to replicate from two or more different masters to a single server? MySQL incorporated some channel mechanisms allowing you to specify on a slave server what channel to replicate, what part of the data to replicate, and from which master to replicate the data. This allows you to configure multiple channels from multiple sources and to duplicate all the data such that it resides in a central depository. Page 1 Leveraging MySQL Features for Availability and Scalability 2016 Datavail, Inc. All rights reserved.
A new feature called Global Transaction Identifier maintains data integrity across all nodes in the replication chain. Thus, based on a unique identifier attached to the data, all the nodes involved in replication are responsible for acknowledging when they have received that transaction ID. MySQL 5.7.9 contains several other features designed to further enhance this transaction consistency and synchronization in comparison to conventional log-based replication methods. Enhanced ability and flexibility in replication makes it easier to scale operations as transaction volumes increase. MySQL Scalability MySQL is highly scalable, thanks to several features. Chief among these is its support for replication. As mentioned previously, you can use master-slave replication to distribute traffic across the slave regions. And synchronous replication also contributes to scalability. MySQL also enables scalability by its support for: Multiple CPU cores Read-write intensive work loads Partitioning Sharding Most database administrators typically ask, When should we start planning for scalability? and What is the best thing to do? Start planning now. The most important task is to start by ensuring you have MySQL properly configured. A properly configured MySQL environment can easily support (depending on the application design) roughly 10,000 concurrent user connections and it can grow to hold as many as 64 terabytes of data. It s unbelievable what a single MySQL engine can deliver without having to worry much about scaling partitioning, sharding, or using any third-party solutions. Measuring MySQL Performance How can you measure the performance of your MySQL environment? How can we calculate and determine how it s performing and where it s lacking? By using the enhanced optimizer settings, we can determine the best execution plan available with minimal resource utilization. MySQL enables you to set the optimizer on a per-session basis as well as globally. You can also specify how deeply you want MySQL to be scanned to deliver a better execution plan. MySQL also offers information_schema and performance_schema objects. These can be used to see what s happening for each transaction or for each user connection. The metrics it collects allows you to see what s actually happening inside the database. With performance schema, you can capture data that allows you to determine, for example, what s causing latency issues. This includes factors such as overhead or locking information as well as everything from usersession-level information to statement-level information. You can even capture the global performance metric summaries. This information is useful for those database administrators who need to figure out what to tune and where those tuning efforts need to be concentrated. MySQL also has some nice tools available for tuning. The goal associated with providing these tools, according to Geir Hoydalsvik, a member of the MySQL Server Team, and employed by Oracle, is to move away from scripts and over to C/C++ to improve on portability and cover more usage scenarios (one cannot run scripts in all environments). One of these tools mysqlslap enables a database administrator to reproduce the traffic in their production environment. It allows you to simulate traffic from concurrent users and load so you can see how it s performing. A load balancing tool mysqlproxy allows you to determine traffic flows prior to, for example, deploying a customized script. Because it is a proxy, you can use it for all sorts of pre-production database analysis. What s New in MySQL 5.7.9 What s new in MySQL 5.7.9? It has some cool features. My favorite is multi-source replication, discussed above, but you ll also find: JSON Support Virtual Columns Multiple Triggers/multiple events per table Virtual columns, for example, provide users with a functional-based indexing metrology. Several improvements allow virtual columns to function as community members originally intended. Within the undo log in the prior release, users found, insufficient information about virtual columns and virtual column indexes, which could cause a server exit when adding or dropping virtual columns, according to the new release notes. Leveraging MySQL Features for Availability and Scalability Page 2
Related virtual column bugs caused errors to be returned, modified data incorrectly, or caused server exits. As now designed, metadata from the non-materialized virtual columns is registered in the InnoDB system tables and metadata caches. The MySQL Server Team explains: Virtual columns provide flexibility and space savings for the table, and more importantly, adding/dropping such columns does not require a table rebuild. These behaviors make it a much better choice for storing and processing non-relational data such as JSON. However, since the columns themselves are not materialized, a scan and search could be slower than on regular (materialized) columns. However, the virtual column value is materialized in the secondary index, thus making it much easier for value searches and processing. Thus this work greatly increases the practical value of virtual columns. With this work, creating an index on virtual generated columns also becomes an ONLINE operation. There are also several additional improvements, including to features in the Optimizer specifically refactoring and accelerated connection handling. In combination, these improvements enable this version of MySQL to return 1.6 million queries per second, making it much, much faster than previous versions. It is three times faster than MySQL 5.6, according to the MySQL Server Team benchmarks. Although we administrators all strive to have MySQL available to users 24/7, there are times that simply isn t possible. One particularly useful addition to this version of MySQL is a method for bringing servers offline in the event of upgrades or routine maintenance. With the help of MySQL utilities, the servers can be placed in and out of rotation for any maintenance activity and even promote the nodes for failover/switchover operations. Administrators can connect and manage the system while it is offline. Several bug fixes in this release are important to note. These include changes in partitioning and replication, many of which are related to how InnoDB works. MySQL. Most users in these groups are very generous and help out immediately. There are also firms like Datavail that are able to provide ongoing support for your MySQL environment. Datavail supports several different implementations of MySQL for customers. For example, a major electronic parts manufacturing company turned to Datavail for assistance as the result of several scaling-related challenges it was experiencing. Because the company has many different divisions spread out geographically, it was tough for the customer s end users to retrieve the millions of records they needed daily. The main issue was the loading of records. The primary help Datavail provided was migrating the client from MySQL 5.1 to 5.6. This improved the database s performance and allowed the company to scale as well as provide a better, more reliable, cost-effective database solution across all the regions in which it operates. There are a host of resources available for those new to this database environment. If you are still uncertain about migrating to MySQL, we can help you evaluate your current database environment against your company s business priorities and future goals. If you are using a previous version of MySQL, such as 5.6, and are interested in migrating to the newest generally available edition (5.7.9), Datavail can help. With nearly 500 database administrators and 300-plus clients worldwide, Datavail is the largest database services provider in North America. With 24x7 managed database services, including database design, architecture and staffing, Datavail can support your organization s transition to the newest version of MySQL, regardless of the version you ultimately select. Contact Datavail to discuss a custom MySQL solution designed for your enterprise and to learn more about our remote database services and how our experts can help with your ongoing operations. MySQL Support Some users worry about whether, once they start using MySQL, they will have the support they need if issues arise. Because MySQL is an open-source database, there are many open-source community groups in which the members are sharing valuable information about Page 3 Leveraging MySQL Features for Availability and Scalability 2015 Datavail, Inc. All rights reserved.
Biography Srinivasa Krishna Mamillapalli Senior MySQL DBA for Datavail Krishna has more than 11 years of experience in the IT industry, including 8+ years as a MySQL database administrator with Datavail Corporation. He specializes in MySQL database administration and technologies like MongoDB, Amazon Redshift and Linux Administration and scripting. He also specializes in database architecture, DBA, HA Solutions, performance tuning, and managing enterprise level database support. About Datavail Datavail Corporation is the largest provider of remote database administration (DBA) services in North America, offering database design and architecture, administration and 24x7 support. The company specializes in Oracle, Oracle E-Business Suite, Microsoft SQL Server, MySQL, MongoDB, DB2 and SharePoint, and provides flexible on-site/off-site, onshore/offshore service delivery options to meet each customer s unique business needs. Contact Us General Inquiries: 877-722-8247 Fax Number: 303-469-2399 Email: info@datavail.com Corporate Headquarters: Datavail Corporation 11800 Ridge Parkway Suite 125 Broomfield, CO 80021 Database Operations Control Center: Datavail Infotech Pvt. Ltd 3rd Floor, Unit No. B-3 Ashar IT Park, Road No. 16Z Wagale Estate Thane (West), Thane 400604 Direct Telephone Number: 022-61517000 Bangalore Office Datavail Infotech Pvt. Ltd Concept Business Park #319/9, 1st floor, Block A Hosur Main Road Bommanahalli, Bangalore 560100 Leveraging MySQL Features for Availability and Scalability Page 4
www.datavail.com 877.634.9222