SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
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)
        –




                                      

Más contenido relacionado

La actualidad más candente

Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
Roland Bouman
 

La actualidad más candente (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
 

Similar a 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 Clusters
PerconaPerformance
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
elliando dias
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
MySQLConference
 
Gmr Highload Presentation Revised
Gmr Highload Presentation RevisedGmr Highload Presentation Revised
Gmr Highload Presentation Revised
Ontico
 
Gmr Highload Presentation
Gmr Highload PresentationGmr Highload Presentation
Gmr Highload Presentation
Ontico
 
My sql monitoring cu沙龙
My sql monitoring cu沙龙My sql monitoring cu沙龙
My sql monitoring cu沙龙
colderboy17
 
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
 
High Availability with MySQL
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQL
Thava Alagu
 

Similar a 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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) –