mysql-proxy By Farhad Saberi - Overview and architecture - Making The case for a proxy - Lua - Lua examples - The admin interface - currently.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

Kit Chan ATS Lua Plugin Kit Chan Hi, My name is kit.
Prime’ Senior Project. Presentation Outline What is Our Project? Problem Definition What does our system do? How does the system work? Implementation.
VxWorks Real-Time Kernel Connectivity
Adding scalability to legacy PHP web applications Overview Mario A. Valdez-Ramirez.
Optimized Data Migration within a System of Linked Medical Research Databases By Jared Christopherson U. of Connecticut.
© MMII JW RyderCS 428 Computer Networks1 Mapping Internet to Physical Addresses  2 machines on a physical network can only communicate if they know each.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
What Can You do With BTM? Business Transaction Management touches the following disciplines:  Performance Management  Application Management  Capacity.
A Billiards Point of Sale Application Christopher Ulmer CS 470 Final Presentation.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Web Based Applications
DONE-10: Adminserver Survival Tips Brian Bowman Product Manager, Data Management Group.
Module 8 Configuring and Securing SharePoint Services and Service Applications.
Oracle10g RAC Service Architecture Overview of Real Application Cluster Ready Services, Nodeapps, and User Defined Services.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
Introduction to databases and SQL. What is a database?  A database is an organized way of holding together pieces of information  A database refers.
Samba version What is the Samba? Samba is a suite of programs which work together to allow clients to access to a server's filespace and printers.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
MultiLearn toby Escarez ethan Faust jacob Mrozek ji Mun chris Patterson anirudh Srinivas calder Thami.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Module 11: Implementing ISA Server 2004 Enterprise Edition.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
Templates, Databases and Frameworks. Databases: DBI Common database interface for perl Provides a functional,
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
Graphing and statistics with Cacti AfNOG 11, Kigali/Rwanda.
A Brief Documentation.  Provides basic information about connection, server, and client.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
MySQL Proxy Boston MySQL User Group Monday, September 24th, 2007 Sheeri Kritzer, MySQL DBA Technocation, Inc.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
Grade Book Database Presentation Jeanne Winstead CINS 137.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
MySQL Getting Started BCIS 3680 Enterprise Programming.
MySQL and GRID status Gabriele Carcassi 9 September 2002.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
January 9, 2001 Router Plugins (Crossbow) 1 Washington WASHINGTON UNIVERSITY IN ST LOUIS Exercises.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
LINUXCHIX WEBMAIL. Software run by an ISP or online service that provides access to send, receive, and review using only your Web browser. Users.
MySQL Getting Started BCIS 3680 Enterprise Programming.
Ch. 23, 25 Q and A (NAT and UDP) Victor Norman IS333 Spring 2015.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Monitoring Dynamic IOC Installations Using the alive Record Dohn Arms Beamline Controls & Data Acquisition Group Advanced Photon Source.
EGI-InSPIRE RI Pakiti Michal Prochazka, (Daniel Kouril)
MySQL HA An overview Kris Buytaert. ● Senior Linux and Open Source ● „Infrastructure Architect“ ● I don't remember when I started.
CIS Host Manager Bryce Johnston CIS 597 May 8, 2009.
Databases and DBMSs Todd S. Bacastow January 2005.
Jean-Philippe Baud, IT-GD, CERN November 2007
Affinity Depending on the application and client requirements of your Network Load Balancing cluster, you can be required to select an Affinity setting.
Web Development Web Servers.
PHP / MySQL Introduction
DUCKS – Distributed User-mode Chirp-Knowledgeable Server
ISC440: Web Programming 2 Server-side Scripting PHP 3
Data, Databases, and DBMSs
Lecture 1: Multi-tier Architecture Overview
Chapter 2: Operating-System Structures
Chapter 2: Operating-System Structures
Web Application Development Using PHP
Presentation transcript:

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:

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

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

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

Lua examples For any query issued, this will be the result: mysql> show tables; # or anything else | message from DBA | | maintenance |

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

Lua example Running any query that would match “from%s+.* my_table” will return ERROR 1105 (07000): access denied to table my_table

Lua example Some other things you can do: Start/stop mysqld backend. Choose your backend DB based on which IP address, or which mysql user the client has. Modify result set by adding or removing a column from the returned table. Time your queries. Gather statistics. Your limits are that of the Lua language.

The admin interface You can monitor and show internal structures of the running mysql-proxy process by programming your own admin interface in Lua. Start mysql-proxy with admin options: --admin-address= : admin-username=root –admin-password=password --admin-lua-script=/mysql-proxy/share/admin/admin.lua

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 … Now build proxy.response and return with proxy.PROXY_SEND_RESULT

The admin interface Querying the previously Lua coded interface will return: mysql>msyql -u root -ppassword -h P mysql> ls; | backend_ndx | address | connected_clients | | 1 | :3309 | 23 | | 2 | :3309 | 142 |

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. A bit complicated. Everything has to be coded by you. You need to know Lua well. (not a bad thing though)