Fight Scene Storyboard (Action/Adventure Animation)
01 demystifying mysq-lfororacledbaanddeveloperv1
1. Demystifying MySQL for Oracle DBAs
and Developers
https://www.facebook.com/groups/hkmysqlusergroup/
Ivan Ma
ivanxma@yahoo.com
2015-06-26
February 2015
2. Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 2
3. Who am I [ Ivan Ma ]
• MySQL User Group Lead in Hong Kong
• 20+ years of experience in enterprise system infrastructure and software
technologies.
• Certified on MySQL
– MySQL DBA 5.6, MySQL DBA 5.1,
– MySQL Developer 5.1 and MySQL Cluster 5.1 DBA.
• MySQL HK blogging
– http://mysqlhk.blogspot.hk/
https://www.facebook.com/groups/hkmysqlusergroup/
4. Overview
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 4
Mystery of MySQL
•Installation & Configuration
•Performance, Performance, Performance
•MySQL and NoSQL
5. • Linux / Unix (rpm & tar/zip/gz) Securing the Initial MySQL DB
Running the command
- > mysql_secure_installation
• Assign root passwod
• Remove root user from remote
access
• Remove guest account
• Remove test database
February 2015 5
Installation & Configuration
Copyright 2015, oracle and/or its affiliates. All rights reserved
6. MySQL Performance Tips
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 6
It is the balance, trade-off and priority
Resource
Cost
Performance
Complexity
CPU
IO
Performance
Memory
7. Performance Tips 01
• Knowing your system behavior and simulate the workload
• Benchmarking and monitoring
– To measure and define the baseline
– System Performance + DB Performance + App Performance
• What tools are available
– To Measure & monitor
• MySQL Enterprise Monitor
• Performance Schema
– Your testing tools / Your applications (Benchmarking)
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 7
8. MySQL Enterprise Monitor
• A fantastic tool!!!
– Have you seen this… Try it…. Running Live….
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 8
11. Performance Schema – A gold mine with performance data
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 11
12. MySQL Workbench and Performance Schema
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 12
13. MySQL Workbench and Performance Schema
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 13
14. MySQL Workbench and Performance Schema
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 14
15. Performance Tips 02
• Do it RIGHT at the beginning
– There is no definite answer otherwise, the system running out-of-the-box should fit
everything.
– No ONE size fit all scenario
• But at least try to get the best/optimal config as good as possible
– More physical resources (CPU, RAM, FAST DISK, NETWORK)
• Question : What is the Optimal : You do not want to provision more than enough (COST)
• In General TODAY – CPU <Start with small, enough, and RAM is cheap, FAST DISK/SSD– possibly,
network should be okay).
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 15
16. Think ‘Database Performance’ at the beginning!
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 16
17. Performance Tips 03
Operating System –
– Solaris, Linux, Windows,
– ulimit,
– cpu affinity like using taskset command on linux
• taskset –c 1-4 `pidof mysqld`
– Solaris (Containers, project, task…)
File System
– ZFS, UFS
– XFS, EXT4, EXT3
– NFS..
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 17
Warning
It is not a good idea to configure InnoDB to use
data files or log files on NFS volumes. Otherwise,
the files might be locked by other processes and
become unavailable for use by MySQL.
https://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html
18. Performance Tips 04
• 90% people may be using single disk
• What-if having several disks,
– One disk is not good enough
– Separate disk for different uses
• Random IO/SSD/Fast IO
– datadir
– innodb_data_home_dir
– innodb_undo_directory
• Sequential, spinning
– innodb_log_group_home_dir
– log-bin
• tmpdir (Memory, Random, tmpfs, SSD)
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 18
19. Performance Tips 05
• Use Thread Pool (if you have the
Enterprise Edition)
• Stable TPS for high concurrency
• Useful if high concurrency >
hardware threads
• Decreases Context Switching
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 19
20. Performance Tips 06
• Compare the rows examined and rows sent.
• Using Performance Schema to identify the query with the pattern
– SELECT abs(SUM_ROWS_EXAMINED - SUM_ROWS_SENT ), digest_text FROM
performance_schema.events_statements_summary_by_digest order by 1 desc;
– SELECT * FROM performance_schema.events_statements_summary_by_digest
where SUM_ROWS_EXAMINED > 10 * SUM_ROWS_SENT;
– Missing indexes?
– Requiring tuning?
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 20
21. Performance Tips 07
• Innodb IO Capacity
– The default value is 200, reflecting that the performance of typical modern I/O
devices is higher than in the early days of MySQL.
– Higher value depending of the storage – RAID, SSD
• The innodb_flush_sync configuration option, introduced in MySQL 5.7.8,
causes the innodb_io_capacity setting to be ignored during bursts of I/O
activity that occur at checkpoints. innodb_flush_sync is enabled by default.
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 21
http://dev.mysql.com/doc/refman/5.6/en/innodb-performance-thread_io_rate.html
22. Performance Tips 08
• Innodb Read Only Transaction Performance
– Start Transaction READ ONLY or AUTOCOMMIT is ON
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 22
https://dev.mysql.com/doc/refman/5.6/en/innodb-
performance-ro-txn.html
23. Performance Tips 09
• Open & Close Files – table_open_cache & table_open_cache_instance
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 23
http://dimitrik.free.fr/blog/archives/2012/09/mysql-
performance-table-open-cache-in-56.html
24. Configuration
February 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 24
Watch out for your machine - # of
cores to match the concurrency and
thread
25.
26. Still a role for the RDBMS?
NoSQL
Simple access patterns
Compromise on consistency
for performance
Ad-hoc data format
Simple operation
RDBMS
Complex queries with joins
ACID transactions
Well defined schemas
Rich set of tools
• No best single solution fits all
• Mix and match
Scalability
Performance
HA
Ease of use
SQL/Joins
ACID Transactions
27. MySQL 5.6 Memcached with InnoDB
0
10000
20000
30000
40000
50000
60000
70000
80000
8 32 128 512
TPS
Client Connections
MySQL 5.6: NoSQL Benchmarking
Memcached
API
SQL
Clients and Applications
MySQL Server
Memcached Plug-in
innodb_
memcached
local cache
(optional)
Handler API InnoDB API
InnoDB Storage Engine
mysqld process
SQL Memcached Protocol
Up to 9x Higher “SET / INSERT” Throughput
28. NoSQL Access to MySQL Cluster data
ClusterJ
MySQL
JDBC
Apps
JPA
JNI
Python Ruby
ClusterJPA
Apps Apps Apps Apps Apps
Node.js
JS
Apps
mod-ndb
Apache
Apps
ndb-eng
Memcached
Apps Apps
NDB API (C++)
MySQL Cluster Data Nodes
Apps
PHP PERL
Apps
29. • Memcached is a distributed memory based hash-
key/value store with no persistence to disk
• NoSQL, simple API, popular with developers
• MySQL Cluster already provides scalable, in-memory
performance with NoSQL (hashed) access as well as
persistence
• Provide the Memcached API but map to NDB API
calls
• Writes-in-place, so no need to invalidate cache
• Simplifies architecture as caching & database integrated
into 1 tier
• Access data from existing relational tables
MySQL Cluster : Memcached
30. NoSQL with Memcached
• Flexible:
– Deployment options
– Multiple Clusters
– Simultaneous SQL Access
– Can still cache in Memcached server
– Flat key-value store or map to multiple tables/columns
set maidenhead 0 0 3
SL6
STORED
get maidenhead
VALUE maidenhead 0 3
SL6
END
31. • Domain Object Model Persistence API (ClusterJ):
• Java API
• High performance, low latency
• Feature rich
• JPA interface built upon this new Java layer:
• Java Persistence API compliant
• Implemented as an OpenJPA plugin
• Uses ClusterJ where possible, reverts to JDBC for some
operations
• Higher performance than JDBC
• More natural for most Java designers
• Easier Cluster adoption for web applications
MySQL Cluster : ClusterJ/JPA
32. Join Hong Kong MySQL
User Group
Summary
Resource
http://www.mysql.com/why-mysql/
Download
http://www.mysql.com/downloads/
Lab Release
http://labs.mysql.com/
Forum
http://forums.mysql.com/
https://www.facebook.com/groups/hkmysqlusergroup/
33. Demystifying MySQL for Oracle DBAs
and Developers
https://www.facebook.com/groups/hkmysqlusergroup/
Ivan Ma
ivanxma@yahoo.com
2015-06-26
February 2015