DBSlayer

DBSlayer is a lightweight database abstraction layer suitable for high-load websites.
Download

DBSlayer Ranking & Summary

Advertisement

  • Rating:
  • License:
  • The Apache License 2.0
  • Price:
  • FREE
  • Publisher Name:
  • Derek Gottfrid
  • Publisher web site:
  • http://code.nytimes.com/projects/dbslayer

DBSlayer Tags


DBSlayer Description

DBSlayer is a lightweight database abstraction layer suitable for high-load websites. DBSlayer also know as Slyer (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 servernameThis 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 OKDate: Wed, 27 Jun 2007 20:55:59 GMTServer: dbslayer/server beta-9Connection: CloseContent-type: text/plain; charset=utf-8Content-Length: 746{"RESULT" : {"TYPES" : , "HEADER" : , "ROWS" : , , , , , , , , , ]}}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.


DBSlayer Related Software