DBSlayer beta-10

DBSlayer is a lightweight database abstraction layer suitable for high-load websites.
DBSlayer also know as Sl鋣er (as we like to call it when we're feeling ironically heavy metal) is a lightweight database abstraction layer suitable for high-load websites where you need the scalable advantages of connection pooling. Written in C for speed, DBSlayer talks to clients via JSON over HTTP, meaning it's simple to monitor and can swiftly interoperate with any web framework you choose.

The DBSlayer originated as an internal tool at the New York Times. The typical LAMP strategy for scaling up data-driven applications is to replicate slave databases to every web server, but this approach can hit scaling limitations for high-volume websites, where processes can overwhelm their given backend DB's connection limits. Quite frankly, we wanted to scale the front-end webservers and backend database servers separately without having to coordinate them. We also needed a way to flexibly reconfigure where our backend databases were located and which applications used them without resorting to tricks of DNS or other such "load-balancing" hacks. Plus, it just seemed really cool to have a JSON-speaking DB layer that all our scriptable content could talk to. Thus, the DBSlayer was born.

Here are some key features of "DBSlayer":

路 Simple HTTP interface
路 JSON-format messages
路 MySQL adapter (others possible in the future)
路 Connection pooling
路 Multithreaded
路 Round-robin distribution of queries to slave instances
路 Automatic failover to alternate databases
路 Straight-forward configuration
路 Simple yet powerful codebase.

Example Usage:

Starting the DBSlayer is as simple as pointing the DBSlayer at your mysql.cnf file with a few command-line options:
dbslayer -c /path/to/mysql.cnf -s servername

This starts up a DBSlayer daemon on 9090 (this default port can be changed) which acts as a proxy for the backend MySQL server. This proxy can then be queried via JSON over HTTP. Here is a query against one of the standard MySQL test databases:

select ci.* from City ci, Country c where c.name = 'United States' and c.code = ci.CountryCode order by Population desc limit 10;

http://localhost:9090/db?{"SQL":"select ci.* from City ci, Country c where c.name = 'United States' and c.code = ci.CountryCode order by Population desc limit 10;"}

HTTP/1.0 200 OK
Date: Wed, 27 Jun 2007 20:55:59 GMT
Server: dbslayer/server beta-9
Connection: Close
Content-type: text/plain; charset=utf-8
Content-Length: 746

{"RESULT" : {"TYPES" : ["MYSQL_TYPE_LONG" , "MYSQL_TYPE_STRING" , "MYSQL_TYPE_STRING" , "MYSQL_TYPE_STRING" , "MYSQL_TYPE_LONG"] ,
"HEADER" : ["ID" , "Name" , "CountryCode" , "District" , "Population"] ,
"ROWS" : [[3793 , "New York" , "USA" , "New York" , 8008278] ,
[3794 , "Los Angeles" , "USA" , "California" , 3694820] ,
[3795 , "Chicago" , "USA" , "Illinois" , 2896016] ,
[3796 , "Houston" , "USA" , "Texas" , 1953631] ,
[3797 , "Philadelphia" , "USA" , "Pennsylvania" , 1517550] ,
[3798 , "Phoenix" , "USA" , "Arizona" , 1321045] ,
[3799 , "San Diego" , "USA" , "California" , 1223400] ,
[3800 , "Dallas" , "USA" , "Texas" , 1188580] ,
[3801 , "San Antonio" , "USA" , "Texas" , 1144646] ,
[3802 , "Detroit" , "USA" , "Michigan" , 951270]]}}

As long as your programming language has HTTP request and JSON parsing libraries, calling the DBSlayer should be rather straightforward. Note: the DBSlayer currently only supports GET requests, although other HTTP verbs will be supported in future releases. See the section Coding Against the DBSlayer below for more practical details.

Requirements:

路 the Apache Portable Runtime (APR) library (1.0 or above)
路 the Apache Portable Runtime Utility (APU) library (1.0 or above)
路 the MySQL 5 client libraries (5.0 or above)

Installation:

You can build and install the DBSlayer using the standard GNU autoconf process:

Unpack the DBSlayer archive

./configure
make
sudo make install

If the APR, APU, and MySQL libraries are installed in default locations, the configure script will find them. Otherwise, it may be necessary to specify the locations of apr-1-config, apu-1-config, and mysql-config with the --with-apr-1-config, --with-apu-1-config, and --with-mysql-config parameters to configure.

last updated on:
July 31st, 2007, 2:05 GMT
price:
FREE!
developed by:
Derek Gottfrid
license type:
The Apache License 2.0 
category:
ROOT \ Database \ Database APIs

FREE!

In a hurry? Add it to your Download Basket!

user rating 1

UNRATED
5.0/5
 

0/5

Add your review!

SUBMIT