SlideShare a Scribd company logo
LSPE @Yahoo mysql-proxy By Farhad Saberi - Overview and architecture - Making The case for a proxy - Lua - Lua examples - The admin interface - currently known issues
Overview and Architecture Same idea as any other proxy. Sits between the application and its Database:
Overview and Arhitecture Read only Load Balancing with multiple –proxy-read-only-backend-addresses option
Making The case for mysql-proxy Easier sites management.  Hundreds of connection definitions use the same host and port. DB Host connection changes are done at one place only.
No need to restart for configuration or behavioral changes. It all happens in real time.
Making the case for mysql-proxy Flexible, Powerful and invisible: intercept, tokenize and modify queries
Deny/allow queries based on DB or DB User.
Deny/allow based on a regex
Construct your own results set and return it to the application without ever actually querying the backend database.
LUA embedded
Making the case for a proxy It's fast and stable: Small daemon, about 35 MB in VSZ compared to a preforked apache child being 50 to 100 MB.
Coded in C
implements connection pooling
Doesn't need to do NS lookups every time
Has never “crashed” on me so far!
Making the case for mysql-proxy Open source.
LUA Simple scripting language
Small: its whole distribution fits in a floppy disk.
Extensible; it is easy to interface with C code.
LUA Widely used in games:
Ad

More Related Content

What's hot (18)

Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
Anirban Sen Chowdhary
 
My sql administration
My sql administrationMy sql administration
My sql administration
Mohd yasin Karim
 
SQL – A Tutorial I
SQL – A Tutorial  ISQL – A Tutorial  I
SQL – A Tutorial I
Gagan Deep
 
Mule xml parsing
Mule xml parsingMule xml parsing
Mule xml parsing
Muralidhar Gumma
 
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
 
PPT
PPTPPT
PPT
webhostingguy
 
MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher MuleSoft ESB Message Enricher
MuleSoft ESB Message Enricher
akashdprajapati
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
Jalpesh Vasa
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
Computer Hardware & Trouble shooting
 
Compress and decompress
Compress and decompressCompress and decompress
Compress and decompress
Son Nguyen
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
AnilKumar Etagowni
 
Advance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.ServletAdvance Java Programming (CM5I) 6.Servlet
Advance Java Programming (CM5I) 6.Servlet
Payal Dungarwal
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64
akashdprajapati
 
Python (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network AutomationPython (Jinja2) Templates for Network Automation
Python (Jinja2) Templates for Network Automation
Rick Sherman
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite Database
ElangovanTechNotesET
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
Mohammed246
 
Mule xml parsing
Mule xml parsingMule xml parsing
Mule xml parsing
Santhosh Ramagiri
 

Viewers also liked (6)

Website Development
Website DevelopmentWebsite Development
Website Development
8i Creations
 
Mysql proxy presentation_yahoo
Mysql proxy presentation_yahooMysql proxy presentation_yahoo
Mysql proxy presentation_yahoo
Chris Westin
 
Deportes extremos
Deportes extremosDeportes extremos
Deportes extremos
urbinaf creativa
 
mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012
Chris Westin
 
eCommerce Development
eCommerce DevelopmenteCommerce Development
eCommerce Development
8i Creations
 
Website Development
Website DevelopmentWebsite Development
Website Development
8i Creations
 
Mysql proxy presentation_yahoo
Mysql proxy presentation_yahooMysql proxy presentation_yahoo
Mysql proxy presentation_yahoo
Chris Westin
 
mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012
Chris Westin
 
eCommerce Development
eCommerce DevelopmenteCommerce Development
eCommerce Development
8i Creations
 
Ad

Similar to Mysql Proxy Presentation Yahoo (20)

PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
Firdaus Adib
 
MySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuse
weigon
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
elliando dias
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
Kasun Don
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
Derek Downey
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
Michael Renner
 
Scripts Python Dbapi
Scripts Python DbapiScripts Python Dbapi
Scripts Python Dbapi
AkramWaseem
 
Oracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLinkOracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLink
Osama Mustafa
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Ulf Wendel
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
Frederic Descamps
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
Dave Stokes
 
Mysql connection
Mysql connectionMysql connection
Mysql connection
beben benzy
 
Multiple instances second method
Multiple instances second methodMultiple instances second method
Multiple instances second method
Vasudeva Rao
 
Database Connectivity using Python and MySQL
Database Connectivity using Python and MySQLDatabase Connectivity using Python and MySQL
Database Connectivity using Python and MySQL
devsuchaye
 
20141011 mastering mysqlnd
20141011 mastering mysqlnd20141011 mastering mysqlnd
20141011 mastering mysqlnd
do_aki
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
oazabir
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
Dave Stokes
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connect
confluent
 
Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1
AkramWaseem
 
PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
Firdaus Adib
 
MySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuse
weigon
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
elliando dias
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
Kasun Don
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
Derek Downey
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
Michael Renner
 
Scripts Python Dbapi
Scripts Python DbapiScripts Python Dbapi
Scripts Python Dbapi
AkramWaseem
 
Oracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLinkOracle to MySQL DatabaseLink
Oracle to MySQL DatabaseLink
Osama Mustafa
 
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Ulf Wendel
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
Frederic Descamps
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
Dave Stokes
 
Mysql connection
Mysql connectionMysql connection
Mysql connection
beben benzy
 
Multiple instances second method
Multiple instances second methodMultiple instances second method
Multiple instances second method
Vasudeva Rao
 
Database Connectivity using Python and MySQL
Database Connectivity using Python and MySQLDatabase Connectivity using Python and MySQL
Database Connectivity using Python and MySQL
devsuchaye
 
20141011 mastering mysqlnd
20141011 mastering mysqlnd20141011 mastering mysqlnd
20141011 mastering mysqlnd
do_aki
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
oazabir
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
Dave Stokes
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connect
confluent
 
Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1Www Kitebird Com Articles Pydbapi Html Toc 1
Www Kitebird Com Articles Pydbapi Html Toc 1
AkramWaseem
 
Ad

More from Chris Westin (20)

Data torrent meetup-productioneng
Data torrent meetup-productionengData torrent meetup-productioneng
Data torrent meetup-productioneng
Chris Westin
 
Gripshort
GripshortGripshort
Gripshort
Chris Westin
 
Ambari hadoop-ops-meetup-2013-09-19.final
Ambari hadoop-ops-meetup-2013-09-19.finalAmbari hadoop-ops-meetup-2013-09-19.final
Ambari hadoop-ops-meetup-2013-09-19.final
Chris Westin
 
Cluster management and automation with cloudera manager
Cluster management and automation with cloudera managerCluster management and automation with cloudera manager
Cluster management and automation with cloudera manager
Chris Westin
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcache
Chris Westin
 
SDN/OpenFlow #lspe
SDN/OpenFlow #lspeSDN/OpenFlow #lspe
SDN/OpenFlow #lspe
Chris Westin
 
cfengine3 at #lspe
cfengine3 at #lspecfengine3 at #lspe
cfengine3 at #lspe
Chris Westin
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012
Chris Westin
 
Nimbula lspe-2012-04-19
Nimbula lspe-2012-04-19Nimbula lspe-2012-04-19
Nimbula lspe-2012-04-19
Chris Westin
 
Stingray - Riverbed Technology
Stingray - Riverbed TechnologyStingray - Riverbed Technology
Stingray - Riverbed Technology
Chris Westin
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
Chris Westin
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
Chris Westin
 
Architecting a Scale Out Cloud Storage Solution
Architecting a Scale Out Cloud Storage SolutionArchitecting a Scale Out Cloud Storage Solution
Architecting a Scale Out Cloud Storage Solution
Chris Westin
 
FlashCache
FlashCacheFlashCache
FlashCache
Chris Westin
 
Large Scale Cacti
Large Scale CactiLarge Scale Cacti
Large Scale Cacti
Chris Westin
 
MongoDB: An Introduction - July 2011
MongoDB:  An Introduction - July 2011MongoDB:  An Introduction - July 2011
MongoDB: An Introduction - July 2011
Chris Westin
 
Practical Replication June-2011
Practical Replication June-2011Practical Replication June-2011
Practical Replication June-2011
Chris Westin
 
MongoDB: An Introduction - june-2011
MongoDB:  An Introduction - june-2011MongoDB:  An Introduction - june-2011
MongoDB: An Introduction - june-2011
Chris Westin
 
Ganglia Overview-v2
Ganglia Overview-v2Ganglia Overview-v2
Ganglia Overview-v2
Chris Westin
 
MongoDB Aggregation MongoSF May 2011
MongoDB Aggregation MongoSF May 2011MongoDB Aggregation MongoSF May 2011
MongoDB Aggregation MongoSF May 2011
Chris Westin
 
Data torrent meetup-productioneng
Data torrent meetup-productionengData torrent meetup-productioneng
Data torrent meetup-productioneng
Chris Westin
 
Ambari hadoop-ops-meetup-2013-09-19.final
Ambari hadoop-ops-meetup-2013-09-19.finalAmbari hadoop-ops-meetup-2013-09-19.final
Ambari hadoop-ops-meetup-2013-09-19.final
Chris Westin
 
Cluster management and automation with cloudera manager
Cluster management and automation with cloudera managerCluster management and automation with cloudera manager
Cluster management and automation with cloudera manager
Chris Westin
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcache
Chris Westin
 
SDN/OpenFlow #lspe
SDN/OpenFlow #lspeSDN/OpenFlow #lspe
SDN/OpenFlow #lspe
Chris Westin
 
cfengine3 at #lspe
cfengine3 at #lspecfengine3 at #lspe
cfengine3 at #lspe
Chris Westin
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012
Chris Westin
 
Nimbula lspe-2012-04-19
Nimbula lspe-2012-04-19Nimbula lspe-2012-04-19
Nimbula lspe-2012-04-19
Chris Westin
 
Stingray - Riverbed Technology
Stingray - Riverbed TechnologyStingray - Riverbed Technology
Stingray - Riverbed Technology
Chris Westin
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
Chris Westin
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
Chris Westin
 
Architecting a Scale Out Cloud Storage Solution
Architecting a Scale Out Cloud Storage SolutionArchitecting a Scale Out Cloud Storage Solution
Architecting a Scale Out Cloud Storage Solution
Chris Westin
 
MongoDB: An Introduction - July 2011
MongoDB:  An Introduction - July 2011MongoDB:  An Introduction - July 2011
MongoDB: An Introduction - July 2011
Chris Westin
 
Practical Replication June-2011
Practical Replication June-2011Practical Replication June-2011
Practical Replication June-2011
Chris Westin
 
MongoDB: An Introduction - june-2011
MongoDB:  An Introduction - june-2011MongoDB:  An Introduction - june-2011
MongoDB: An Introduction - june-2011
Chris Westin
 
Ganglia Overview-v2
Ganglia Overview-v2Ganglia Overview-v2
Ganglia Overview-v2
Chris Westin
 
MongoDB Aggregation MongoSF May 2011
MongoDB Aggregation MongoSF May 2011MongoDB Aggregation MongoSF May 2011
MongoDB Aggregation MongoSF May 2011
Chris Westin
 

Mysql Proxy Presentation Yahoo

  • 1. LSPE @Yahoo mysql-proxy By Farhad Saberi - Overview and architecture - Making The case for a proxy - Lua - Lua examples - The admin interface - currently known issues
  • 2. Overview and Architecture Same idea as any other proxy. Sits between the application and its Database:
  • 3. Overview and Arhitecture Read only Load Balancing with multiple –proxy-read-only-backend-addresses option
  • 4. Making The case for mysql-proxy Easier sites management. Hundreds of connection definitions use the same host and port. DB Host connection changes are done at one place only.
  • 5. No need to restart for configuration or behavioral changes. It all happens in real time.
  • 6. Making the case for mysql-proxy Flexible, Powerful and invisible: intercept, tokenize and modify queries
  • 7. Deny/allow queries based on DB or DB User.
  • 9. Construct your own results set and return it to the application without ever actually querying the backend database.
  • 11. Making the case for a proxy It's fast and stable: Small daemon, about 35 MB in VSZ compared to a preforked apache child being 50 to 100 MB.
  • 14. Doesn't need to do NS lookups every time
  • 15. Has never “crashed” on me so far!
  • 16. Making the case for mysql-proxy Open source.
  • 18. Small: its whole distribution fits in a floppy disk.
  • 19. Extensible; it is easy to interface with C code.
  • 20. LUA Widely used in games:
  • 21. LUA Mysql-proxy is the application code and Lua is its extension language . You change a running mysql-proxy's behavior and variables in a single Lua script in real time (no restart required).
  • 22. Lua examples Mysql-proxy starts with – proxy-backend-addresses=db1.host.net, db2.host.net, db3.host.net Choose your backend in connect_server() Function connect_server() proxy.connection.backend_ndx= 2 End And you will always connect to db2.host.net. If you change 2 to 3, you will always connect to db3. Note: Lua's array starts at 1, !0
  • 23. Lua examples Deny all queries to any backend DB: function read_query(packet) if string.byte(packet) == proxy.COM_QUERY then local fields = { } local rows = { } fields = { { name = “ message from DBA ”, type =proxy.MYSQL_TYPE_STRING}, } rows[1] = { “ maintenance ”} proxy.respose = { type = proxy.MYSQLD_PACKET_OK, resultset = { fields = fields, rows = rows } } return proxy.PROXY_SEND_RESULT –means bypass backend, return to client now end end
  • 24. Lua examples For any query issued, this will be the result: mysql> show tables; # or anything else +--------------------------+ | message from DBA | +--------------------------+ | maintenance | +---------------------------+
  • 25. Lua example denying access to just one table using a regex. Return mysql error msg to client. Function read_query(packet) if packet:byte() == proxy.COM_QUERY then local query= packet:sub(2) print (“query: “ .. query ) – debugging purpose if string.match(query:lower(), “ from%s+.*my_table ” ) then proxy.response.type = proxy.MYSQLD_PACKET_ERR proxy.response.errmsg = “ access denied to table my_table ” return proxy.PROXY_SEND_RESULT end end end
  • 26. Lua example Running any query that would match “from%s+.* my_table” will return ERROR 1105 (07000): access denied to table my_table
  • 27. Lua example Some other things you can do: Start/stop mysqld backend.
  • 28. Choose your backend DB based on which IP address, or which mysql user the client has.
  • 29. Modify result set by adding or removing a column from the returned table.
  • 30. Time your queries. Gather statistics.
  • 31. Your limits are that of the Lua language.
  • 32. The admin interface You can monitor and show internal structures of the running mysql-proxy process by programming your own admin interface in Lua.
  • 33. Start mysql-proxy with admin options:
  • 38. The admin interface Function read_query(packet) If packet:byte() ~= proxy.COM_QUERY then return_error(“ [admin] we only handle COM_QUERY ”); --user defined end Local rows = { } local fields = { } – no need for a semicolon in Lua if packet:sub(2) == “ls” then – if query is an ls fields = { { name = “ backend_ndx ”, type = proxy.MYSQL_TYPE_LONG }, { name = “ address ” , type = proxy.MYSQL_TYPE_STRING } , { name = “ connected_clients ”, type = proxy.MYSQL_TYPE_LONG}, } for i = 1 , #proxy.global.backends do Local b = proxy.global.backends[i] rows[#rows + 1 ] = { i, b.dst.name, b.connected_clients } end end … Now build proxy.response and return with proxy.PROXY_SEND_RESULT
  • 39. The admin interface Querying the previously Lua coded interface will return: mysql>msyql -u root -ppassword -h 127.0.0.1 -P 10008 mysql> ls; +------------------+--------------------------+-------------------------+ | backend_ndx | address | connected_clients | +------------------+--------------------------+-------------------------+ | 1 | 192.168.1.9:3309 | 23 | +------------------+--------------------------+-------------------------+ | 2 | 192.168.1.10:3309 | 142 | +------------------+--------------------------+-------------------------+
  • 40. Currently known issues Read/Write splitting does not work if used by more than one client on the same proxy process. This is a known issue and I'm assuming it is being worked on.
  • 41. A bit complicated. Everything has to be coded by you.
  • 42. You need to know Lua well. (not a bad thing though)