Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

10/22/2019

Reading time:2 min

wikimedia/restbase-mod-table-cassandra

by John Doe

This projects provides a high-level table storage service abstractionsimilar to Amazon DynamoDB or Google DataStore on top of Cassandra. As theproduction table storage backend for RESTBase, it powers theWikimedia REST APIs, such as this one for the EnglishWikipedia.For testing and small installs, there is also a sqlite backendimplementing the same interfaces.Issue trackingWe use Phabricator to trackissues. See the list of current issues in restbase-mod-table-cassandra.StatusIn production since March 2015.Featuresbasic table storage service with REST interface, backed by Cassandra,implementing the RESTBase table storage interfacemulti-tenant design: domain creation, prepared for per-domain ACLstable creation with declarative JSON schemaslimited automatic schema migrationspagingTODOPossibly, some amount of transaction supportLeverage Cassandra 3 materializedviews where it makes sense,once those have stabilized.ConfigurationConfiguration of this module takes place from within an x-modules stanza in the YAML-formattedRESTBase configuration file.While complete configuration of RESTBase is beyond the scope of this document, (see theRESTBase docs for that), this section covers therestbase-mod-table-cassandra specifics. - name: restbase-mod-table-cassandra version: 1.0.0 type: npm options: # Passed to the module constructor conf: version: 1 hosts: [localhost] username: cassandra password: cassandra defaultConsistency: localOne localDc: datacenter1 datacenters: - datacenter1 storage_groups: - name: default.group.local domains: /./VersionThe version of this configuration. Each edit of the module configuration mustcorrepond to a new, unique version.Note: Versions must be monotonically increasing. version: 1HostsA list of Cassandra nodes to use as contact points. hosts: - cassandra-01.sample.org - cassandra-02.sample.org - cassandra-03.sample.orgCredentialsPassword credentials to use in authenticating with Cassandra.Note: Optional; Leave unconfigured if Cassandra authentication is not enabled. username: someuser password: somepassDefault ConsistencyThe Cassandra consistency level to use when not otherwise specified. Validvalues are those from the nodejs driver for Cassandra.Defaults to localOne. defaultConsistency: localOneTLSKey and certificate information for use in TLS-encrypted environments. See thenodejs documentation on tls.connectfor the meaning of these directives.Note: Optional; Leave unconfigured if Cassandra client encryption is not enabled. tls: cert: /etc/restbase/tls/cert.pem key: /etc/restbase/tls/key.pem ca: - /etc/restbase/tls/root.pemLocal Datacenterrestbase-mod-table-cassandrauses a datacenter-aware connection pool. The localDc directive instructs the modulewhich datacenter to treat as 'local' to this instance. Cassandra nodes in the localdatacenter will be used for queries, and any others serve as a fallback. Defaults todatacenter1 (the Cassandra default).Note: the localDc must be in the list of configured datacenters (see below). localDc: datacenter1DatacentersThe list of datacenters this Cassandra cluster belongs to. Data will be replicatedacross these datacenters accordingly. Defaults to [ datacenter1 ].Note: Changing this list alters the underlying Cassandra keyspaces in order to addor remove datacenter replicas accordingly, but replication is NOT made retroactive.You MUST perform aCassandra repairafter adding a new datacenter to realize theadded redundancy. Likewise, you must perform a cleanup to reclaim space if adatacenter is removed. datacenters: - datacenter1Storage GroupsStorage groups are used to map tables to one or more hosts/domains. storage_groups: - name: default.group.local domains: /./

Illustration Image

This projects provides a high-level table storage service abstraction similar to Amazon DynamoDB or Google DataStore on top of Cassandra. As the production table storage backend for RESTBase, it powers the Wikimedia REST APIs, such as this one for the English Wikipedia.

For testing and small installs, there is also a sqlite backend implementing the same interfaces.

Issue tracking

We use Phabricator to track issues. See the list of current issues in restbase-mod-table-cassandra.

Status

In production since March 2015.

Build Status coverage status

Features

  • basic table storage service with REST interface, backed by Cassandra, implementing the RESTBase table storage interface
  • multi-tenant design: domain creation, prepared for per-domain ACLs
  • table creation with declarative JSON schemas
  • limited automatic schema migrations
  • paging

TODO

Configuration

Configuration of this module takes place from within an x-modules stanza in the YAML-formatted RESTBase configuration file. While complete configuration of RESTBase is beyond the scope of this document, (see the RESTBase docs for that), this section covers the restbase-mod-table-cassandra specifics.

    - name: restbase-mod-table-cassandra
      version: 1.0.0
      type: npm
      options: # Passed to the module constructor
        conf:
          version: 1
          hosts: [localhost]
          username: cassandra
          password: cassandra
          defaultConsistency: localOne
          localDc: datacenter1
          datacenters:
            - datacenter1
          storage_groups:
            - name: default.group.local
              domains: /./

Version

The version of this configuration. Each edit of the module configuration must correpond to a new, unique version.

Note: Versions must be monotonically increasing.

    version: 1

Hosts

A list of Cassandra nodes to use as contact points.

    hosts:
      - cassandra-01.sample.org
      - cassandra-02.sample.org
      - cassandra-03.sample.org

Credentials

Password credentials to use in authenticating with Cassandra.

Note: Optional; Leave unconfigured if Cassandra authentication is not enabled.

    username: someuser
    password: somepass

Default Consistency

The Cassandra consistency level to use when not otherwise specified. Valid values are those from the nodejs driver for Cassandra. Defaults to localOne.

    defaultConsistency: localOne

TLS

Key and certificate information for use in TLS-encrypted environments. See the nodejs documentation on tls.connect for the meaning of these directives.

Note: Optional; Leave unconfigured if Cassandra client encryption is not enabled.

    tls:
      cert: /etc/restbase/tls/cert.pem
      key: /etc/restbase/tls/key.pem
      ca:
        - /etc/restbase/tls/root.pem

Local Datacenter

restbase-mod-table-cassandra uses a datacenter-aware connection pool. The localDc directive instructs the module which datacenter to treat as 'local' to this instance. Cassandra nodes in the local datacenter will be used for queries, and any others serve as a fallback. Defaults to datacenter1 (the Cassandra default).

Note: the localDc must be in the list of configured datacenters (see below).

    localDc: datacenter1

Datacenters

The list of datacenters this Cassandra cluster belongs to. Data will be replicated across these datacenters accordingly. Defaults to [ datacenter1 ].

Note: Changing this list alters the underlying Cassandra keyspaces in order to add or remove datacenter replicas accordingly, but replication is NOT made retroactive. You MUST perform a Cassandra repair after adding a new datacenter to realize the added redundancy. Likewise, you must perform a cleanup to reclaim space if a datacenter is removed.

    datacenters:
      - datacenter1

Storage Groups

Storage groups are used to map tables to one or more hosts/domains.

    storage_groups:
      - name: default.group.local
        domains: /./

Related Articles

api.management
node
api

LoopBack

John Doe

3/7/2024

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra