SlideShare a Scribd company logo
1 of 58
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning 101
Ricky Setyawan
Principal Sales Consultant – MySQL
ASEAN
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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.
2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Agenda
3
Oracle Premier Support for MySQL
MySQL Performance Tuning Best Practices
Top 6 Tips
Summary
Q & A
1
2
3
4
5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 4
Linkedin : goo.gl/vjwN9H
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Oracle Premier Support untuk
MySQL
Kami selalu mendukung anda
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Support
• Diberikan oleh expert, langsung dari sumbernya
• Didukung oleh para developer MySQL
• Support kelas dunia, dalam 27 bahasa
• Hot fixes & release maintenance
• 24x7x365
• Tak ada batas insiden
• Support konsultatif
• Skala dunia
Dapatkan pertolongan segera utk
masalah MySQL, plus advis dari
ahlinya
6
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Support konsultatif
• Remote Troubleshooting menggunakan Webex
• Replication review
• Partitioning review
• Schema review
• Query review
• Performance tuning di OS platform yg berbeda2
• ...and more
7
Maksimalkan production deployment anda
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Best practice dalam MySQL Performance
Tuning
8
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning Best Practices
• Berhati2lah akan “best practices”
– Tidak ada dua system yg sama
– Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak
• HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu
– Test, Benchmark, Monitor
– Gunakan sysbench, mysqlslap, tool2 monitoring
9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning Best Practices
• Berhati2lah akan “best practices”
– Tidak ada dua system yg sama
– Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak
• HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu
– Test, Benchmark, Monitor
– Gunakan sysbench, mysqlslap, tool2 monitoring
10
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning Best Practices
• Berhati2lah akan “best practices”
– Tidak ada dua system yg sama
– Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak
• HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu
– Test, Benchmark, Monitor
– Gunakan sysbench, mysqlslap, tool2 monitoring
• Pikirkan – apa yg anda lakukan dan mengapa?
11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning Best Practices
• Berhati2lah akan “best practices”
– Tidak ada dua system yg sama
– Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak
• HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu
– Test, Benchmark, Monitor
– Gunakan sysbench, mysqlslap, tool2 monitoring
• Pikirkan – apa yg anda lakukan dan mengapa?
• Guideline ada, tapi bukan konfigurasi terbaik
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Performance Tuning Best Practices
• Perhatikan kebutuhan anda
– Beberapa opsi memberikan pilihan antara performa & keamanan data – Apa yg anda
butuhkan?
• Terkadang default value adalah value terbaik
• Pastikan semua table memiliki PRIMARY KEY
• InnoDB mengatur data menurut PRIMARY KEY :
– PRIMARY KEY termasuk di semua secondary index agar dapat mencari row yg
diinginkan => semakin kecil PRIMARY KEY memberikan secondary index yg makin kecil
– PRIMARY KEY yg kebanyakan berurutan secara general direkomendasikan utk
menghindari memasukkan row baru diantara row existing
13
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Top 6 Tips
Tuning performa MySQL
14
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
01. Pikir
• Berpikir adalah pertahanan terbaik anda
• Analisa problem performa anda :
– Pastikan anda mengerti apa masalah sebenarnya :
• Bukan seperti ini : performa sangat lambat
• Tapi seperti ini :
– Query tersebut butuh 10 detik, tapi dipakai utk penggunaan interaktif maka harus selesai dalam 0.1 detik
atau kurang
– Server harus handle 200k query per detik
– Putuskan penyebabnya
• Jangan segera melompat ke kesimpulan
• Pertimbangkan seluruh stack
• Justifikasi mengapa anda piker anda telah menemukan penyebabnya
15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
01. Pikir
• Menerapkan solusinya
– Buat daftar semua solusi yg anda dapat pikirkan
• Pastikan anda berpikir “outside the box” – tidak hanya apa yg anda asumsikan
– Jelaskan mengapa solusi2 tersebut akan bekerja
– Implementasikan action plan :
• Uji action plan dan rubah bila perlu
• Pastikan anda implementasikan solusi yg sama di test & production
• Bila regresi terjadi, anda memiliki
• Jika regresi terjadi, Anda memiliki catatan langkah-langkah yang dilakukan
16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
• Berikan anda sebuah base line
• Memberi tahu anda apa yg telah terjadi – berguna utk penyelidikan
masalah performa
• Memungkinkan Anda untuk secara proaktif menangani masalah potensial
17
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
• Banyak opsi tersedia :
– MySQL Enterprise Monitor
– MySQL Workbench
– Slow Query Log
– MySQL Plugin utk Oracle Enterprise Manager
– And many more
• Pastikan anda konfigurasikan alert hingga anda
• Make sure you configure alerts so bereaksi terhadap semua kejadian
berdasarkan tingkat severity!
18
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
• Di Linux, perf adalah tool yg bagus utk melakukan live monitoring dan
dapat merekam utk jangka waktu tertentu
– https://perf.wiki.kernel.org/index.php/Main_Page
– http://www.brendangregg.com/perf.html
• MySQL Enterprise Monitor memiliki beberapa report utk mendapatkan
snapshot data
• Workbench memiliki report performa dari sys schema
“Real time” monitoring
19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
MySQL Workbench Report performa
20
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
• Sys schema adalah koleksi view, function, procedure yg digunakan agar
information schema & performance schema lebih mudah dipakai
• Termasuk secara default di MySQL 5.7+
• Juga tersedia dari https://github.com/mysql/mysql-sys utk MySQL 5.6
• Dulu dikenal sebagai ps_helper oleh Mark Leith
• https://dev.mysql.com/doc/refman/5.7/en/sys-schema.html
Apakah sys schema?
21
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
Temukan query utk dioptimasi - MySQL Enterprise Monitor Query Analyzer
22
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
02. Monitoring
Temukan query utk dioptimasi – Performance Schema Digest Summary
mysql> SELECT LEFT(DIGEST_TEXT, 64) AS DIGEST_TEXT, COUNT_STAR, SUM_TIMER_WAIT, MAX_TIMER_WAIT
FROM performance_schema.events_statements_summary_by_digest
ORDER BY MAX_TIMER_WAIT DESC
LIMIT 10;
+------------------------------------------------------------------+------------+-----------------+----------------+
| DIGEST_TEXT | COUNT_STAR | SUM_TIMER_WAIT | MAX_TIMER_WAIT |
+------------------------------------------------------------------+------------+-----------------+----------------+
| INSERT INTO `salaries` VALUES (...) /* , ... */ | 342 | 159811231808000 | 4156961573000 |
| INSERT INTO `dept_emp` VALUES (...) /* , ... */ | 42 | 31561264335000 | 2458392698000 |
| INSERT INTO `titles` VALUES (...) /* , ... */ | 63 | 35738435708000 | 1735350241000 |
| INSERT INTO `employees` VALUES (...) /* , ... */ | 51 | 18004605187000 | 1679817477000 |
| INSERT INTO `sbtest` ( `k` , `c` , `pad` ) VALUES (...) /* , ... | 10 | 5241286782000 | 1247361451000 |
| COMMIT | 342 | 31984662051000 | 992714081000 |
| DROP SCHEMA IF EXISTS `employees` | 6 | 1252459420000 | 848771265000 |
| CREATE TABLE `sbtest` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCR | 1 | 565468324000 | 565468324000 |
| CREATE TABLE `dept_manager` ( `dept_no` CHARACTER (?) NOT NULL , | 3 | 355874700000 | 220491035000 |
| SELECT COUNT (?) AS `cnt` , `round` ( ( `performance_schema` . ` | 6 | 386062170000 | 217206520000 |
+------------------------------------------------------------------+------------+-----------------+----------------+
10 rows in set (0.00 sec)
23
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
1. Mulai dengan config file kosong
2. Set paths, port, dll.
3. Nyalakan monitoring tambahan
4. Set setting kapasitas
5. Jangan lakukan lebih dari ini!
24
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Bisa menjadi kelebihan memiliki path yg mengarah ke disk system terpisah
– Kurangi contention
– I/O seringkali menjadi bottleneck
– Dapat meletakkan “hot file” di disk yg lbh cepat
• Misalnya dengan innodb_flush_log_at_trx_commit = 1 dan transaction commit rate yg tinggi,
mungkin perlu utk meletakkan InnoDB redo log di SSD utk mendukung flush rate yg tinggi
• Note: File-per-table tablespace and general tablespace dapat diletakkan
diluar datadir sewaktu mereka dibuat
Path
25
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Bila anda gunakan InnoDB, aktifkan semua INNODB_METRICS counter :
– innodb_monitor_enable = ‘%’
• Extra detail yg diberikan sangat berguna & overhead sangat kecil
• Pastikan performance schema sudah diaktivasi
– Ada overhead tapi menyediakan informasi yg sgt berguna utk tuning performa
– Pertimbangkan utk nyalakan tambahan consumers & instruments seperlunya
(misalnya utk transactions di MySQL 5.7)
– Performance schema dpt dikonfigurasi secara dinamis sewaktu runtime
Nyalakan monitoring tambahan
26
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• MySQL Reference Manual (about innodb_buffer_pool_size):
“On a dedicated database server, you might set the buffer pool size to 80%
of the machine's physical memory size.”
– Bagaimana bila anda memiliki 1TB memory? Apakah anda masih akan menyimpan
20% sisanya utk keperluan lain?
• Semestinya :
– Berapa banyak memory host miliki?
– Kurangi memory yg diperlukan oleh OS & proses lain2
– Kurangi memory yg diperlukan oleh MySQL selain InnoDB Buffer pool
– Pilih minimum dari ini dan ukuran dari “working data set”
Setting kapasitas - innodb_buffer_pool_size
27
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Total redo log size ditentukan dgn two opsi :
– innodb_log_file_size
– innodb_log_files_in_group
• Total size = innodb_log_file_size * innodb_log_files_in_group
– Max total redo log size yg disupport :
• MySQL 5.5 dan sebelumnya : just below 4G
• MySQL 5.6 dan setelahnya: just below 512G
• Harus cukup besar utk hindari checkpointing yg berlebihan
• Semakin besar redo log, semakin lambat proses shutdown berjalan
Setting kapasitas – InnoDB redo log
28
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Ambil current Log sequence number (LSN) dan checkpoint terakhir :
– SHOW ENGINE INNODB STATUS:
– INNODB_METRICS:
Setting kapasitas – InnoDB redo log – Apakah cukup besar?
---
LOG
---
Log sequence number 602763740
Log flushed up to 602763740
Pages flushed up to 584668961
Last checkpoint at 555157885
mysql> SELECT NAME, COUNT
FROM information_schema.INNODB_METRICS
WHERE NAME IN ('log_lsn_current', 'log_lsn_last_checkpoint');
+-------------------------+-----------+
| NAME | COUNT |
+-------------------------+-----------+
| log_lsn_last_checkpoint | 555157885 |
| log_lsn_current | 602763740 |
+-------------------------+-----------+
29
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Hitung besar redo log terpakai :
– Used log = log_lsn_current – log_lsn_last_checkpoint
= 602763740 - 555157885
= 47605855 (bytes)
• Bandingkan dgn total size :
– Used % = (Used log / Total log) * 100
= (47605855 / (innodb_log_file_size * innodb_log_files_in_group)) * 100
= (47605855 / 100663296) * 100
= 47.29 %
Setting kapasitas – InnoDB redo log – Apakah cukup besar?
30
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Bila pemakaian mencapai 75% asynchronous flush terjadi
– I/O dpt menjadi sangat intensif yg membuat proses lain dari MySQL terhenti
– InnoDB thread utama mungkin berstatus : flushing buffer pool pages
• Pastikan anda memiliki buffer cukup utk menangani peak load
– Misalnya targetkan utk gunakan max 60% atau 70% dari redo log
• Penting utk memonitor redo log usage
• Perbaikan flushing algorithm dan opsi baru utk mengkontrol I/O telah
ditambahkan di versi MySQL terbaru
Setting kapasitas – InnoDB redo log – Apakah cukup besar?
31
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• Innodb_undo_tablespaces hanya dpt di-set sblm initializing datadir!
• Bila di-set maka undo log tablespace akan dibuat diluar system tablespace
(ibdata1)
• Kelebihan :
– Membuat system tablespace lebih kecil
– Dpt di-set agar undo log diletakkan di disk yg lbh cepat spt SSD
– Di MySQL 5.7 undo log tablespace dapat di-truncate
• Tiap undo tablespace adalah 10M awalnya
• Maximum 95 undo tablespace di 5.7
InnoDB Undo Log
32
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
03. Initial Configuration File
• max_connections – berhati2 set ini terlalu besar karena tiap koneksi butuh
memory
• table_definition_cache – pastikan semua table dapat disimpan di cache.
Bila memiliki 4000 tables, maka set table_definition_cache > 4000
• table_open_cache – tiap table dapat dibuka lebih dari sekali
• table_open_cache_instances – Biasanya di-set di 16
Opsi kapasitas lain
33
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Apakah menyalakan cache adalah selalu pilihan terbaik?
• Apakah cache & buffer lebih besar lebih baik?
Beberapa buffer & cache yg tersedia
34
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Apakah menyalakan cache adalah selalu pilihan terbaik?
• Apakah cache & buffer lebih besar lebih baik?
• No!
Beberapa buffer & cache yg tersedia
35
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Biasanya menyalakan query cache jarang berguna
– Dioperasikan oleh single mutex
• Kebanyakan workload lbh baik gunakan query cache disabled (default) :
– query_cache_type = 0
• Bila anda berpikir bahwa workload anda butuh query cache, test dahulu
– Makin banyak write, semakin sedikit gunanya
– Makin banyak data tersimpan di buffer pool, semakin sedikit gunanya
– Makin complex query dan makin besar scan, semakin banyak gunanya
• Biasanya solusi caching lainnya adalah opsi yg lbh baik
Query Cache
36
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Di MySQL 5.5 dan sebelumnya : hanya digunakan utk index scan biasa,
range index scan, dan join2 yg tak gunakan index
– Tidak ada alasan utk memiliki lbh besar dari size masing2 row yg match
• Di MySQL 5.6+ juga digunakan utk Batched Key Access (BKA)
– Query yg gunakan BKA dapat diuntungkan dari join buffer yg lbh besar
• Size minimum telaah dialokasi!
• Biasanya global value yg kecil yg terbaik : 32k-256k
• Besarkan dalam session bila diperlukan
join_buffer_size
37
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Seperti join_buffer_size, global value yg kecil bisanya terbaik : 32k-256k
• Dapat dimonitor menggunakan global status variable Sort_merge_passes:
• Targetkan utk beberapa Sort_merge_passes per detik di server yg sibuk
• Besarkan di level session bila perlu
sort_buffer_size
mysql> SHOW GLOBAL STATUS LIKE 'Sort_merge_passes';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Sort_merge_passes | 0 |
+-------------------+-------+
1 row in set (0.00 sec)
38
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
04. Buffers And Caches
• Beberapa buffer dialokasi secara full tiap kali mereka dipakai
• Satu query dpt gunakan bbrp buffer, maka buffer2 besar dpt akibatkan
pemakaian memory yg jauh lbh besar
• Alokasi memory relative mahal
• Misalnya Linux glibc malloc merubah algoritma alokasi memory ketika
batas telah terlewati (biasanya 256k or 512k)
– Algoritma utk alokasi yg lbh besar dpt 40 kali lbh lembat daripada alokasi kecil
Mengapa penting dgn global value yg kecil?
39
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
05. Data Consistency Versus Performance
• Value yg dpt di-set sesuai urutan mulai dari data safety plg baik
– 1: secara teori adalah yg plg lambat, namun dgn SSD cepat dapat secepat opsi 2 dan 0
– 2: di-flush tiap detik (innodb_flush_log_at_timeout in 5.6+)
• Transaksi dpt hilang bila OS crash
– 0: MySQL tidak pernah fsync
• Transaksi dpt hilang bila OS crash
• Defaults adalah 1 – flush redo log setelah tiap commit
– Dibutuhkan utk memenuhi D dalam ACID
– Karena alasan ini lah, 1 adalah value recommended
innodb_flush_log_at_trx_commit
40
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
05. Data Consistency Versus Performance
• Bagaimana bila innodb_flush_log_at_trx_commit = 1 terlalu lamban dan
anda ingin D dalam ACID?
– Pastikan redo log group dalam disk yg terpisah dgn data
• Jangan tergoda utk meletakkan masing2 redo log di disk terpisah
– Pertimbangkan SSD terutama bila anda memiliki commit rate yg tinggi
– Disk cache battery-backed juga memberikan flush yg murah karena IO cepat
innodb_flush_log_at_trx_commit
41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
05. Data Consistency Versus Performance
• Spesifikasikan berapa banyak transaksi antara tiap flush binary log
– 0: ketika rotating binary log atau ketika OS inisiasi
– 1: tiap transaction commit – Ini yg paling safe
– N: tiap N commit
• Default value:
– MySQL 5.6 dan sebelumnya : 0
– MySQL 5.7 dan setelahnya : 1
• MySQL 5.6 dan setelahnya mendukung group commit utk InnoDB yg
mengurangi overhead dari sync_binlog=1
sync_binlog
42
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
05. Data Consistency Versus Performance
• Sync_binlog != 1 berarti slave kemungkinan besar akan harus di-rebuild bila
master crash
• Namun sync_binlog = 0 pastilah memberi performa terbaik, benar?
sync_binlog
43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
05. Data Consistency Versus Performance
• Sync_binlog != 1 berarti slave kemungkinan besar akan harus di-rebuild bila
master crash
• Namun sync_binlog = 0 pastilah memberi performa terbaik, benar?
– By default: max_binlog_size = 1G
– 1G tidak dianggap kebutuhan besar utk memory saat ini
– Maka OS dapat mem-buffer seluruh binary log
– Ketika rotating binary log, diatas 1G akan di-flush ke disk
• Menghentikan semua commit2 lain sampai binary log rotation selesai
• Maka pendeknya : sync_binlog=0 akan berikan throughput terbaik, tapi
sync_binlog =1 akan berikan performa yg paling dpt diprediksi
sync_binlog
44
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Masalah dpt terjadi di setiap level dalam stack, misalnya :
– Application
– Application host/hardware
– Network antara application dan host dgn MySQL
– MySQL host/hardware
– MySQL
• Ini harus juga dipertimbangkan sewaktu monitoring
• Pertimbangkan setting OS/hardware
45
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Pastikan anda memiliki cukup RAM
– Semua data aktif harus tersimpan di buffer pool
– Koneksi & cache MySQL membutuhkan memory
– Extra RAM utk
• FS cache
• Monitoring
• RAM disk (tmpfs)
Pertimbangan hardware
46
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• CPU cepat sangat diperlukan utk performa single thread
• Server2 baru memiliki 32 – 80 core
• Nyalakan hyper-threading
• MySQL skrg dpt scale lbh dari 72 core di 5.7
• Jumlah core yg sama di socket yg lbh sedikit lebih baik
• Core yg lbh cepat lbh baik dari core yg lambat & banyak
Pertimbangan hardware
47
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Storage yg cepat & handal bagus utk load yg berat di IO
• HDD utk sequential reads & writes
• SSD attach ke bus utk random reads & writes
• SATA atau disk lain utk log file
• Beberapa disk!
• Umur disk juga harus dipertimbangkan
Pertimbangan hardware - Storage
48
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Linux (L of LAMP)
• Solaris juga bagus
• Oracle juga invest di Windows
• Utk performa murni, gunakan Linux
Operating System
49
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• I/O Scheduler
– Beberapa Linux distro menggunakan CFQ scheduler by default
• OK utk reads
• Serial writes!
– NOOP & deadline biasanya lbh baik utk workload MySQL
• Deadline adalah default I/O scheduler utk Oracle Linux Unbreakable
Setting I/O di the operating system
50
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• I/O Scheduler
– Cek scheduler saat ini :
– Update scheduler secara dinamis :
– Utk set waktu boot time, gunakan “elevator=deadline” boot option
Setting I/O di the operating system
shell# cat /sys/block/sda/queue/scheduler
noop deadline [cfq]
shell# echo deadline > /sys/block/sda/queue/scheduler
shell# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
51
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Linux glibc malloc dpt menjadi performa bottleneck
• Lbh baik gunakan malloc library alternative :
– tcmalloc
– jemalloc
Memory allocation library
52
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
06. Consider the Whole Stack
• Set alternative malloc library:
– mysqld_safe
– systemd distributions:
• Set LD_PRELOAD in /etc/sysconfig/mysql
Memory allocation library
[mysqld_safe]
malloc-lib = /usr/lib64/libjemalloc.so.1
53
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Summary
Wrapping it all up
54
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Ringkasan
• Tuning performa MySQL mirip dgn tuning performa database lain :
– Optimisasi premature tidak baik
– Hanya rubah satu hal tiap waktu & jgn lakukan perubahan terlalu besar
– Jangan micro manage
– Satu size tidak cocok utk semua
– Buat keputusan berdasarkan pengukuran
– Mengerti apa maksudnya sebuah opsi sebelum implementasi opsi tersebut
– Mengerti system anda (data)
– Mengerti apa yg anda butuhkan
– Pertimbangkan seluruh stack
55
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Thank You
Q&A
56
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 57
MySQL Performance Tuning 101 (Bahasa)

More Related Content

What's hot

MySQL Enterprise Edition Overview
MySQL Enterprise Edition OverviewMySQL Enterprise Edition Overview
MySQL Enterprise Edition OverviewMario Beck
 
MySQL London Tech Tour March 2015 - Embedded Database of Choice
MySQL London Tech Tour March 2015 - Embedded Database of ChoiceMySQL London Tech Tour March 2015 - Embedded Database of Choice
MySQL London Tech Tour March 2015 - Embedded Database of ChoiceMark Swarbrick
 
MySQL Cloud Service
MySQL Cloud ServiceMySQL Cloud Service
MySQL Cloud ServiceMario Beck
 
MySQL Intro JSON NoSQL
MySQL Intro JSON NoSQLMySQL Intro JSON NoSQL
MySQL Intro JSON NoSQLMark Swarbrick
 
MySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt IntroMySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt IntroMark Swarbrick
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise MonitorTed Wennmark
 
MySQL Manchester TT - Security
MySQL Manchester TT  - SecurityMySQL Manchester TT  - Security
MySQL Manchester TT - SecurityMark Swarbrick
 
MySQL 5.6, news in 5.7 and our HA options
MySQL 5.6, news in 5.7 and our HA optionsMySQL 5.6, news in 5.7 and our HA options
MySQL 5.6, news in 5.7 and our HA optionsTed Wennmark
 
MySQL @ the University Of Nottingham
MySQL @ the University Of NottinghamMySQL @ the University Of Nottingham
MySQL @ the University Of NottinghamMark Swarbrick
 
MySQL Document Store
MySQL Document StoreMySQL Document Store
MySQL Document StoreMario Beck
 
Netherlands Tech Tour - 06 MySQL Enterprise Monitor
Netherlands Tech Tour - 06 MySQL Enterprise MonitorNetherlands Tech Tour - 06 MySQL Enterprise Monitor
Netherlands Tech Tour - 06 MySQL Enterprise MonitorMark Swarbrick
 
MySQL 5.7 Replication News
MySQL 5.7 Replication News MySQL 5.7 Replication News
MySQL 5.7 Replication News Ted Wennmark
 
MySQL Community and Commercial Edition
MySQL Community and Commercial EditionMySQL Community and Commercial Edition
MySQL Community and Commercial EditionMario Beck
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsMario Beck
 
MySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 SecurityMySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 SecurityMark Swarbrick
 
MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15MySQL Brasil
 
MySQL Manchester TT - Replication Features
MySQL Manchester TT  - Replication FeaturesMySQL Manchester TT  - Replication Features
MySQL Manchester TT - Replication FeaturesMark Swarbrick
 
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorEfficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorMark Matthews
 
MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016Ted Wennmark
 
MySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMorgan Tocker
 

What's hot (20)

MySQL Enterprise Edition Overview
MySQL Enterprise Edition OverviewMySQL Enterprise Edition Overview
MySQL Enterprise Edition Overview
 
MySQL London Tech Tour March 2015 - Embedded Database of Choice
MySQL London Tech Tour March 2015 - Embedded Database of ChoiceMySQL London Tech Tour March 2015 - Embedded Database of Choice
MySQL London Tech Tour March 2015 - Embedded Database of Choice
 
MySQL Cloud Service
MySQL Cloud ServiceMySQL Cloud Service
MySQL Cloud Service
 
MySQL Intro JSON NoSQL
MySQL Intro JSON NoSQLMySQL Intro JSON NoSQL
MySQL Intro JSON NoSQL
 
MySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt IntroMySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt Intro
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise Monitor
 
MySQL Manchester TT - Security
MySQL Manchester TT  - SecurityMySQL Manchester TT  - Security
MySQL Manchester TT - Security
 
MySQL 5.6, news in 5.7 and our HA options
MySQL 5.6, news in 5.7 and our HA optionsMySQL 5.6, news in 5.7 and our HA options
MySQL 5.6, news in 5.7 and our HA options
 
MySQL @ the University Of Nottingham
MySQL @ the University Of NottinghamMySQL @ the University Of Nottingham
MySQL @ the University Of Nottingham
 
MySQL Document Store
MySQL Document StoreMySQL Document Store
MySQL Document Store
 
Netherlands Tech Tour - 06 MySQL Enterprise Monitor
Netherlands Tech Tour - 06 MySQL Enterprise MonitorNetherlands Tech Tour - 06 MySQL Enterprise Monitor
Netherlands Tech Tour - 06 MySQL Enterprise Monitor
 
MySQL 5.7 Replication News
MySQL 5.7 Replication News MySQL 5.7 Replication News
MySQL 5.7 Replication News
 
MySQL Community and Commercial Edition
MySQL Community and Commercial EditionMySQL Community and Commercial Edition
MySQL Community and Commercial Edition
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
MySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 SecurityMySQL Tech Tour 2015 - 5.7 Security
MySQL Tech Tour 2015 - 5.7 Security
 
MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15MySQL The State of the Dolphin - jun15
MySQL The State of the Dolphin - jun15
 
MySQL Manchester TT - Replication Features
MySQL Manchester TT  - Replication FeaturesMySQL Manchester TT  - Replication Features
MySQL Manchester TT - Replication Features
 
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise MonitorEfficient Performance Analysis and Tuning with MySQL Enterprise Monitor
Efficient Performance Analysis and Tuning with MySQL Enterprise Monitor
 
MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016MySQL Enterprise Backup apr 2016
MySQL Enterprise Backup apr 2016
 
MySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMySQL Cloud Service Deep Dive
MySQL Cloud Service Deep Dive
 

Similar to MySQL Performance Tuning 101 (Bahasa)

MySQL enterprise edition
MySQL enterprise edition MySQL enterprise edition
MySQL enterprise edition Mark Swarbrick
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise MonitorMario Beck
 
20190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev220190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev2Ivan Ma
 
MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)Keith Hollman
 
MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015Mario Beck
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1Ivan Ma
 
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...Mark Swarbrick
 
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015 2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015 Geir Høydalsvik
 
MySQL Enterprise Portfolio
MySQL Enterprise PortfolioMySQL Enterprise Portfolio
MySQL Enterprise PortfolioAbel Flórez
 
MySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMark Swarbrick
 
Upgrading to my sql 8.0
Upgrading to my sql 8.0Upgrading to my sql 8.0
Upgrading to my sql 8.0Ståle Deraas
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...GeneXus
 
Modern Data Security with MySQL
Modern Data Security with MySQLModern Data Security with MySQL
Modern Data Security with MySQLVittorio Cioe
 
BGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQLBGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQLGeorgi Kodinov
 
MySQL Performance Best Practices
MySQL Performance Best PracticesMySQL Performance Best Practices
MySQL Performance Best PracticesOlivier DASINI
 
Data dictionary pl17
Data dictionary pl17Data dictionary pl17
Data dictionary pl17Ståle Deraas
 
MySQL Day Paris 2018 - Introduction & The State of the Dolphin
MySQL Day Paris 2018 - Introduction & The State of the DolphinMySQL Day Paris 2018 - Introduction & The State of the Dolphin
MySQL Day Paris 2018 - Introduction & The State of the DolphinOlivier DASINI
 
MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?Olivier DASINI
 

Similar to MySQL Performance Tuning 101 (Bahasa) (20)

MySQL enterprise edition
MySQL enterprise edition MySQL enterprise edition
MySQL enterprise edition
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise Monitor
 
20190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev220190615 hkos-mysql-troubleshootingandperformancev2
20190615 hkos-mysql-troubleshootingandperformancev2
 
MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)
 
MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1
 
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...
MySQL Webinar Series 3/4 - MySQl Monitoring With Enterprise Monitor + Query A...
 
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015 2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015
2015: Whats New in MySQL 5.7, At Oracle Open World, November 3rd, 2015
 
MySQL Enterprise Portfolio
MySQL Enterprise PortfolioMySQL Enterprise Portfolio
MySQL Enterprise Portfolio
 
MySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & Tune
 
Upgrading to my sql 8.0
Upgrading to my sql 8.0Upgrading to my sql 8.0
Upgrading to my sql 8.0
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
 
Modern Data Security with MySQL
Modern Data Security with MySQLModern Data Security with MySQL
Modern Data Security with MySQL
 
SQL TUNING 101
SQL TUNING 101SQL TUNING 101
SQL TUNING 101
 
BGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQLBGOUG 2014: Developing Using MySQL
BGOUG 2014: Developing Using MySQL
 
MySQL Performance Best Practices
MySQL Performance Best PracticesMySQL Performance Best Practices
MySQL Performance Best Practices
 
Data dictionary pl17
Data dictionary pl17Data dictionary pl17
Data dictionary pl17
 
Rootconf admin101
Rootconf admin101Rootconf admin101
Rootconf admin101
 
MySQL Day Paris 2018 - Introduction & The State of the Dolphin
MySQL Day Paris 2018 - Introduction & The State of the DolphinMySQL Day Paris 2018 - Introduction & The State of the Dolphin
MySQL Day Paris 2018 - Introduction & The State of the Dolphin
 
MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?
 

More from OracleMySQL

MySQL Performance Tuning (In Korean)
MySQL Performance Tuning (In Korean)MySQL Performance Tuning (In Korean)
MySQL Performance Tuning (In Korean)OracleMySQL
 
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorSolving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorOracleMySQL
 
MySQL partitioning
MySQL partitioning MySQL partitioning
MySQL partitioning OracleMySQL
 
What's New MySQL 8.0?
What's New MySQL 8.0?What's New MySQL 8.0?
What's New MySQL 8.0?OracleMySQL
 
MySQL 8.0 in a nutshell
MySQL 8.0 in a nutshellMySQL 8.0 in a nutshell
MySQL 8.0 in a nutshellOracleMySQL
 
Infographic oracle-my sql-cloud
Infographic oracle-my sql-cloudInfographic oracle-my sql-cloud
Infographic oracle-my sql-cloudOracleMySQL
 
MySQL in oracle_public_cloud
MySQL in oracle_public_cloudMySQL in oracle_public_cloud
MySQL in oracle_public_cloudOracleMySQL
 

More from OracleMySQL (7)

MySQL Performance Tuning (In Korean)
MySQL Performance Tuning (In Korean)MySQL Performance Tuning (In Korean)
MySQL Performance Tuning (In Korean)
 
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorSolving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise Monitor
 
MySQL partitioning
MySQL partitioning MySQL partitioning
MySQL partitioning
 
What's New MySQL 8.0?
What's New MySQL 8.0?What's New MySQL 8.0?
What's New MySQL 8.0?
 
MySQL 8.0 in a nutshell
MySQL 8.0 in a nutshellMySQL 8.0 in a nutshell
MySQL 8.0 in a nutshell
 
Infographic oracle-my sql-cloud
Infographic oracle-my sql-cloudInfographic oracle-my sql-cloud
Infographic oracle-my sql-cloud
 
MySQL in oracle_public_cloud
MySQL in oracle_public_cloudMySQL in oracle_public_cloud
MySQL in oracle_public_cloud
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

MySQL Performance Tuning 101 (Bahasa)

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning 101 Ricky Setyawan Principal Sales Consultant – MySQL ASEAN
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 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. 2
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Agenda 3 Oracle Premier Support for MySQL MySQL Performance Tuning Best Practices Top 6 Tips Summary Q & A 1 2 3 4 5
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 4 Linkedin : goo.gl/vjwN9H
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Oracle Premier Support untuk MySQL Kami selalu mendukung anda
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Enterprise Support • Diberikan oleh expert, langsung dari sumbernya • Didukung oleh para developer MySQL • Support kelas dunia, dalam 27 bahasa • Hot fixes & release maintenance • 24x7x365 • Tak ada batas insiden • Support konsultatif • Skala dunia Dapatkan pertolongan segera utk masalah MySQL, plus advis dari ahlinya 6
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Support konsultatif • Remote Troubleshooting menggunakan Webex • Replication review • Partitioning review • Schema review • Query review • Performance tuning di OS platform yg berbeda2 • ...and more 7 Maksimalkan production deployment anda
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Best practice dalam MySQL Performance Tuning 8
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning Best Practices • Berhati2lah akan “best practices” – Tidak ada dua system yg sama – Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak • HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu – Test, Benchmark, Monitor – Gunakan sysbench, mysqlslap, tool2 monitoring 9
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning Best Practices • Berhati2lah akan “best practices” – Tidak ada dua system yg sama – Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak • HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu – Test, Benchmark, Monitor – Gunakan sysbench, mysqlslap, tool2 monitoring 10
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning Best Practices • Berhati2lah akan “best practices” – Tidak ada dua system yg sama – Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak • HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu – Test, Benchmark, Monitor – Gunakan sysbench, mysqlslap, tool2 monitoring • Pikirkan – apa yg anda lakukan dan mengapa? 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning Best Practices • Berhati2lah akan “best practices” – Tidak ada dua system yg sama – Yang dulu pernah bekerja dgn baik, sekarang mungkin tidak • HW and SW vendors semuanya berbohong! Sebenarnya tidak begitu – Test, Benchmark, Monitor – Gunakan sysbench, mysqlslap, tool2 monitoring • Pikirkan – apa yg anda lakukan dan mengapa? • Guideline ada, tapi bukan konfigurasi terbaik 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Performance Tuning Best Practices • Perhatikan kebutuhan anda – Beberapa opsi memberikan pilihan antara performa & keamanan data – Apa yg anda butuhkan? • Terkadang default value adalah value terbaik • Pastikan semua table memiliki PRIMARY KEY • InnoDB mengatur data menurut PRIMARY KEY : – PRIMARY KEY termasuk di semua secondary index agar dapat mencari row yg diinginkan => semakin kecil PRIMARY KEY memberikan secondary index yg makin kecil – PRIMARY KEY yg kebanyakan berurutan secara general direkomendasikan utk menghindari memasukkan row baru diantara row existing 13
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Top 6 Tips Tuning performa MySQL 14
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 01. Pikir • Berpikir adalah pertahanan terbaik anda • Analisa problem performa anda : – Pastikan anda mengerti apa masalah sebenarnya : • Bukan seperti ini : performa sangat lambat • Tapi seperti ini : – Query tersebut butuh 10 detik, tapi dipakai utk penggunaan interaktif maka harus selesai dalam 0.1 detik atau kurang – Server harus handle 200k query per detik – Putuskan penyebabnya • Jangan segera melompat ke kesimpulan • Pertimbangkan seluruh stack • Justifikasi mengapa anda piker anda telah menemukan penyebabnya 15
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 01. Pikir • Menerapkan solusinya – Buat daftar semua solusi yg anda dapat pikirkan • Pastikan anda berpikir “outside the box” – tidak hanya apa yg anda asumsikan – Jelaskan mengapa solusi2 tersebut akan bekerja – Implementasikan action plan : • Uji action plan dan rubah bila perlu • Pastikan anda implementasikan solusi yg sama di test & production • Bila regresi terjadi, anda memiliki • Jika regresi terjadi, Anda memiliki catatan langkah-langkah yang dilakukan 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring • Berikan anda sebuah base line • Memberi tahu anda apa yg telah terjadi – berguna utk penyelidikan masalah performa • Memungkinkan Anda untuk secara proaktif menangani masalah potensial 17
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring • Banyak opsi tersedia : – MySQL Enterprise Monitor – MySQL Workbench – Slow Query Log – MySQL Plugin utk Oracle Enterprise Manager – And many more • Pastikan anda konfigurasikan alert hingga anda • Make sure you configure alerts so bereaksi terhadap semua kejadian berdasarkan tingkat severity! 18
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring • Di Linux, perf adalah tool yg bagus utk melakukan live monitoring dan dapat merekam utk jangka waktu tertentu – https://perf.wiki.kernel.org/index.php/Main_Page – http://www.brendangregg.com/perf.html • MySQL Enterprise Monitor memiliki beberapa report utk mendapatkan snapshot data • Workbench memiliki report performa dari sys schema “Real time” monitoring 19
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring MySQL Workbench Report performa 20
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring • Sys schema adalah koleksi view, function, procedure yg digunakan agar information schema & performance schema lebih mudah dipakai • Termasuk secara default di MySQL 5.7+ • Juga tersedia dari https://github.com/mysql/mysql-sys utk MySQL 5.6 • Dulu dikenal sebagai ps_helper oleh Mark Leith • https://dev.mysql.com/doc/refman/5.7/en/sys-schema.html Apakah sys schema? 21
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring Temukan query utk dioptimasi - MySQL Enterprise Monitor Query Analyzer 22
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 02. Monitoring Temukan query utk dioptimasi – Performance Schema Digest Summary mysql> SELECT LEFT(DIGEST_TEXT, 64) AS DIGEST_TEXT, COUNT_STAR, SUM_TIMER_WAIT, MAX_TIMER_WAIT FROM performance_schema.events_statements_summary_by_digest ORDER BY MAX_TIMER_WAIT DESC LIMIT 10; +------------------------------------------------------------------+------------+-----------------+----------------+ | DIGEST_TEXT | COUNT_STAR | SUM_TIMER_WAIT | MAX_TIMER_WAIT | +------------------------------------------------------------------+------------+-----------------+----------------+ | INSERT INTO `salaries` VALUES (...) /* , ... */ | 342 | 159811231808000 | 4156961573000 | | INSERT INTO `dept_emp` VALUES (...) /* , ... */ | 42 | 31561264335000 | 2458392698000 | | INSERT INTO `titles` VALUES (...) /* , ... */ | 63 | 35738435708000 | 1735350241000 | | INSERT INTO `employees` VALUES (...) /* , ... */ | 51 | 18004605187000 | 1679817477000 | | INSERT INTO `sbtest` ( `k` , `c` , `pad` ) VALUES (...) /* , ... | 10 | 5241286782000 | 1247361451000 | | COMMIT | 342 | 31984662051000 | 992714081000 | | DROP SCHEMA IF EXISTS `employees` | 6 | 1252459420000 | 848771265000 | | CREATE TABLE `sbtest` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCR | 1 | 565468324000 | 565468324000 | | CREATE TABLE `dept_manager` ( `dept_no` CHARACTER (?) NOT NULL , | 3 | 355874700000 | 220491035000 | | SELECT COUNT (?) AS `cnt` , `round` ( ( `performance_schema` . ` | 6 | 386062170000 | 217206520000 | +------------------------------------------------------------------+------------+-----------------+----------------+ 10 rows in set (0.00 sec) 23
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File 1. Mulai dengan config file kosong 2. Set paths, port, dll. 3. Nyalakan monitoring tambahan 4. Set setting kapasitas 5. Jangan lakukan lebih dari ini! 24
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Bisa menjadi kelebihan memiliki path yg mengarah ke disk system terpisah – Kurangi contention – I/O seringkali menjadi bottleneck – Dapat meletakkan “hot file” di disk yg lbh cepat • Misalnya dengan innodb_flush_log_at_trx_commit = 1 dan transaction commit rate yg tinggi, mungkin perlu utk meletakkan InnoDB redo log di SSD utk mendukung flush rate yg tinggi • Note: File-per-table tablespace and general tablespace dapat diletakkan diluar datadir sewaktu mereka dibuat Path 25
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Bila anda gunakan InnoDB, aktifkan semua INNODB_METRICS counter : – innodb_monitor_enable = ‘%’ • Extra detail yg diberikan sangat berguna & overhead sangat kecil • Pastikan performance schema sudah diaktivasi – Ada overhead tapi menyediakan informasi yg sgt berguna utk tuning performa – Pertimbangkan utk nyalakan tambahan consumers & instruments seperlunya (misalnya utk transactions di MySQL 5.7) – Performance schema dpt dikonfigurasi secara dinamis sewaktu runtime Nyalakan monitoring tambahan 26
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • MySQL Reference Manual (about innodb_buffer_pool_size): “On a dedicated database server, you might set the buffer pool size to 80% of the machine's physical memory size.” – Bagaimana bila anda memiliki 1TB memory? Apakah anda masih akan menyimpan 20% sisanya utk keperluan lain? • Semestinya : – Berapa banyak memory host miliki? – Kurangi memory yg diperlukan oleh OS & proses lain2 – Kurangi memory yg diperlukan oleh MySQL selain InnoDB Buffer pool – Pilih minimum dari ini dan ukuran dari “working data set” Setting kapasitas - innodb_buffer_pool_size 27
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Total redo log size ditentukan dgn two opsi : – innodb_log_file_size – innodb_log_files_in_group • Total size = innodb_log_file_size * innodb_log_files_in_group – Max total redo log size yg disupport : • MySQL 5.5 dan sebelumnya : just below 4G • MySQL 5.6 dan setelahnya: just below 512G • Harus cukup besar utk hindari checkpointing yg berlebihan • Semakin besar redo log, semakin lambat proses shutdown berjalan Setting kapasitas – InnoDB redo log 28
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Ambil current Log sequence number (LSN) dan checkpoint terakhir : – SHOW ENGINE INNODB STATUS: – INNODB_METRICS: Setting kapasitas – InnoDB redo log – Apakah cukup besar? --- LOG --- Log sequence number 602763740 Log flushed up to 602763740 Pages flushed up to 584668961 Last checkpoint at 555157885 mysql> SELECT NAME, COUNT FROM information_schema.INNODB_METRICS WHERE NAME IN ('log_lsn_current', 'log_lsn_last_checkpoint'); +-------------------------+-----------+ | NAME | COUNT | +-------------------------+-----------+ | log_lsn_last_checkpoint | 555157885 | | log_lsn_current | 602763740 | +-------------------------+-----------+ 29
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Hitung besar redo log terpakai : – Used log = log_lsn_current – log_lsn_last_checkpoint = 602763740 - 555157885 = 47605855 (bytes) • Bandingkan dgn total size : – Used % = (Used log / Total log) * 100 = (47605855 / (innodb_log_file_size * innodb_log_files_in_group)) * 100 = (47605855 / 100663296) * 100 = 47.29 % Setting kapasitas – InnoDB redo log – Apakah cukup besar? 30
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Bila pemakaian mencapai 75% asynchronous flush terjadi – I/O dpt menjadi sangat intensif yg membuat proses lain dari MySQL terhenti – InnoDB thread utama mungkin berstatus : flushing buffer pool pages • Pastikan anda memiliki buffer cukup utk menangani peak load – Misalnya targetkan utk gunakan max 60% atau 70% dari redo log • Penting utk memonitor redo log usage • Perbaikan flushing algorithm dan opsi baru utk mengkontrol I/O telah ditambahkan di versi MySQL terbaru Setting kapasitas – InnoDB redo log – Apakah cukup besar? 31
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • Innodb_undo_tablespaces hanya dpt di-set sblm initializing datadir! • Bila di-set maka undo log tablespace akan dibuat diluar system tablespace (ibdata1) • Kelebihan : – Membuat system tablespace lebih kecil – Dpt di-set agar undo log diletakkan di disk yg lbh cepat spt SSD – Di MySQL 5.7 undo log tablespace dapat di-truncate • Tiap undo tablespace adalah 10M awalnya • Maximum 95 undo tablespace di 5.7 InnoDB Undo Log 32
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 03. Initial Configuration File • max_connections – berhati2 set ini terlalu besar karena tiap koneksi butuh memory • table_definition_cache – pastikan semua table dapat disimpan di cache. Bila memiliki 4000 tables, maka set table_definition_cache > 4000 • table_open_cache – tiap table dapat dibuka lebih dari sekali • table_open_cache_instances – Biasanya di-set di 16 Opsi kapasitas lain 33
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Apakah menyalakan cache adalah selalu pilihan terbaik? • Apakah cache & buffer lebih besar lebih baik? Beberapa buffer & cache yg tersedia 34
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Apakah menyalakan cache adalah selalu pilihan terbaik? • Apakah cache & buffer lebih besar lebih baik? • No! Beberapa buffer & cache yg tersedia 35
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Biasanya menyalakan query cache jarang berguna – Dioperasikan oleh single mutex • Kebanyakan workload lbh baik gunakan query cache disabled (default) : – query_cache_type = 0 • Bila anda berpikir bahwa workload anda butuh query cache, test dahulu – Makin banyak write, semakin sedikit gunanya – Makin banyak data tersimpan di buffer pool, semakin sedikit gunanya – Makin complex query dan makin besar scan, semakin banyak gunanya • Biasanya solusi caching lainnya adalah opsi yg lbh baik Query Cache 36
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Di MySQL 5.5 dan sebelumnya : hanya digunakan utk index scan biasa, range index scan, dan join2 yg tak gunakan index – Tidak ada alasan utk memiliki lbh besar dari size masing2 row yg match • Di MySQL 5.6+ juga digunakan utk Batched Key Access (BKA) – Query yg gunakan BKA dapat diuntungkan dari join buffer yg lbh besar • Size minimum telaah dialokasi! • Biasanya global value yg kecil yg terbaik : 32k-256k • Besarkan dalam session bila diperlukan join_buffer_size 37
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Seperti join_buffer_size, global value yg kecil bisanya terbaik : 32k-256k • Dapat dimonitor menggunakan global status variable Sort_merge_passes: • Targetkan utk beberapa Sort_merge_passes per detik di server yg sibuk • Besarkan di level session bila perlu sort_buffer_size mysql> SHOW GLOBAL STATUS LIKE 'Sort_merge_passes'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Sort_merge_passes | 0 | +-------------------+-------+ 1 row in set (0.00 sec) 38
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 04. Buffers And Caches • Beberapa buffer dialokasi secara full tiap kali mereka dipakai • Satu query dpt gunakan bbrp buffer, maka buffer2 besar dpt akibatkan pemakaian memory yg jauh lbh besar • Alokasi memory relative mahal • Misalnya Linux glibc malloc merubah algoritma alokasi memory ketika batas telah terlewati (biasanya 256k or 512k) – Algoritma utk alokasi yg lbh besar dpt 40 kali lbh lembat daripada alokasi kecil Mengapa penting dgn global value yg kecil? 39
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 05. Data Consistency Versus Performance • Value yg dpt di-set sesuai urutan mulai dari data safety plg baik – 1: secara teori adalah yg plg lambat, namun dgn SSD cepat dapat secepat opsi 2 dan 0 – 2: di-flush tiap detik (innodb_flush_log_at_timeout in 5.6+) • Transaksi dpt hilang bila OS crash – 0: MySQL tidak pernah fsync • Transaksi dpt hilang bila OS crash • Defaults adalah 1 – flush redo log setelah tiap commit – Dibutuhkan utk memenuhi D dalam ACID – Karena alasan ini lah, 1 adalah value recommended innodb_flush_log_at_trx_commit 40
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 05. Data Consistency Versus Performance • Bagaimana bila innodb_flush_log_at_trx_commit = 1 terlalu lamban dan anda ingin D dalam ACID? – Pastikan redo log group dalam disk yg terpisah dgn data • Jangan tergoda utk meletakkan masing2 redo log di disk terpisah – Pertimbangkan SSD terutama bila anda memiliki commit rate yg tinggi – Disk cache battery-backed juga memberikan flush yg murah karena IO cepat innodb_flush_log_at_trx_commit 41
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 05. Data Consistency Versus Performance • Spesifikasikan berapa banyak transaksi antara tiap flush binary log – 0: ketika rotating binary log atau ketika OS inisiasi – 1: tiap transaction commit – Ini yg paling safe – N: tiap N commit • Default value: – MySQL 5.6 dan sebelumnya : 0 – MySQL 5.7 dan setelahnya : 1 • MySQL 5.6 dan setelahnya mendukung group commit utk InnoDB yg mengurangi overhead dari sync_binlog=1 sync_binlog 42
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 05. Data Consistency Versus Performance • Sync_binlog != 1 berarti slave kemungkinan besar akan harus di-rebuild bila master crash • Namun sync_binlog = 0 pastilah memberi performa terbaik, benar? sync_binlog 43
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 05. Data Consistency Versus Performance • Sync_binlog != 1 berarti slave kemungkinan besar akan harus di-rebuild bila master crash • Namun sync_binlog = 0 pastilah memberi performa terbaik, benar? – By default: max_binlog_size = 1G – 1G tidak dianggap kebutuhan besar utk memory saat ini – Maka OS dapat mem-buffer seluruh binary log – Ketika rotating binary log, diatas 1G akan di-flush ke disk • Menghentikan semua commit2 lain sampai binary log rotation selesai • Maka pendeknya : sync_binlog=0 akan berikan throughput terbaik, tapi sync_binlog =1 akan berikan performa yg paling dpt diprediksi sync_binlog 44
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Masalah dpt terjadi di setiap level dalam stack, misalnya : – Application – Application host/hardware – Network antara application dan host dgn MySQL – MySQL host/hardware – MySQL • Ini harus juga dipertimbangkan sewaktu monitoring • Pertimbangkan setting OS/hardware 45
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Pastikan anda memiliki cukup RAM – Semua data aktif harus tersimpan di buffer pool – Koneksi & cache MySQL membutuhkan memory – Extra RAM utk • FS cache • Monitoring • RAM disk (tmpfs) Pertimbangan hardware 46
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • CPU cepat sangat diperlukan utk performa single thread • Server2 baru memiliki 32 – 80 core • Nyalakan hyper-threading • MySQL skrg dpt scale lbh dari 72 core di 5.7 • Jumlah core yg sama di socket yg lbh sedikit lebih baik • Core yg lbh cepat lbh baik dari core yg lambat & banyak Pertimbangan hardware 47
  • 48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Storage yg cepat & handal bagus utk load yg berat di IO • HDD utk sequential reads & writes • SSD attach ke bus utk random reads & writes • SATA atau disk lain utk log file • Beberapa disk! • Umur disk juga harus dipertimbangkan Pertimbangan hardware - Storage 48
  • 49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Linux (L of LAMP) • Solaris juga bagus • Oracle juga invest di Windows • Utk performa murni, gunakan Linux Operating System 49
  • 50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • I/O Scheduler – Beberapa Linux distro menggunakan CFQ scheduler by default • OK utk reads • Serial writes! – NOOP & deadline biasanya lbh baik utk workload MySQL • Deadline adalah default I/O scheduler utk Oracle Linux Unbreakable Setting I/O di the operating system 50
  • 51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • I/O Scheduler – Cek scheduler saat ini : – Update scheduler secara dinamis : – Utk set waktu boot time, gunakan “elevator=deadline” boot option Setting I/O di the operating system shell# cat /sys/block/sda/queue/scheduler noop deadline [cfq] shell# echo deadline > /sys/block/sda/queue/scheduler shell# cat /sys/block/sda/queue/scheduler noop [deadline] cfq 51
  • 52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Linux glibc malloc dpt menjadi performa bottleneck • Lbh baik gunakan malloc library alternative : – tcmalloc – jemalloc Memory allocation library 52
  • 53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 06. Consider the Whole Stack • Set alternative malloc library: – mysqld_safe – systemd distributions: • Set LD_PRELOAD in /etc/sysconfig/mysql Memory allocation library [mysqld_safe] malloc-lib = /usr/lib64/libjemalloc.so.1 53
  • 54. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Summary Wrapping it all up 54
  • 55. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Ringkasan • Tuning performa MySQL mirip dgn tuning performa database lain : – Optimisasi premature tidak baik – Hanya rubah satu hal tiap waktu & jgn lakukan perubahan terlalu besar – Jangan micro manage – Satu size tidak cocok utk semua – Buat keputusan berdasarkan pengukuran – Mengerti apa maksudnya sebuah opsi sebelum implementasi opsi tersebut – Mengerti system anda (data) – Mengerti apa yg anda butuhkan – Pertimbangkan seluruh stack 55
  • 56. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Thank You Q&A 56
  • 57. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 57

Editor's Notes

  1. Probably the first thing to keep in mind is that you should be very careful while following any best practices of performance tuning. The reason is, the environment those practices are applicable to will almost never be identical to yours and what sas said earlier may not hold true any longer for various reaons… like mysql version change or hardware configuration being different etc.
  2. Next point is, don’t pay too much attention to the benchmarks provided by hardware and software providers. You should test YOUR environment, your application and benchmark… also keep monitoring and when you apply any changes, make one change at a time.
  3. For example read_rnd_buffer_size was in 5.5 and earlier only used by MyISAM. But in 5.6 and later by all storage engines for Multi-Range Optimization.
  4. For example read_rnd_buffer_size was in 5.5 and earlier only used by MyISAM. But in 5.6 and later by all storage engines for Multi-Range Optimization.
  5. Safety vs performance: e.g. sync_binlog and innodb_flush_at_trx_commit Using the default value also automatically gives you improved values when the default value is changed in new versions. But new options also often has values that are backward compatible so does not take advantage of new features. InnoDB (and NDBCluster) will always have a “PRIMARY KEY” whether specified explicitly or not The PRIMARY KEY can also be a NOT NULL unique index Unsigned integers with auto_increment makes a good PRIMARY KEY for InnoDB. If you use UUID like PRIMARY KEYs for InnoDB, consider re-order the components to have the time component first.
  6. Same procedure as when investigating all kinds of issues
  7. Everybody knows this but sometimes, we just don’t practice. It’s important to have an action plan and follow it. If something goes wrong, you have a record of what you did.
  8. If you start to ignore monitoring alerts because “it’s not important”, sooner or later you will also ignore one that is important I will not go into details here using the monitoring system for performance tuning as there are other talks dedicated to that – see the references later
  9. This is one of the reports available in Workbench which gives you details of events which are doing most I/O
  10. Used by MySQL Enterprise Monitor Query Analyzer by default in 5.6.14 and later Enabled by default DIGEST_TEXT is a normalized query equivalent to the queries returned by mysqldumpslow Timings are in picoseconds – the sys schema has the format_time() function to convert to human readable text
  11. Obviously you may have experiences from previous projects that you may want to take into account But remember, MySQL may have changed since you deployed the last project
  12. The InnoDB redo logs may also be a good candidate for spinning disks as it’s sequential I/O; the fsync rate will be deciding factor Binary logs are also I/O intensive, but serial I/O The paths can be reconfigured later
  13. Make sure to allow for growth! Can be changed dynamically in 5.7+
  14. Drawback of “too large” redo log: slower crash recoveries
  15. The INNODB_METRICS log_lsn_% counters are not enabled by default, but it is recommended to enable them. Thus the innodb_monitor_enable = '%‘ recommendation for the initial configuration file.
  16. This example uses the default values for the InnoDB redo log size
  17. There are other similar main thread states which are not an indication of an asynchronous flush If you have problems with asynchronous flushing, upgrading may help you Side note: you can make incremental backups with MySQL Enterprise Backup using exclusively the redo log – if so make sure it’s big enough to hold the changes between backups.
  18. Not really a capacity setting, but important to consider when creating the initial configuration file as innodb_undo_tablespaces cannot be changed later The undo logs can be I/O intensive – with random I/O The maximum allowed number of undo tablespaces were reduced in 5.7 as 32 tablespaces are now reserved for temporary tables
  19. Example of option that has changed meaning between releases
  20. In 5.5. and earlier the sort buffer was allocated in full each time it was needed
  21. Allocation < MALLOC_MMAP_THRESHOLD uses heap, > MALLOC_MMAP_THRESHOLD uses MMAP
  22. Have seen cases where 1 was fastest or as fast as 0/2 (redo logs were on SSD) Make sure your operating system and hardware is not lying about the flush-to-disk operation Crash recovery works irrespectively of the setting, but with != 1 some transactions may be missing after the recovery
  23. CFQ = Completely Fair Queuing
  24. jemalloc was installed from epel