Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

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

8/25/2018

Reading time:2 min

wikimedia/restbase

by John Doe

RESTBase was built to provide a low-latency & high-throughput API forWikipedia / Wikimediacontent. It is basicallya storage proxy, which presents a coherent API powered by Swagger specs to theoutside, and backs up many of these entry points with storage. The defaulttable storage backend is based on Cassandra, which helps it to performwell at Wikimedia's scale without placing undue burden on operations.As a proxy, RESTBase does not perform any significant content processingitself. Instead, it requests content transformations from backend serviceswhen needed, and typically (depending on configuration) stores it back forlater retrieval. For high-volume static end points, most requests will besatisfied directly from storage.The table storage backends conform to a RESTful table storageAPIsimilar to Amazon DynamoDBand Google DataStore. The primaryimplementation uses Apache Cassandra. Notable features include automaticallymaintained secondary indexes and some lightweight transaction support. ASQLite backend isunder development.RESTBase systematically emits statsd metrics about storage and backendrequests. Specifically, the systematic metric production for backend servicesprovides a good baseline level of instrumentation for tracking performanceand errors in a micro-service architecture.Issue trackingWe use Phabricator to trackissues. See the list of current issues in RESTBase.InstallationMake sure that you have node 6+:sudo apt-get install nodejs nodejs-legacy nodejs-dev npmNote: if your distribution does not have a recent version of Node, you caninstall one via nvm.From the restbase project directory, install the Node dependencies:npm installStart RESTBase:node serverThe defaults without a config file should work for a local Cassandrainstallation with the default passwords. Restbase has been tested withCassandra 2.2.6.To customize RESTBase's behaviour, copy the example config to itsdefault location:cp config.example.yaml config.yamlYou can also pass in the path to another file with the -c commandline optionto server.js. If you're running a single Cassandra instance (e.g. a localdevelopment environment), set defaultConsistency to one inconfig.yaml.UsageSee the Wikimedia REST content API sandboxfor a fine example of what RESTBase can do.DevelopmentTestingTo run all the tests from a clean slate, first make sure Cassandra is running locally, then fire up the tests with npm:npm testTo run tests from a single file, e.g. test/features/pagecontent/rerendering.js, run mocha with the file as an argument:mocha test/features/pagecontent/rerendering.jsNote that this might require some setup (e.g. creating the necessary domain and buckets), which is currently done by test/buckets.js.This also works for a directory, e.g. test/features/pagecontent/:mocha test/features/pagecontentCoverageTo check the test coverage, use npm, then browse the report:npm run-script coverageThe coverage report can now be found in <project>/coverage/lcov-report/index.html.Design docs

Illustration Image

RESTBase was built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content. It is basically a storage proxy, which presents a coherent API powered by Swagger specs to the outside, and backs up many of these entry points with storage. The default table storage backend is based on Cassandra, which helps it to perform well at Wikimedia's scale without placing undue burden on operations.

As a proxy, RESTBase does not perform any significant content processing itself. Instead, it requests content transformations from backend services when needed, and typically (depending on configuration) stores it back for later retrieval. For high-volume static end points, most requests will be satisfied directly from storage.

The table storage backends conform to a RESTful table storage API similar to Amazon DynamoDB and Google DataStore. The primary implementation uses Apache Cassandra. Notable features include automatically maintained secondary indexes and some lightweight transaction support. A SQLite backend is under development.

RESTBase systematically emits statsd metrics about storage and backend requests. Specifically, the systematic metric production for backend services provides a good baseline level of instrumentation for tracking performance and errors in a micro-service architecture.

Issue tracking

We use Phabricator to track issues. See the list of current issues in RESTBase.

Installation

Make sure that you have node 6+:

sudo apt-get install nodejs nodejs-legacy nodejs-dev npm

Note: if your distribution does not have a recent version of Node, you can install one via nvm.

From the restbase project directory, install the Node dependencies:

npm install

Start RESTBase:

node server

The defaults without a config file should work for a local Cassandra installation with the default passwords. Restbase has been tested with Cassandra 2.2.6. To customize RESTBase's behaviour, copy the example config to its default location:

cp config.example.yaml config.yaml

You can also pass in the path to another file with the -c commandline option to server.js. If you're running a single Cassandra instance (e.g. a local development environment), set defaultConsistency to one in config.yaml.

Usage

See the Wikimedia REST content API sandbox for a fine example of what RESTBase can do.

Development

Testing

To run all the tests from a clean slate, first make sure Cassandra is running locally, then fire up the tests with npm:

npm test

To run tests from a single file, e.g. test/features/pagecontent/rerendering.js, run mocha with the file as an argument:

mocha test/features/pagecontent/rerendering.js

Note that this might require some setup (e.g. creating the necessary domain and buckets), which is currently done by test/buckets.js.

This also works for a directory, e.g. test/features/pagecontent/:

mocha test/features/pagecontent

Coverage

To check the test coverage, use npm, then browse the report:

npm run-script coverage

The coverage report can now be found in <project>/coverage/lcov-report/index.html.

Design docs

Related Articles

spring
angular
rest

GitHub - jhipster/jhipster-sample-app-cassandra: This is a sample application created with JHipster, with the Cassandra option

jhipster

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