WORSE CASE SCENARIO IN THE DATABASE WORSE CASE SCENARIO IN THE - - PowerPoint PPT Presentation

worse case scenario in the database
SMART_READER_LITE
LIVE PREVIEW

WORSE CASE SCENARIO IN THE DATABASE WORSE CASE SCENARIO IN THE - - PowerPoint PPT Presentation

DEPARTMENT OF COMMERCE WORSE CASE SCENARIO IN THE DATABASE WORSE CASE SCENARIO IN THE DATABASE GIVE ME YOUR WORST OH NO! A DATABASE MUST BE IN TROUBLE! @bellmar WORSE CASE SCENARIO IN THE DATABASE WERE HAVING SERIOUS PERFORMANCE


slide-1
SLIDE 1

WORSE CASE SCENARIO IN THE DATABASE

DEPARTMENT OF COMMERCE

slide-2
SLIDE 2

WORSE CASE SCENARIO IN THE DATABASE

GIVE ME YOUR WORST

@bellmar

OH NO! A DATABASE MUST BE IN TROUBLE!

slide-3
SLIDE 3

WE’RE HAVING SERIOUS PERFORMANCE ISSUES. CAN YOU LOOK AT OUR DB?

Important Client

WORSE CASE SCENARIO IN THE DATABASE

slide-4
SLIDE 4

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

slide-5
SLIDE 5

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

OMG WTF?!?!?

  • OH. THAT LOOKS LIKE MY

DATABASE…

slide-6
SLIDE 6

IT’S NOT THE NUMBER OF TABLES

IT’S WHY YOU NEED SO MANY

slide-7
SLIDE 7

WORSE CASE SCENARIO IN THE DATABASE

TECHNICAL DEBT

@bellmar

๏ “Technical debt” is not limited to application code ๏ How often do we change things? ๏ Application code: Often ๏ Infrastructure: Rarely ๏ Data model and schemas: Variable

slide-8
SLIDE 8

WORSE CASE SCENARIO IN THE DATABASE

TECHNICAL DEBT

@bellmar New Feature Refactoring

slide-9
SLIDE 9

WORSE CASE SCENARIO IN THE DATABASE

TECHNICAL DEBT

@bellmar Mon Tues Wed Thurs Fri

slide-10
SLIDE 10

WORSE CASE SCENARIO IN THE DATABASE

DEBT -VS- LEGACY

@bellmar

DEBT

✓ WTF factor ✓ Performance unaffected by upgrades ✓ Extended onboarding engineers

LEGACY

✓ Design pattern resource mismatch ✓ Performance product of capacity ✓ Candidate skill gap

$

slide-11
SLIDE 11

WITHOUT A WAY TO MEASURE DEBT

THE BEST TIME TO PAY IT DOWN IS ALWAYS TOMORROW

slide-12
SLIDE 12

WORSE CASE SCENARIO IN THE DATABASE

MEASURING TECHNICAL DEBT

@bellmar

slide-13
SLIDE 13

WORSE CASE SCENARIO IN THE DATABASE

MEASURING TECHNICAL DEBT

@bellmar

Feature started Feature deployed Bug fixes

slide-14
SLIDE 14

WORSE CASE SCENARIO IN THE DATABASE

MEASURING TECHNICAL DEBT

@bellmar

Feature started Feature deployed Bug fixes!!!

slide-15
SLIDE 15

WORSE CASE SCENARIO IN THE DATABASE

MEASURING TECHNICAL DEBT

@bellmar

๏ Increase in operation costs ๏ Static code analysis ๏ Test coverage

slide-16
SLIDE 16

WORSE CASE SCENARIO IN THE DATABASE

WHY DON’T WE TALK ABOUT TECHNICAL DEBT IN THE DB?

@bellmar

๏ Most businesses only live 10 years (Time Magazine, 2015) ๏ Silos between DBA and Data Engineering ๏ Backups? Software upgrades? ๏ Normalization? Queries? ๏ “From my experience, a DBA maintains existing infrastructure and a Data Engineer designs

new/expanding databases”

U m m … w h a t ? O .

slide-17
SLIDE 17

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

slide-18
SLIDE 18

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

slide-19
SLIDE 19

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

slide-20
SLIDE 20

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

TABLE AND COLUMN NAMES NOT INTUITIVE

fdtw01_applDOAlcc NmOCoun_1

slide-21
SLIDE 21

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

TABLE AND COLUMN NAMES NOT INTUITIVE

fdtw01_applDOAlcc NmOCoun_1

fake data train wreck 01 application Department of Awesome location country code

Name Of Country

slide-22
SLIDE 22

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

PII AS PRIMARY KEY

slide-23
SLIDE 23

WORSE CASE SCENARIO IN THE DATABASE

IMPROPER PRIVACY/SECURITY

@bellmar

๏ Restricting tool options (test data when PK is unencrypted PII) ๏ “Temporary” roles that have too much access ๏ Not upgrading hashing algorithms (MD5 SHA-1 SHA-256) ๏ Not maturing architecture as organization matures (message queues!)

slide-24
SLIDE 24

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

THIS IS VIEW BASED ON THIS TABLE

slide-25
SLIDE 25

WORSE CASE SCENARIO IN THE DATABASE

DATABASE VIEWS

@bellmar USEFUL

๏ Regularly joining multiple tables ๏ Subsets of data, better access control ๏ Routine db calculations (sums, geo) ๏ Feature flagging

DYSFUNCTIONAL

๏ Developer silos (my views, your views) ๏ Hides complexity ๏ Application logic in the db ๏ Small but not nonexistent

slide-26
SLIDE 26

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

THESE ARE DBLINKS TO OTHER DATABASES

slide-27
SLIDE 27

WORSE CASE SCENARIO IN THE DATABASE

DBLINKS AND OTHER MAGIC TRICKS

@bellmar

๏ DBlinks: joins across databases ๏ Query time + network speed ๏ Directionality: Query from which table? Can affect performance ๏ Complicates security ๏ Why was this data separate in the first place?

slide-28
SLIDE 28

WORSE CASE SCENARIO IN THE DATABASE

STORED PROCEDURES

@bellmar

๏ Scripts inserted and run on the db itself ๏ Code will usually run faster on the db than the application ๏ Application logic kept away from where application teams can see it ๏ “We don’t need to version control it because it’s in our backups” ๏ Harder to trace or predict impact of changes

slide-29
SLIDE 29

WORSE CASE SCENARIO IN THE DATABASE

@bellmar

COLUMN TYPE HERE IS BLOB

slide-30
SLIDE 30

WORSE CASE SCENARIO IN THE DATABASE

BLOBS: WHAT DATA IS DATA?

@bellmar

๏ BLOB = Binary Large Object ๏ Images, audio, executables … these things are not queryable ๏ Popular as storage became cheap, but inflates the size of the database ๏ As connection speeds increase, cloud file storage (AWS S3) preferred

slide-31
SLIDE 31

WORSE CASE SCENARIO IN THE DATABASE

WHAT SHOULD YOU DO?

@bellmar

๏ Audit the queries? ๏ Migrate to NoSQL? ๏ Rewrite and simplify the applications using this db? ๏ Light the thing on fire and go home?

slide-32
SLIDE 32

INCREMENTAL FAILURE IS SOLVED WITH

INCREMENTAL IMPROVEMENT

slide-33
SLIDE 33

WORSE CASE SCENARIO IN THE DATABASE

RESPONSIBILITY GAP

@bellmar

DBAS DEVS OPS

Query optimization Schema design Security Upgrading Backups Analysis Normalization

slide-34
SLIDE 34

WORSE CASE SCENARIO IN THE DATABASE

ARE ENGINEERS FIRST CLASS CITIZENS?

@bellmar

Oh stop being so dramatic. It’s just one little change

slide-35
SLIDE 35

WORSE CASE SCENARIO IN THE DATABASE

COMMUNICATION TOOLS

@bellmar

๏ Organized chat: Can people figure out who each other are and reach out quickly? ๏ Automation: Readable configuration scripts and immutable architecture means devs can see

hidden logic. Dev environments easier to setup

๏ Documentation: How does your data dictionary relate to your code documentation? Are you

using ORM?

slide-36
SLIDE 36

WORSE CASE SCENARIO IN THE DATABASE

DEFINE YOUR GOAL

@bellmar PERFORMANCE SECURITY ACCURACY

slide-37
SLIDE 37

WORSE CASE SCENARIO IN THE DATABASE

PRIORITIZE BASED ON WORST QUERIES

@bellmar TIME PER EXEC TOTAL TIME EXECUTIONS % CPU

88.89 1,155.52 13 78.09 6.33 43,742.23 6,914 86.07 0.55 792.04 1,442 83.38

slide-38
SLIDE 38

WORSE CASE SCENARIO IN THE DATABASE

PRIORITIZE BASED ON WORST QUERIES

@bellmar TIME PER EXEC TOTAL TIME EXECUTIONS % CPU

88.89 1,155.52 13 78.09 6.33 43,742.23 6,914 86.07 0.55 792.04 1,442 83.38

slide-39
SLIDE 39

WORSE CASE SCENARIO IN THE DATABASE

PRIORITIZE BASED ON WORST QUERIES

@bellmar TIME PER EXEC TOTAL TIME EXECUTIONS % CPU

88.89 1,155.52 13 78.09 6.33 43,742.23 6,914 86.07 0.55 792.04 1,442 83.38

slide-40
SLIDE 40

WORSE CASE SCENARIO IN THE DATABASE

PRIORITIZE BASED ON WORST QUERIES

@bellmar TIME PER EXEC TOTAL TIME EXECUTIONS % CPU

88.89 1,155.52 13 78.09 6.33 43,742.23 6,914 86.07 0.55 792.04 1,442 83.38

slide-41
SLIDE 41

WORSE CASE SCENARIO IN THE DATABASE

PRIORITIZE BASED ON WORST QUERIES

@bellmar TIME PER EXEC TOTAL TIME EXECUTIONS % CPU

88.89 1,155.52 13 78.09 6.33 43,742.23 6,914 86.07 0.55 792.04 1,442 83.38

slide-42
SLIDE 42

WORSE CASE SCENARIO IN THE DATABASE

MINIMIZE VECTORS

@bellmar

slide-43
SLIDE 43

WORSE CASE SCENARIO IN THE DATABASE

MINIMIZE VECTORS

@bellmar

Migrate application logic from stored procedure to application

slide-44
SLIDE 44

WORSE CASE SCENARIO IN THE DATABASE

MINIMIZE VECTORS

@bellmar

Use feature flags in the db (even views) to shift applications over one at a time

slide-45
SLIDE 45

WORSE CASE SCENARIO IN THE DATABASE

REDUCE OVERALL DATABASE SIZE

@bellmar “After 3 months the data the user has entered into our system for their shipment is not accessed again”

6+ months old

slide-46
SLIDE 46

OK, BUT I WOULD NEVER WORK FOR A COMPANY LIKE

  • THIS. WHY SHOULD I CARE?

You, and thousands of other engineers

WORSE CASE SCENARIO IN THE DATABASE

slide-47
SLIDE 47

WORSE CASE SCENARIO IN THE DATABASE

THIS DATA IS IMPORTANT

@bellmar

๏ Background checks for visa applications ๏ Shipping logistics for military families ๏ Financial data that informs decisions made by pensions and investment managers ๏ Election records

slide-48
SLIDE 48

“I HAVE [X] YEARS OF EXPERIENCE AND I’M STILL TERRIFIED OF BEING ON CALL”

slide-49
SLIDE 49

WORSE CASE SCENARIO IN THE DATABASE

HOW WE JUDGE EXPERTISE

@bellmar

NORMAL BEHAVIOR EDGE CASES NORMAL BEHAVIOR EDGE CASES IDIOSYNCRASIES

QUIRKS

I’VE SEEN SOME SHIT, MAN

slide-50
SLIDE 50

THANK YOU!

COME TALK TO US ABOUT OPPORTUNITIES