Skip to main content

table-oriented abstraction layer over key-value stores

Project description

kvlayer
=======

``kvlayer`` is a database abstraction layer providing a simple key-value store to applications. For development purposes this can run against an in-memory implementation or a server such as [Redis](http://redis.io/); in test and production, this can be switched to a relational database such as [PostgreSQL](http://postgresql.org/) or a cluster database such as [Accumulo](http://accumulo.apache.org/) or [Riak](http://basho.com/riak/).

Configuration
-------------

``kvlayer`` depends on the [Yakonfig](https://github.com/diffeo/yakonfig/) library to get its configuration information. Configuration is in a YAML file passed into the application. This includes a *storage type*, indicating which backend to use, and an *application name* and a *namespace*, both of which distinguish different applications sharing the same database.

```yaml
kvlayer:
storage_type: local # in-memory data store
app_name: kvlayer
namespace: kvlayer
```

kvlayer API
-----------

Applications see multiple kvlayer *tables*, which may be implemented as database-native tables for databases that have that concept. Each row has a key and a value. The keys are Python tuples, with some consistent set of types; tuple parts may be strings, integers, or UUIDs. Values are always Python byte strings.

There are four basic operations kvlayer makes available. ``put()`` writes one or more key-value pairs into the database. ``get()`` retrieves key-value pairs with known fixed keys. ``scan()`` retrieves key-value pairs within a range of keys. ``delete()`` removes specific keys.

A minimal kvlayer application would look like:

```python
import argparse
import kvlayer
import yakonfig

parser = argparse.ArgumentParser()
yakonfig.parse_args(parser, [yakonfig, kvlayer])
kvl = kvlayer.client()
kvl.setup_namespace({'table': (str,)})

# Write values
kvl.put('table', (('foo',), 'one'), (('bar',), 'two'))

# Retrieve values
for k,v in kvl.get('table', ('foo',)):
assert k == 'foo'
print v

# Scan values
for k,v in kvl.scan('table', (('a',), ('e',))):
print k
print v

# Scan keys
for k in kvl.scan_keys('table', (('e',), ('z',))):
print k

# Delete values
kvl.delete('table', ('foo',))
```

Other notes
-----------

See details of [testing on Accumulo using saltstack](accumulo-tests.md).

For throughput testing, see [kvlayer_throughput_tests](https://github.com/diffeo/kvlayer/blob/0.4.5/kvlayer/tests/test_throughput.py).

For example, using various single-node EC2 instances, random
reads/writes experiences these rates:

| num_workers | storage_type | read MB/sec | write MB/sec | |
|-------------|--------------|-------------|--------------|---|
| 100 | redis | 99.6 | 57.3 |m1.xlarge |
| 50 | redis | 93.7 | 56.5 |m1.xlarge |
| 25 | redis | 66.9 | 33.8 |m1.xlarge |
| 80 | postgres | 34.2 | 14.4 |m1.medium |
| 50 | postgres | 33.1 | 14.1 |m1.medium |
| 25 | postgres | 30.1 | 13.7 |m1.medium |
| 100 | accumulo | 17.2 | 13.6 |m1.large |
| 50 | accumulo | 21.9 | 16.0 |m1.large |
| 25 | accumulo | 24.7 | 16.6 |m1.large |

TODO: gather more stats.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kvlayer-0.5.3.dev9.tar.gz (73.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kvlayer-0.5.3.dev9-py2.7.egg (211.8 kB view details)

Uploaded Egg

File details

Details for the file kvlayer-0.5.3.dev9.tar.gz.

File metadata

  • Download URL: kvlayer-0.5.3.dev9.tar.gz
  • Upload date:
  • Size: 73.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kvlayer-0.5.3.dev9.tar.gz
Algorithm Hash digest
SHA256 be95e17adcc63c59a64074369c545d862e49fa3e25526318860db562a30b85c0
MD5 be40a26a153a8a2cfe715f3066725eeb
BLAKE2b-256 f90a353898d0ea993d5ccc416add2be6bdb46a96391a33a0acfe1faa02249ddf

See more details on using hashes here.

File details

Details for the file kvlayer-0.5.3.dev9-py2.7.egg.

File metadata

File hashes

Hashes for kvlayer-0.5.3.dev9-py2.7.egg
Algorithm Hash digest
SHA256 fe37a81a04de7d4a7e1e9df438b7cccfa3621cf621a7ec3c68bffebf3e49b123
MD5 9698ac12c539089f19f44aca53f21148
BLAKE2b-256 df9c3a621f8fb7afa5bd5f7ac706b986b7f349de98e851eea0ecd4556cc142e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page