SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
MySQL Proxy



    Making MySQL more flexible
          Jan Kneschke
         jan@mysql.com



                 
MySQL Proxy
        proxy­servers forward requests to backends 
    ●



        and can
            transform, handle or block them
        –


        released under the GPL
    ●



            see http://forge.mysql.com/wiki/MySQL_Proxy
        –


        developed as part of the Enterprise Tools since 
    ●



        February 2007
                                   
Design Decisions
        goal is to be transparent to the application layer
    ●




        supports all platforms and languages
    ●




        designed to handle thousands of parallel 
    ●



        connections (c10k)
        uses a embedded scripting language for 
    ●



        customizations


                                
Transparency
        SHOW WARNINGS can be worked around with 
    ●



        Query Injection
        SELECT USER() shows the connected user 
    ●



        (the proxy, not the client) which can be 
        corrected with result­set rewriting
        host auth against the MySQL server
    ●




                              
Latency
        early tests via localhost
    ●




        same script run directly and through the proxy
    ●




        latency per mysql­packet: 0.4ms
    ●




        ping RTT on 1Gbit: 0.1ms
    ●




                                 
Load Balancing
        load balancing distributes the load across 
    ●



        several slaves
        Shortest Queue First is default
    ●



            send new connections to the server with the least 
        –

            number of open connections




                                    
Fail Over
        dead host are detected
    ●




        taking out of load balancing for 2min
    ●




        uses custom load balancers to decide how to 
    ●



        handle a dead host
            hot + standby
        –

            uses load balancing
        –




                                   
Removing SPoF
        one Proxy == Single Point of Failure
    ●




        use external Heartbeat (linuxha.org) or
    ●




        2 LB proxies + 1 Host Selecting Proxy per 
    ●



        application server




                               
Failsafe Load Balancing




                
Flexibility
        proxy embeds LUA 
    ●




        allows analyzing and manipulating packets 
    ●



            Inspection
        –

            Rewriting
        –

            Blocking
        –

            Injection
        –




                               
LUA
        PiL http://lua.org/manual/5.1/
    ●




        embedded, simple, efficient
    ●




        can do OO­like programming
    ●




        has scalars, tables, metatables and anonymous 
    ●



        functions



                                
Query Rewriting
        Macro Packages (ls, cd, who, ...)
    ●




        tagging queries with SQL_CACHE
    ●




        migrating table­names and SQL dialects
    ●




        turn EXPLAIN UPDATE|DELETE  into 
    ●



        equivalent EXPLAIN SELECT



                              
Query Profiling
        SHOW SESSION STATUS around a Query
    ●



    Exec_time: 6749 us
    .. Handler_read_rnd_next = 252
    .. Handler_write = 252
    .. Select_scan = 1




                          
Query Statistics
        Normalize Queries to track query usage
    ●




        Count Table and Index usage
    ●




        Optimize Query Cache Usage by injecting 
    ●



        SQL_CACHE in cachable queries
        see lib/analyze­queries.lua
    ●




                              
Auditing
        Diagnostic Auditing
    ●




        track which user+ip run which query or 
    ●



        accessed which objects when
        assign query­costs
    ●




        log gathered information in a central place
    ●




        see lib/auditing.lua
    ●




                                
Global Transaction ID
        Inject a counter in all transactions
    ●




        Answers questions like
    ●



            which slave is most current
        –

            can I read from this slave, or do I have to read from 
        –

            master
            you name it
        –




                                     
Connection Pooling
        reusing open connections between proxy and 
    ●



        server
        reduces concurrency on the MySQL Server
    ●




        external connection pool for PHP
    ●




                               
Statement Routing
        split the query stream into reading and writing
    ●



            READs go to the slaves
        –

            WRITEs and transactions to the master
        –


        automatic scale­out
    ●




        sharding
    ●




                                      
Tokenizer
        turns a SQL query into a token stream
    ●




        not a full parser, just a tokenizer for speed 
    ●



        reasons
        understands KEYWORDS, /*comments*/, 
    ●



        “strings”, 123 and `literals`
        later we'll add support for SQL modes
    ●




                                 
normalizing Queries

    1:  { TK_SQL_SELECT, select }
    2:  { TK_STAR, * }
    3:  { TK_SQL_FROM, from }
    4:  { TK_LITERAL, t1 }
    5:  { TK_SQL_WHERE, where }
    6:  { TK_LITERAL, id }
    7:  { TK_EQ, = }
    8:  { TK_INTEGER, 1 }
    normalized query: SELECT * FROM `t1` WHERE 
    `id` = ? 



                            
Libraries
        auto­config                      parser
    ●                                ●



            SET GLOBAL ...                   extract tablenames
        –                                –


        balance                          tokenizer
    ●                                ●



            load balancers                   normalize()
        –                                –

                                             cleanup queries
        commands                         –
    ●



            parse MySQL 
        –

            Command Packets
                                  
Internals – LUA scripting
        proxy.* is the namespace
    ●




        proxy.connection.* is the current 
    ●



        connection
        proxy.backends[...] are the backends
    ●




        proxy.global.* is the global table
    ●




        proxy.global.config.* is used for the 
    ●



        config
                             
Internals ­ Scope
        Each connection has its own script scope
    ●




        proxy.global.* to share data between 
    ●



        connections
        use local to make variables local to the 
    ●



        function
        use package.seeall() to export functions 
    ●



        from modules
                               
Internals ­ Threading
        the global scope and threading don't play nice 
    ●



        by default
        http://www.cs.princeton.edu/~diego/professional/lua
    ●




        patches lua to apply mutexes around variable 
    ●



        access




                               
Internals – Script Cache
        0.6.0 we reload the script on each connection 
    ●



        start
        adding a script cache with mtime check
    ●




        lua_pushvalue(L, ­1) does the trick
    ●




                               
Roadmap
        to be released 0.6.0
    ●



            tokenizer
        –

            read­write splitting
        –

            Query Statistics
        –


        later
    ●



            parallel Queries
        –

            proxy initiates connections
        –

                                    
LUA ­ Gotchas
        only false and nil are !true, 0 is true
    ●




        to say “not equal” you use ~=
    ●




        there are no shortcuts
    ●



            no a++, no a *= 4, ...
        –

            no a > b ? a : b (there is “(a > b) and a or b)
        –




                                      

Contenu connexe

Tendances

Upgrading oracle db 11.2.0.1 to 11.2.0.3
Upgrading oracle db 11.2.0.1 to 11.2.0.3Upgrading oracle db 11.2.0.1 to 11.2.0.3
Upgrading oracle db 11.2.0.1 to 11.2.0.3Ravi Kumar Lanke
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18Derek Downey
 
Percona live 2021 Practical Database Automation with Ansible
Percona live 2021 Practical Database Automation with Ansible Percona live 2021 Practical Database Automation with Ansible
Percona live 2021 Practical Database Automation with Ansible Derek Downey
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database DeploymentsMike Willbanks
 
Fortify aws aurora_proxy
Fortify aws aurora_proxyFortify aws aurora_proxy
Fortify aws aurora_proxyMarco Tusa
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Introduction to Spring Cloud Kubernetes (July 4th, 2019)
Introduction to Spring Cloud Kubernetes (July 4th, 2019)Introduction to Spring Cloud Kubernetes (July 4th, 2019)
Introduction to Spring Cloud Kubernetes (July 4th, 2019)Alexandre Roman
 
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...Frederic Descamps
 
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012Scott Sutherland
 
Habits of Effective Sqoop Users
Habits of Effective Sqoop UsersHabits of Effective Sqoop Users
Habits of Effective Sqoop UsersKathleen Ting
 
Performance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cPerformance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cAjith Narayanan
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageSteven Feuerstein
 
Apache Kafka® Security Overview
Apache Kafka® Security OverviewApache Kafka® Security Overview
Apache Kafka® Security Overviewconfluent
 
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)Scott Sutherland
 
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial EmulationScott Sutherland
 

Tendances (18)

Upgrading oracle db 11.2.0.1 to 11.2.0.3
Upgrading oracle db 11.2.0.1 to 11.2.0.3Upgrading oracle db 11.2.0.1 to 11.2.0.3
Upgrading oracle db 11.2.0.1 to 11.2.0.3
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
 
Percona live 2021 Practical Database Automation with Ansible
Percona live 2021 Practical Database Automation with Ansible Percona live 2021 Practical Database Automation with Ansible
Percona live 2021 Practical Database Automation with Ansible
 
PPT
PPTPPT
PPT
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Fortify aws aurora_proxy
Fortify aws aurora_proxyFortify aws aurora_proxy
Fortify aws aurora_proxy
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Spring Mvc Rest
Spring Mvc RestSpring Mvc Rest
Spring Mvc Rest
 
Introduction to Spring Cloud Kubernetes (July 4th, 2019)
Introduction to Spring Cloud Kubernetes (July 4th, 2019)Introduction to Spring Cloud Kubernetes (July 4th, 2019)
Introduction to Spring Cloud Kubernetes (July 4th, 2019)
 
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
OpenWorld 2014 - Schema Management: versioning and automation with Puppet and...
 
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
SQL Server Exploitation, Escalation, Pilfering - AppSec USA 2012
 
Apache servicemix1
Apache servicemix1Apache servicemix1
Apache servicemix1
 
Habits of Effective Sqoop Users
Habits of Effective Sqoop UsersHabits of Effective Sqoop Users
Habits of Effective Sqoop Users
 
Performance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12cPerformance Tuning Oracle Weblogic Server 12c
Performance Tuning Oracle Weblogic Server 12c
 
New Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL LanguageNew Stuff in the Oracle PL/SQL Language
New Stuff in the Oracle PL/SQL Language
 
Apache Kafka® Security Overview
Apache Kafka® Security OverviewApache Kafka® Security Overview
Apache Kafka® Security Overview
 
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
 
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
2017 Q1 Arcticcon - Meet Up - Adventures in Adversarial Emulation
 

Similaire à MySQL Proxy

Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication ClustersPerconaPerformance
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppetelliando dias
 
My Sql Proxy
My Sql ProxyMy Sql Proxy
My Sql ProxyLiu Lizhi
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
Gmr Highload Presentation Revised
Gmr Highload Presentation RevisedGmr Highload Presentation Revised
Gmr Highload Presentation RevisedOntico
 
Gmr Highload Presentation
Gmr Highload PresentationGmr Highload Presentation
Gmr Highload PresentationOntico
 
My sql monitoring cu沙龙
My sql monitoring cu沙龙My sql monitoring cu沙龙
My sql monitoring cu沙龙colderboy17
 
YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)rgiersig
 
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...phpbarcelona
 
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...Timofey Turenko
 
High Availability with MySQL
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQLThava Alagu
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debeziumKasun Don
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 

Similaire à MySQL Proxy (20)

Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication Clusters
 
MySQL Proxy tutorial
MySQL Proxy tutorialMySQL Proxy tutorial
MySQL Proxy tutorial
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
 
Capistrano
CapistranoCapistrano
Capistrano
 
My Sql Proxy
My Sql ProxyMy Sql Proxy
My Sql Proxy
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Gmr Highload Presentation Revised
Gmr Highload Presentation RevisedGmr Highload Presentation Revised
Gmr Highload Presentation Revised
 
Gmr Highload Presentation
Gmr Highload PresentationGmr Highload Presentation
Gmr Highload Presentation
 
My sql monitoring cu沙龙
My sql monitoring cu沙龙My sql monitoring cu沙龙
My sql monitoring cu沙龙
 
YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)YAPC2007 Remote System Monitoring (w. Notes)
YAPC2007 Remote System Monitoring (w. Notes)
 
Download It
Download ItDownload It
Download It
 
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...
Text indexing and search libraries for PHP - Zoë Slattery - Barcelona PHP Con...
 
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
 
Capistrano2
Capistrano2Capistrano2
Capistrano2
 
High Availability with MySQL
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQL
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Conflict Resolution In Kai
Conflict Resolution In KaiConflict Resolution In Kai
Conflict Resolution In Kai
 

Dernier

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Dernier (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

MySQL Proxy

  • 1. MySQL Proxy Making MySQL more flexible Jan Kneschke jan@mysql.com    
  • 2. MySQL Proxy proxy­servers forward requests to backends  ● and can transform, handle or block them – released under the GPL ● see http://forge.mysql.com/wiki/MySQL_Proxy – developed as part of the Enterprise Tools since  ● February 2007    
  • 3. Design Decisions goal is to be transparent to the application layer ● supports all platforms and languages ● designed to handle thousands of parallel  ● connections (c10k) uses a embedded scripting language for  ● customizations    
  • 4. Transparency SHOW WARNINGS can be worked around with  ● Query Injection SELECT USER() shows the connected user  ● (the proxy, not the client) which can be  corrected with result­set rewriting host auth against the MySQL server ●    
  • 5. Latency early tests via localhost ● same script run directly and through the proxy ● latency per mysql­packet: 0.4ms ● ping RTT on 1Gbit: 0.1ms ●    
  • 6. Load Balancing load balancing distributes the load across  ● several slaves Shortest Queue First is default ● send new connections to the server with the least  – number of open connections    
  • 7. Fail Over dead host are detected ● taking out of load balancing for 2min ● uses custom load balancers to decide how to  ● handle a dead host hot + standby – uses load balancing –    
  • 8. Removing SPoF one Proxy == Single Point of Failure ● use external Heartbeat (linuxha.org) or ● 2 LB proxies + 1 Host Selecting Proxy per  ● application server    
  • 10. Flexibility proxy embeds LUA  ● allows analyzing and manipulating packets  ● Inspection – Rewriting – Blocking – Injection –    
  • 11. LUA PiL http://lua.org/manual/5.1/ ● embedded, simple, efficient ● can do OO­like programming ● has scalars, tables, metatables and anonymous  ● functions    
  • 12. Query Rewriting Macro Packages (ls, cd, who, ...) ● tagging queries with SQL_CACHE ● migrating table­names and SQL dialects ● turn EXPLAIN UPDATE|DELETE  into  ● equivalent EXPLAIN SELECT    
  • 13. Query Profiling SHOW SESSION STATUS around a Query ● Exec_time: 6749 us .. Handler_read_rnd_next = 252 .. Handler_write = 252 .. Select_scan = 1    
  • 14. Query Statistics Normalize Queries to track query usage ● Count Table and Index usage ● Optimize Query Cache Usage by injecting  ● SQL_CACHE in cachable queries see lib/analyze­queries.lua ●    
  • 15. Auditing Diagnostic Auditing ● track which user+ip run which query or  ● accessed which objects when assign query­costs ● log gathered information in a central place ● see lib/auditing.lua ●    
  • 16. Global Transaction ID Inject a counter in all transactions ● Answers questions like ● which slave is most current – can I read from this slave, or do I have to read from  – master you name it –    
  • 17. Connection Pooling reusing open connections between proxy and  ● server reduces concurrency on the MySQL Server ● external connection pool for PHP ●    
  • 18. Statement Routing split the query stream into reading and writing ● READs go to the slaves – WRITEs and transactions to the master – automatic scale­out ● sharding ●    
  • 19. Tokenizer turns a SQL query into a token stream ● not a full parser, just a tokenizer for speed  ● reasons understands KEYWORDS, /*comments*/,  ● “strings”, 123 and `literals` later we'll add support for SQL modes ●    
  • 20. normalizing Queries 1:  { TK_SQL_SELECT, select } 2:  { TK_STAR, * } 3:  { TK_SQL_FROM, from } 4:  { TK_LITERAL, t1 } 5:  { TK_SQL_WHERE, where } 6:  { TK_LITERAL, id } 7:  { TK_EQ, = } 8:  { TK_INTEGER, 1 } normalized query: SELECT * FROM `t1` WHERE  `id` = ?     
  • 21. Libraries auto­config parser ● ● SET GLOBAL ...  extract tablenames – – balance tokenizer ● ● load balancers normalize() – – cleanup queries commands – ● parse MySQL  – Command Packets    
  • 22. Internals – LUA scripting proxy.* is the namespace ● proxy.connection.* is the current  ● connection proxy.backends[...] are the backends ● proxy.global.* is the global table ● proxy.global.config.* is used for the  ● config    
  • 23. Internals ­ Scope Each connection has its own script scope ● proxy.global.* to share data between  ● connections use local to make variables local to the  ● function use package.seeall() to export functions  ● from modules    
  • 24. Internals ­ Threading the global scope and threading don't play nice  ● by default http://www.cs.princeton.edu/~diego/professional/lua ● patches lua to apply mutexes around variable  ● access    
  • 25. Internals – Script Cache 0.6.0 we reload the script on each connection  ● start adding a script cache with mtime check ● lua_pushvalue(L, ­1) does the trick ●    
  • 26. Roadmap to be released 0.6.0 ● tokenizer – read­write splitting – Query Statistics – later ● parallel Queries – proxy initiates connections –    
  • 27. LUA ­ Gotchas only false and nil are !true, 0 is true ● to say “not equal” you use ~= ● there are no shortcuts ● no a++, no a *= 4, ... – no a > b ? a : b (there is “(a > b) and a or b) –