Alejandro Álvarez on behalf of the FTS team

Slides:



Advertisements
Similar presentations
Drop in replacement of MySQL. Agenda MySQL branch GPL licence Maria storage engine Virtual columns FederatedX storage engine PBXT storage engine XtraDB.
Advertisements

File Processing : Hash 2015, Spring Pusan National University Ki-Joune Li.
Distributed Databases John Ortiz. Lecture 24Distributed Databases2  Distributed Database (DDB) is a collection of interrelated databases interconnected.
1 Overview of Storage and Indexing Yanlei Diao UMass Amherst Feb 13, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Physical Database Monitoring and Tuning the Operational System.
1 External Sorting for Query Processing Yanlei Diao UMass Amherst Feb 27, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Team Dosen UMN Physical DB Design Connolly Book Chapter 18.
Agile Environments and DBAs Laine Campbell, PalominoDB Sheeri Cabral, The Pythian Group.
Lecture 9 Methodology – Physical Database Design for Relational Databases.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Data and its manifestations. Storage and Retrieval techniques.
European Interoperability Architecture e-SENS Workshop : Collecting data for the Cartography Tool 7-8 January 2015.
NoSQL Databases Oracle - Berkeley DB. Content A brief intro to NoSQL About Berkeley Db About our application.
1 Index Structures. 2 Chapter : Objectives Types of Single-level Ordered Indexes Primary Indexes Clustering Indexes Secondary Indexes Multilevel Indexes.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
© Pearson Education Limited, Chapter 13 Physical Database Design – Step 4 (Choose File Organizations and Indexes) Transparencies.
G063 - Distributed Databases. Learning Objectives: By the end of this topic you should be able to: explain how databases may be stored in more than one.
By Shanna Epstein IS 257 September 16, Cnet.com Provides information, tools, and advice to help customers decide what to buy and how to get the.
Methodology – Physical Database Design for Relational Databases.
Introduction MySQL won't actually execute the query, just analyse it EXPLAIN helps us understand how and when MySQL will use indexes EXPLAIN returns a.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Visual Basic for Application - Microsoft Access 2003 Finishing the application.
Mining real world data RDBMS and SQL. Index RDBMS introduction SQL (Structured Query language)
Introduction to Distributed Databases Yiwei Wu. Introduction A distributed database is a database in which portions of the database are stored on multiple.
Query Execution. Where are we? File organizations: sorted, hashed, heaps. Indexes: hash index, B+-tree Indexes can be clustered or not. Data can be stored.
Chapter Five Distributed file systems. 2 Contents Distributed file system design Distributed file system implementation Trends in distributed file systems.
Creating a simplified global unique file catalogue Miguel Martinez Pedreira Pablo Saiz.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
How is data stored? ● Table and index Data are stored in blocks(aka Page). ● All IO is done at least one block at a time. ● Typical block size is 8Kb.
1 CS122A: Introduction to Data Management Lecture #15: Physical DB Design Instructor: Chen Li.
CS Introduction to Operating Systems
10/3/2017 Chapter 6 Index Structures.
Practical Database Design and Tuning
Remote Backup Systems.
Jonathan Walpole Computer Science Portland State University
Module 11: File Structure
392-"JOIN" us on DataServers Journey
CS 540 Database Management Systems
Indexes By Adrienne Watt.
Record Storage, File Organization, and Indexes
CS 540 Database Management Systems
Large-scale file systems and Map-Reduce
Physical Changes That Don’t Change the Logical Design
Lecture 16: Data Storage Wednesday, November 6, 2006.
Database Management Systems (CS 564)
Database Applications (15-415) DBMS Internals- Part VII Lecture 16, October 25, 2016 Mohammad Hammoud.
Isolation Levels Understanding Transaction Temper Tantrums
Methodology – Physical Database Design for Relational Databases
Database Management Systems (CS 564)
Physical Database Design for Relational Databases Step 3 – Step 8
Database Performance Tuning and Query Optimization
Arrested by the CAP Handling Data in Distributed Systems
國立臺北科技大學 課程:資料庫系統 fall Chapter 18
G063 - Distributed Databases
Introduction to Database Systems
Database Applications (15-415) DBMS Internals- Part VII Lecture 19, March 27, 2018 Mohammad Hammoud.
Physical Database Design
(Slides by Hector Garcia-Molina,
Database Design and Programming
2018, Spring Pusan National University Ki-Joune Li
Chapter 11 Database Performance Tuning and Query Optimization
Indexing 4/11/2019.
Advance Database System
Isolation Levels Understanding Transaction Temper Tantrums
Remote Backup Systems.
CSE 326: Data Structures Lecture #14
Index Structures Chapter 13 of GUW September 16, 2019
Join Implementation How is it done? Copyright © Curt Hill.
Presentation transcript:

Alejandro Álvarez on behalf of the FTS team The FTS Case Alejandro Álvarez on behalf of the FTS team

Introduction about FTS Implements low-level transferring for LHCb, ATLAS and CMS And a few other smaller Multi-level, fair share transfer scheduler Maximize resource usage & congestion avoidance Multiple protocol support Support for recall from tape

Introduction about FTS Experiments need to copy a big number of files between sites They send the list to FTS3 FTS3 decides how many transfers to run (optimizer) and how to share them (scheduler) FTS3 runs the transfer when suitable Messages are sent for asynchronous clients and for monitoring

MySQL in FTS3 FTS3 uses MySQL to keep the queue, and the state of each transfer When scheduling, need to get them from there On changes, need to update the DB For the optimizer and monitoring views, need to aggregate One database used by a few hosts

MySQL in FTS3 Performing well with the DB is necessary for a well performing service MySQL could be quite stressed (80% CPU usage wasn’t rare) Architecture changes were (are) considered, but that’s very hard! Can’t take years to make things better The DB was a “low” hanging fruit

MySQL in FTS3 Some ideas were already in place Each node only access an even subset of the tables Avoids contention

Today Architecture is still the same CPU usage now between 14% and peaks of 50% Way better! We can do more with the same What changed?

Step 1: Disable backups Yes, really DboD scheduled backups We can afford it Recovering from 23 hours old backup is worse than non recovering at all (for us!) Was damaging us Symptom: blocked queries and a “FLUSH TABLES WITH READ LOCK;”

Step 1: Disable backups From time to time we would see MySQL (thus, FTS3) deadlocking A massive query Q1 may be read-locking table T1 mysqldump tries to get a global lock, blocking updates first, but then mysqldump gets blocked by Q1 All updates get blocked until Q1 is done

Step 1: Disable backups From time to time we would see MySQL (thus, FTS3) deadlocking A massive query Q1 may be read-locking table T1 mysqldump tries to get a global lock, blocking updates first, but then mysqldump gets blocked by Q1 All updates get blocked until Q1 is done

Step 1: Disable backups Don’t do this! Again, we can afford it Nice to know this can happen You may be able to live without single transaction dumps Or reconsider the long queries Or use master-slave replication

Step 2: Profile database Slow queries Archival of old jobs is the most time consuming part! Unused indexes Archive tables… hum Thanks to the DB people!

Step 3: Reconsider engine type ARCHIVE is better for data rarely read, never modified Not indexed Low disk footprint, fast INSERT Perfect for the archive tables!

Step 4: Low hanging fruit Drop unused and redudant fields Smaller reads Reconsider column types Reconsider index types

Step 4: Low hanging fruit Reconsider column types Some string fields (state) could be enums 1 byte vs ~O(10) Indexed! Adding is cheap, deleting/renaming is expensive Some string fields could be booleans And others could be shorter

Step 4: Low hanging fruit Reconsider index type BTREE vs HASH index type HASH only supported by MEMORY engine Nevermind, then

Step 5: Slow queries Gives a hint at what indexes to add Look at EXPLAIN <query> Indexes improves SELECT, hurt INSERT/DELETE, and maybe UPDATE

Step 6: Redundant indexes (a, b, c) covers a a,b a,b,c (a,b,c) is redundant with (b,c,a), but (b,c) may be needed, and (a,b) never

Step 6: Redundant indexes Very coupled with which queries are run Queries can be reworded to match index Or an index can be added to match the query More queries using the same index => less indexes => good Harder, because you need to move queries and indexes in lockstep

Step 7: Rewrite queries Multiple nodes may pick the same entry SELECT FOR UPDATE is bad, locks the record for potentially a long time SELECT job FROM t_job WHERE running=0 FOR UPDATE UPDATE SET running = 1 WHERE job = X Rather, UPDATE WHERE + affected rows SELECT job FROM t_job WHERE running=0 UPDATE t_job SET running = 1 WHERE job = X AND running = 0 mysql_affected_rows() > 0

An example Retrieve files to recall from tape was very slow Reading way more than needed # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 450 # Exec time 74 395835s 10s 24060s 880s 3781s 2352s 113s # Lock time 0 95ms 115us 2ms 211us 515us 161us 159us # Rows sent 1 263.24k 0 1000 599.01 964.41 440.36 964.41 # Rows examine 99 94.44G 141.27k 5.16G 214.91M 1006.04M 566.21M 23.50M # Query size 1 377.26k 855 859 858.47 833.10 0 833.10

An example The original query had a DEPENDENT SUBQUERY, which blows the number of rows read It degraded with time, ending N2 To fix it, had to consider both query an index Many iterations of EXPLAIN and rewrite Managed to drop the nested query Turned into a self-JOIN

An example To make queries easier, wrapped the self-join into a view 2 PRIMARY + DEPENDENT SUBQUERY went away, replaced with three SIMPLE Added an index to make it better

An example Exec time: 395 835s => 13 490s # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 1 316 # Exec time 2 13490s 10s 128s 43s 76s 21s 42s # Lock time 0 151ms 227us 14ms 476us 384us 1ms 287us # Rows sent 3 308.19k 609 1000 998.68 964.41 20.91 964.41 # Rows examine 3 1.23G 42.99k 6.80M 4.00M 5.71M 1.10M 4.06M # Query size 0 104.04k 334 338 337.15 329.68 0 329.68 Exec time: 395 835s => 13 490s No way around knowing your queries, and iterating

TODO: UUID are terrible keys 36 characters InnoDB stores the primary key on all secondary keys It is randomly distributed which is actually bad Scattered writes Fragmentation See Percona’s blog post on it