cachedb_cassandra Module

Vladut-Stefan Paiu

OpenSIPS Solutions

Edited by

Vladut-Stefan Paiu


Table of Contents

1. Admin Guide
1.1. Overview
1.2. Advantages
1.3. Limitations
1.4. Dependencies
1.4.1. OpenSIPS Modules
1.4.2. External Libraries or Applications
1.5. Exported Parameters
1.5.1. cachedb_url (string)
1.5.2. connection_timeout (int)
1.5.3. send_timeout (int)
1.5.4. receive_timeout (int)
1.5.5. wr_consistency_level (int)
1.5.6. rd_consistency_level (int)
1.6. Exported Functions
1.7. Known issues

List of Examples

1.1. Set cachedb_url parameter
1.2. Use Cassandra servers
1.3. Set connection_timeout parameter
1.4. Set send_timeout parameter
1.5. Set receive_timeout parameter
1.6. Set wr_consistency_level parameter
1.7. Set rd_consistency_level parameter

Chapter 1. Admin Guide

1.1. Overview

This module is an implementation of a cache system designed to work with Cassandra servers. It uses the Key-Value interface exported from the core.

1.2. Advantages

  • memory costs are no longer on the server

  • many servers can be used inside a cluster, so the memory is virtually unlimited

  • the cache is 100% persistent. A restart of OpenSIPS server will not affect the DB. The Cassandra DB is also persistent so it can also be restarted without loss of information.

  • Cassandra is an open-source project so it can be used to exchange data with various other applicationsr

  • By creating a Cassandra Cluster, multiple OpenSIPS instances can easily share key-value information

1.3. Limitations

  • keys (in key:value pairs) may not contain spaces or control characters

1.4. Dependencies

1.4.1. OpenSIPS Modules

None.

1.4.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • thrift 0.6.1

    Thrift 0.6.1 can be downloaded from http://archive.apache.org/dist/thrift/ Download the archive, extract sources, run ./configure,make,sudo make install.

1.5. Exported Parameters

1.5.1. cachedb_url (string)

The urls of the server groups that OpenSIPS will connect to in order to use the from script cache_store,cache_fetch, etc operations. It can be set more than one time. The prefix part of the URL will be the identifier that will be used from the script. The database part of the URL needs to be in the format Keyspace_ColumnFamily

Example 1.1. Set cachedb_url parameter

...
modparam("cachedb_cassandra", "cachedb_url","cassandra:group1://localhost:9061/Keyspace1_Users");
modparam("cachedb_cassandra", "cachedb_url","cassandra:cluster1://random_url:8888/Keyspace2_Keys");
...
	

Example 1.2. Use Cassandra servers

...
cache_store("cassandra:group1","key","$ru value");
cache_fetch("cassandra:cluster1","key",$avp(10));
cache_remove("cassandra:cluster1","key");
...
	

1.5.2. connection_timeout (int)

The timeout in ms that will be triggered in case a connection attempt fails.

Example 1.3. Set connection_timeout parameter

...
modparam("cachedb_cassandra", "connection_timeout",1000);
...
	

1.5.3. send_timeout (int)

The timeout in ms that will be triggered in case a Cassandra write takes too long

Example 1.4. Set send_timeout parameter

...
modparam("cachedb_cassandra", "send_timeout",1000);
...
	

1.5.4. receive_timeout (int)

The timeout in ms that will be triggered in case a Cassandra read takes too long

Example 1.5. Set receive_timeout parameter

...
modparam("cachedb_cassandra", "receive_timeout",1000);
...
	

1.5.5. wr_consistency_level (int)

The consistency level desired for write operations. Options are :

  • 1 - Ensure that the write has been written to at least 1 replica's commit log and memory table before responding to the client.

  • 2 - Ensure that the write has been written to N / 2 + 1 replicas before responding to the client.

  • 3 - Ensure that the write has been written to ReplicationFactor / 2 + 1 nodes, within the local datacenter (requires NetworkTopologyStrategy)

  • 4 - Ensure that the write has been written to ReplicationFactor / 2 + 1 nodes in each datacenter (requires NetworkTopologyStrategy)

  • 5 - Ensure that the write is written to all N replicas before responding to the client. Any unresponsive replicas will fail the operation.

  • 6 - Ensure that the write has been written to at least 1 node, including HintedHandoff recipients.

  • 7 - Ensure that the write has been written to at least 2 replica's before responding to the client.

  • 8 - Ensure that the write has been written to at least 3 replica's before responding to the client.

Default is 1

Example 1.6. Set wr_consistency_level parameter

...
modparam("cachedb_cassandra", "wr_consistency_level",7);
...
	

1.5.6. rd_consistency_level (int)

The consistency level desired for read operations. Options are the same as for write consistency level.

Example 1.7. Set rd_consistency_level parameter

...
modparam("cachedb_cassandra", "rd_consistency_level",7);
...
	

1.6. Exported Functions

The module does not export functions to be used in configuration script.

1.7. Known issues

Due to the fact that Cassandra cannot store counters and regular columns in the same ColumnFamily, add() and sub() methods are not exported through the Key-Value interface.

Also, the module does not currently support Authentication.

Future realeases of this module will address this issue.