Proxies and supporting an exploding number of user-accounts Eric - - PowerPoint PPT Presentation

proxies and supporting an exploding number of user
SMART_READER_LITE
LIVE PREVIEW

Proxies and supporting an exploding number of user-accounts Eric - - PowerPoint PPT Presentation

Proxies and supporting an exploding number of user-accounts Eric Herman - Percona Live - 2018-04-24 Eric Herman eric.herman@gmail.com https://github.com/ericherman/ https://twitter.com/eric_herman Trend of more complex deployments - tools


slide-1
SLIDE 1

Proxies and supporting an exploding number of user-accounts

Eric Herman - Percona Live - 2018-04-24

slide-2
SLIDE 2

Eric Herman eric.herman@gmail.com https://github.com/ericherman/ https://twitter.com/eric_herman

slide-3
SLIDE 3

Trend of more complex deployments - tools

  • More external tooling

○ Orchestrator, gh-ost ○ pt-online-schema-change ○ Percona XtraBackup ○ Sqoop, mysql-time-machine ○ ps-top, query analysis tools ○ binlog parsing/analysis tools (e.g. to kafka)

slide-4
SLIDE 4

Trend of more complex deployments - plugins

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, e.g. Audit:

○ Prevent CREATE TABLE if no primary key

slide-5
SLIDE 5

Trend of more complex deployments - plugins 1

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, e.g. Audit:

○ Prevent CREATE TABLE if no primary key

■ https://github.com/dveeden/mysql-enforcepk

slide-6
SLIDE 6

Trend of more complex deployments - plugins 2

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, e.g. Audit:

○ Prevent CREATE TABLE if no primary key

■ https://github.com/dveeden/mysql-enforcepk

○ Prevent DROP TABLE if not named like %_DROP_AFTER_YYYY_MM_DD (and past)

slide-7
SLIDE 7

Trend of more complex deployments - plugins 3

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, e.g. Audit:

○ Prevent CREATE TABLE if no primary key

■ https://github.com/dveeden/mysql-enforcepk

○ Prevent DROP TABLE if not named like %_DROP_AFTER_YYYY_MM_DD (and past) ○ Warn if “suspicious” query

slide-8
SLIDE 8

Trend of more complex deployments - triggers

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins
  • More sophisticated use of triggers

○ Online schema change

slide-9
SLIDE 9

Trend of more complex deployments - triggers 1

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins
  • More sophisticated use of triggers

○ Online schema change ○ R&D: write additional information into a blackhole table in order to record more information about “who did it” in the binlog

slide-10
SLIDE 10

Trend of more complex deployments - proxies

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, triggers
  • More proxies

○ Vitess ○ ProxySQL ○ MySQL Router ○ MaxScale

slide-11
SLIDE 11

Trend of more complex deployments - users

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, triggers
  • More proxies
  • More user accounts per server

○ More applications, services, micro-services ○ More powerful logging, auditing ○ Per-user accounts, fine-grain permissions

slide-12
SLIDE 12

Trend of more complex deployments - conflict

  • More external tooling (e.g. orchestrator)
  • More sophisticated use of plugins, triggers
  • More proxies
  • More user accounts per server
  • Conflict: proxy may not support custom

connection attributes, or may not nicely support lots of users with session variables

slide-13
SLIDE 13

Wanted: more dynamic connection attributes

  • E.g: connection pool with shared app user

○ Set the webpage with each request?

slide-14
SLIDE 14

Wanted: more dynamic connection attributes 1

  • E.g: connection pool with shared app user

○ Set the webpage with each request?

  • Wish for nicer support at the protocol level

○ But then connector support, too

slide-15
SLIDE 15

Wanted: more dynamic connection attributes 2

  • E.g: connection pool with shared app user

○ Set the webpage with each request?

  • Wish for nicer support at the protocol level

○ But then connector support, too

  • Proxies might use COM_CHANGE_USER

○ Store attributes per proxied connection :-(

○ https://dev.mysql.com/doc/internals/en/com-change-user.html ○ https://mariadb.com/kb/en/library/com_change_user/

slide-16
SLIDE 16

Surprise: connect time grows with more users

  • Never noticed when a few apps shared a few

user accounts

  • Noticed slowdown on server with >1000 users

○ Thousands of users is new for me. You?

slide-17
SLIDE 17

Surprise: connect time grows with more users 1

  • Never noticed when a few apps shared a few

user accounts

  • Noticed slowdown on server with >1000 users

○ Thousands of users is new for me. You? ○ https://bugs.mysql.com/bug.php?id=88834

  • Testing showed that slow-down was linear!

○ delay ≅ const_a + (const_b * num_users)

slide-18
SLIDE 18

Why a linear slow-down?

  • acl_users is a list in RAM

○ This is fast and light for most deployments ○ Has been good-enough for years

slide-19
SLIDE 19

Why a linear slow-down? 1

  • acl_users is a list in RAM

○ This is fast and light for most deployments ○ Has been good-enough for years

  • But, list is naively traversed in a few places
slide-20
SLIDE 20

Why a linear slow-down? 2

  • acl_users is a list in RAM

○ This is fast and light for most deployments ○ Has been good-enough for years

  • But, list is naively traversed in a few places

○ 44% time in __strcmp_sse2_unaligned

slide-21
SLIDE 21

Why a linear slow-down? 3

  • acl_users is a list in RAM

○ This is fast and light for most deployments ○ Has been good-enough for years

  • But, list is naively traversed in a few places

○ 44% time in __strcmp_sse2_unaligned

  • Maybe we could use a hashtable?
slide-22
SLIDE 22

Hacking a prototype easy, “for real” was tricky

  • Subtleties in ACL_USER sorting, candidates

○ Anonymous users ○ Wild-cards in hostnames

slide-23
SLIDE 23

Hacking a prototype easy, “for real” was tricky 1

  • Subtleties in ACL_USER sorting, candidates

○ Anonymous users ○ Wild-cards in hostnames

  • unorderd_map<string, list<ACL_USER *>>

○ Custom Memory Allocator for PS ○ Tip: avoid allocator constructor arguments

slide-24
SLIDE 24

Hacking a prototype easy, “for real” was tricky 2

  • Subtleties in ACL_USER sorting, candidates

○ Anonymous users ○ Wild-cards in hostnames

  • unorderd_map<string, list<ACL_USER *>>

○ Custom Memory Allocator for PS ○ Tip: avoid allocator constructor arguments

  • https://github.com/mysql/mysql-server/pull/203
slide-25
SLIDE 25

Together, let’s make the server better!

  • Devs from the whole ecosystem are here:

○ Oracle MySQL ○ MariaDB Server ○ Percona Server ○ Proxies: Vitess, ProxySQL, Spider ○ Individual contributors

  • What are your needs? Let’s talk!
slide-26
SLIDE 26

Questions?

slide-27
SLIDE 27

Thank you