DB Relay An Introduction. INSPIRATION Database access is WAY TOO HARD The crux.

Slides:



Advertisements
Similar presentations
1. XP 2 * The Web is a collection of files that reside on computers, called Web servers. * Web servers are connected to each other through the Internet.
Advertisements

Info to Enterprise Migration Implementation Case Study: SBC Corporation Presented to the Crystal Decisions Regional Users Group for the Bay Area on October.
IS 6116 Introduction – 10 Jan Lecturer Details Aonghus Sugrue Website: aonghussugrue.wordpress.com
© 2007 Cisco Systems, Inc. All rights reserved.ISCW-Mod3_L7 1 Network Security 2 Module 6 – Configure Remote Access VPN.
J0 1 Marco Ronchetti - The Web: an architectural view.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Introduction to Rails.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Using Perl for CGI Programming.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
NetSEC: metrology-based application for network security Jean-François SCARIOT Bernard MARTINET Centre Interuniversitaire de Calcul de Grenoble TNC 2002.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Eldas 1.0 Enterprise Level Data Access Services Design Issues, Implementation and Future Development Davy Virdee.
ZMQS ZMQS
Overview Environment for Internet database connectivity
1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
Representational State Transfer (REST): Representing Information in Web 2.0 Applications this is the presentation Emilio F Zegarra CS 2650.
Web Service Testing RESTful Web Services Snejina Lazarova Dimo Mitev
REST and JSON in WCF It is possible to implement and access REST services in WCF And still doing it object oriented This is a short presentation on how.
BT Wholesale October Creating your own telephone network WHOLESALE CALLS LINE ASSOCIATED.
Simplified Management using the Enterprise Policy Management Framework
1 The phone in the cloud Utilizing resources hosted anywhere Claes Nilsson.
ABC Technology Project
MySQL Access Privilege System
1 Web-Enabled Decision Support Systems Access Introduction: Touring Access Prof. Name Position (123) University Name.
State of Connecticut Core-CT Project Query 8 hrs Updated 6/06/2006.
Copyright 2007, Information Builders. Slide 1 Introduction to Web Services Efrem Litwin Director, WebFOCUS Integration Products Information Builders.
© S Haughton more than 3?
CAR Training Module PRODUCT REGISTRATION and MANAGEMENT Module 2 - Register a New Document - Without Alternate Formats (Run as a PowerPoint show)
Squares and Square Root WALK. Solve each problem REVIEW:
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
31242/32549 Advanced Internet Programming Advanced Java Programming
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Test B, 100 Subtraction Facts
Performance Tuning for Informer PRESENTER: Jason Vorenkamp| | October 11, 2010.
Week 1.
1 1999/Ph 514: Channel Access Concepts EPICS Channel Access Concepts Bob Dalesio LANL.
We will resume in: 25 Minutes.
A SMALL TRUTH TO MAKE LIFE 100%
1 Unit 1 Kinematics Chapter 1 Day
1 PART 1 ILLUSTRATION OF DOCUMENTS  Brief introduction to the documents contained in the envelope  Detailed clarification of the documents content.
How Cells Obtain Energy from Food
1/16 Steven Leung Introduction to HTML/CGI/JavaScript Intro to HTML/CGI/JavaScript How the Web Works HTML: Basic Concept CGI: Basic Concept JavaScript:
WaveMaker Visual AJAX Studio 4.0 Training
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Computer Net Lab/Praktikum Datenverarbeitung 2 1 Overview Sockets Sockets in C Sockets in Delphi.
© 2009 GroundWork Open Source, Inc. PROPRIETARY INFORMATION: Information contained herein is not for use or disclosure outside of GroundWork Open Source,
Learningcomputer.com SQL Server 2008 Configuration Manager.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
ICM – API Server & Forms Gary Ratcliffe.
ICM – API Server Gary Ratcliffe. 2 Agenda Webinar Programme API Server Overview JSON-RPC iCM API Service API Server and Forms New services under.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
DEPTT. OF COMP. SC & APPLICATIONS
Node.js Express Web Applications
z/Ware 2.0 Technical Overview
PHP / MySQL Introduction
Presentation transcript:

DB Relay An Introduction

INSPIRATION

Database access is WAY TOO HARD The crux

The problem

Easy access means getting data from a database in one or two language statements The vision

Like that, for example $ curl \ --data-urlencode sql_server=sqlserver \ --data-urlencode sql_user=demo \ --data-urlencode sql_password=demo \ --data-urlencode "sql=select count(*) as employees from HumanResources.vEmployee" \ " {"request":{"sql_server":"sqlserver", "sql_user":"demo", "sql_database":"AdventureWorks"}, "data":[{"fields":[{"name":"employees", "sql_type":"int", "length”:4}], "rows":[{"employees":290}], "count":1}], "log":{}} $ HTTP POST request: JSON over HTTP response:

… even within a web page The twist

CONCEPT

Achieving simplicity  Little to learn - Protocols and authentication - Query language - Results as data structures  Interface libraries  Simple maintenance and configuration HTTP, HTTPS SQL JSON Come with a language Single-file config

Prerequisite: NGiNX Prerequisite knowledge: NGiNX (pronounced “engine-X”) is a free, open-source, high-performance HTTP server and then some. NGiNX was released in 2004 by Igor Sysoev. It is now the third or fourth most popular web server and hosts about 6.55% (per Netcraft in May 2010) of all domains worldwide. NGiNX is fast, lightweight, and scales to 10K concurrent requests. More information about NGiNX is available at:

Welcome to DB Relay ! DB Relay is an open source project built around the NGiNX web server platform, providing an HTTP/JSON interface to a variety of database servers. It enables database access without drivers and web application development without complex middleware. DB Relay is designed for operational efficiency and easy maintenance.

ARCHITECTURE

Architecture

In a simple use case one DB Relay instance services one target database with shared or independent DB connections Simple connectivity

Any DB Relay instance may serve any number of clients and databases DB Relay view of connectivity

Each client may send requests to any number of DB Relays and databases Client view of connectivity

Any combination of the previous connectivity options is OK All connectivity options

EXAMPLES

Returned JSON format { "request": { "query_tag":..., "sql_server":..., "sql_user":..., "sql_database":... }, "data": [ { "fields": [...], "rows": [...], "count":... }, { "fields": [...], "rows": [...], "count":... } ], "log": { "sql":..., "error":... } Properties of the root object. The “request” property returns some of the original request’s HTTP parameters. Array of row sets. Example field: { "name": "Last", "sql_type": "char", "length": 100 } Example row: { "First": "Garrett”, "Last": "Vargas" } Optional log entries: The “sql” property contains the SQL string which was sent to the database server. It is not returned by default. To turn it on, use the “flags” HTTP parameter with value “echosql”. The “error” property is returned automatically only if there was an error executing the request. In that case the “error” property contains the error message string.

Python example import urllib, urllib2 from pprint import pprint try: import simplejson as json except ImportError: import json response = urllib2.urlopen( url = " data = urllib.urlencode({ 'connection_name' : 'sql_server' : 'sqlserver', 'sql_user' : 'demo', 'sql_password' : 'demo', 'sql' : 'select count(*) as employees from HumanResources.vEmployee' })) parsed = json.load( response ) pprint( parsed )

JavaScript example <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN” " jQuery.post( "/sql", { connection_name : sql_server : "sqlserver", sql_user : "demo", sql_password : "demo", sql : "select count(*) as employees from HumanResources.vEmployee" }, function( response ) { jQuery("body").html( " " + response.data[0].rows[0].employees + " employees ” ); }, "json" );

The web UI built into DB Relay is an example of building a rich Internet application on the top of DB Relay server using the Sencha (ExtJS) framework. It implements a SQL query UI and table editor (WIP). Web UI as example application

As a part of its web UI, DB Relay provides the connector status window, which allows the user to browse active connections. From the same window users can terminate connectors running offending queries. Managing connectors via web UI

OPERATION

Installation (CentOS 5.2 and OSX 10.5+) Download and build a DB Relay development instance: $ mkdir $HOME/dbrelay; cd $HOME/dbrelay $ git clone git $ cd git $ git submodule init $ git submodule update $./configure --prefix=$HOME/dbrelay --with-freetds $ make $ make install (measured on a MacBook Pro 2.66 GHz Intel Core Duo) 3 s 15 s 2 s 3 s 7 s 35 s 80 s 15 s 2 m 20 s Time: (total time)

Operation on Linux as a service Installing the init script on CentOS # cp /home/dbrelay/git/contrib/init \ /etc/init.d/dbrelay # chmod +x /etc/init.d/dbrelay # vi /etc/init.d/dbrelay # chkconfig --add dbrelay Standard operating commands: # service dbrelay start # service dbrelay stop # service dbrelay restart

Operation on Mac OS X and Linux Starting DB Relay from its install directory: $./sbin/nginx $ Stopping DB Relay from its install directory: $ kill $(cat./logs/nginx.pid) $ Logs directory content: $ ls./logs/ access.log connector1234.log error.log nginx.pid

Maillist list.dbrelay.org Web site : Brian Bruns dbrelay.com Vlad Didenko dbrelay.com Booth # 520

Backup / Overflow Materials

In case of emergency Shared memory cleaning by DB Relay $./sbin/nginx --clean Cleaning up old instance(s) shared mem key = $ Shared memory cleaning by root: # ipcs -sm Shared Memory Segments key shmid owner perms bytes nattch status 0x dbrelay Semaphore Arrays key semid owner perms nsems 0x dbrelay # ipcrm –M 0x ; ipcrm –S 0x

Example of DB Relay configuration error_log logs/error.log info; worker_processes 100; events { worker_connections 256; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 1433; server_name dbrelay; error_page /50x.html; location / { root html; index index.html index.htm; } location /sql { dbrelay; } location /dbrelay/eg/ { autoindex on; } location /dbrelay/plugins/ { autoindex on; } location = /50x.html { root html; } } gzip on; gzip_http_version 1.1; gzip_vary on; gzip_comp_level 4; gzip_proxied any; gzip_types text/plain text/css text/javascript application/json application/x-javascript; gzip_buffers 16 8k; }

Project status  Deployed in production  All dependency libraries are statically compiled into a single executable  Most common (date & time, numeric, string, and UID) types are implemented  Persistent named database connections  Error handling  A single configuration file  Positional SQL parameters in queries  Domain logins  Configurable timeouts  Platform-specific autoconf builds  Administrator HTML interface  Feedback and logging  Legal work to release project as Open Source software  Multiple RDBMS back-ends  Single-file deployment  Handling signals per specification  Full command-line options implementation  Tune the build process to allow for third-party NGiNX modules

Why not MS SQL Server's IIS?  Do not want to enable IIS on each MS SQL Server.  MS SQL Server emits heavy, hard-to parse XML - pain to use in an agile JavaScript or Python.  MS SQL Server's IIS establishes database connection at each request - no intelligent connection persistence.  DB Relay supports other databases in addition to MS SQL Server.  All extra features and plug-ins to NGiNX may be used in the future. For example, NGiNX proxy and cache features used today to cache some of the expensive queries for daily data at the DB Relay level, without hitting the database.

DB Relay