Cassandra Protocol Configuration
Cassandra Protocol Configuration
Complete configuration reference for HeliosDB’s Cassandra CQL protocol implementation.
Server Configuration
Network Settings
[cassandra]# Listen address for CQL native protocollisten_address = "0.0.0.0"
# CQL native protocol port (default: 9042)port = 9042
# Maximum concurrent connectionsmax_connections = 1000
# Connection timeout in secondsconnection_timeout = 10
# Idle connection timeout (0 = disabled)idle_timeout = 0Protocol Settings
[cassandra.protocol]# Supported protocol versionsmin_version = 4max_version = 5
# Maximum frame size (bytes)max_frame_size = 268435456 # 256MB
# Enable compressioncompression_enabled = truecompression_algorithms = ["lz4", "snappy"]
# Request timeout (ms)request_timeout = 12000Authentication
[cassandra.auth]# Enable authenticationenabled = true
# Authenticator type: "AllowAll", "Password"authenticator = "Password"
# Authorizer type: "AllowAll", "CassandraAuthorizer"authorizer = "AllowAll"
# Role managerrole_manager = "CassandraRoleManager"
# Credentials validity period (ms)credentials_validity = 2000
# Permission validity period (ms)permissions_validity = 2000Keyspace Settings
[cassandra.keyspace]# Default keyspace (optional)default_keyspace = ""
# System keyspace replicationsystem_keyspace_replication = { class = "SimpleStrategy", replication_factor = 1 }
# Auto-create keyspacesauto_create_keyspaces = trueQuery Settings
[cassandra.query]# Enable prepared statement cacheprepared_cache_enabled = true
# Prepared statement cache sizeprepared_cache_size = 1000
# Page size defaultdefault_page_size = 5000
# Maximum page sizemax_page_size = 50000
# Allow filteringallow_filtering = trueBatch Settings
[cassandra.batch]# Enable batch operationsenabled = true
# Maximum batch size (statements)max_batch_size = 65535
# Batch timeout (ms)batch_timeout = 10000
# Logged batch by defaultlogged_by_default = trueConnection String Format
Driver Configuration
Java (DataStax)
CqlSession session = CqlSession.builder() .addContactPoint(new InetSocketAddress("localhost", 9042)) .withLocalDatacenter("datacenter1") .withAuthCredentials("username", "password") .withKeyspace("my_keyspace") .build();Python (cassandra-driver)
from cassandra.cluster import Clusterfrom cassandra.auth import PlainTextAuthProvider
auth = PlainTextAuthProvider(username='user', password='password')cluster = Cluster( ['localhost'], port=9042, auth_provider=auth, protocol_version=5)session = cluster.connect('my_keyspace')Node.js (cassandra-driver)
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({ contactPoints: ['localhost'], localDataCenter: 'datacenter1', keyspace: 'my_keyspace', authProvider: new cassandra.auth.PlainTextAuthProvider('user', 'password'), protocolOptions: { port: 9042 }});Go (gocql)
cluster := gocql.NewCluster("localhost")cluster.Port = 9042cluster.Keyspace = "my_keyspace"cluster.Authenticator = gocql.PasswordAuthenticator{ Username: "user", Password: "password",}cluster.ProtoVersion = 4
session, err := cluster.CreateSession()Connection Pool Settings
Java Driver
CqlSession session = CqlSession.builder() .addContactPoint(new InetSocketAddress("localhost", 9042)) .withLocalDatacenter("datacenter1") .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 4) .setCoreConnectionsPerHost(HostDistance.REMOTE, 1) .setMaxConnectionsPerHost(HostDistance.REMOTE, 2) .setMaxRequestsPerConnection(HostDistance.LOCAL, 32768) ) .build();Python Driver
from cassandra.cluster import Cluster, ExecutionProfilefrom cassandra.policies import RoundRobinPolicy
profile = ExecutionProfile( load_balancing_policy=RoundRobinPolicy(), request_timeout=10)
cluster = Cluster( ['localhost'], execution_profiles={'default': profile}, protocol_version=5, idle_heartbeat_interval=30)Consistency Levels
Server Configuration
[cassandra.consistency]# Default read consistencydefault_read_consistency = "LOCAL_QUORUM"
# Default write consistencydefault_write_consistency = "LOCAL_QUORUM"
# Serial consistencydefault_serial_consistency = "SERIAL"Client Configuration
from cassandra import ConsistencyLevelfrom cassandra.query import SimpleStatement
# Query with specific consistencyquery = SimpleStatement( "SELECT * FROM users WHERE user_id = ?", consistency_level=ConsistencyLevel.QUORUM)session.execute(query, [user_id])Retry Policies
Java Driver
CqlSession session = CqlSession.builder() .addContactPoint(new InetSocketAddress("localhost", 9042)) .withLocalDatacenter("datacenter1") .withRetryPolicy(new DefaultRetryPolicy()) .build();Python Driver
from cassandra.policies import RetryPolicy
class CustomRetryPolicy(RetryPolicy): def on_read_timeout(self, query, consistency, required_responses, received_responses, data_retrieved, retry_num): if retry_num < 3: return (self.RETRY, consistency) return (self.RETHROW, None)Compression
Server Configuration
[cassandra.compression]# Enable compressionenabled = true
# Preferred algorithm: "lz4", "snappy"algorithm = "lz4"
# Compression level (1-22 for lz4, 1-9 for snappy)level = 3Client Configuration
from cassandra.cluster import Cluster
cluster = Cluster( ['localhost'], compression=True # Auto-negotiate)SSL/TLS Configuration
Server Configuration
[cassandra.ssl]# Enable SSLenabled = false
# Certificate filescert_file = "/etc/heliosdb/cassandra.crt"key_file = "/etc/heliosdb/cassandra.key"ca_file = "/etc/heliosdb/ca.crt"
# Require client certificaterequire_client_cert = false
# Cipher suitesciphers = ["TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256"]Client Configuration
from cassandra.cluster import Clusterfrom ssl import SSLContext, PROTOCOL_TLS_CLIENT
ssl_context = SSLContext(PROTOCOL_TLS_CLIENT)ssl_context.load_verify_locations('/path/to/ca.crt')
cluster = Cluster( ['localhost'], ssl_context=ssl_context)Performance Tuning
Query Optimization
[cassandra.performance]# Query trace threshold (ms)trace_threshold_ms = 100
# Log slow querieslog_slow_queries = true
# Slow query threshold (ms)slow_query_threshold_ms = 500
# Enable query cachequery_cache_enabled = true
# Query cache size (MB)query_cache_size = 256Memory Settings
[cassandra.memory]# Native transport max concurrent connectionsnative_transport_max_concurrent_connections = 128
# Native transport max frame size (bytes)native_transport_max_frame_size = 268435456
# Request timeout (ms)request_timeout = 10000Monitoring
cqlsh Commands
-- Show cluster infoDESCRIBE CLUSTER;
-- Show keyspacesDESCRIBE KEYSPACES;
-- Show tablesDESCRIBE TABLES;
-- Show table schemaDESCRIBE TABLE my_table;
-- Enable tracingTRACING ON;SELECT * FROM users WHERE user_id = ?;TRACING OFF;System Tables
-- Query system tablesSELECT * FROM system.peers;SELECT * FROM system.local;SELECT * FROM system_schema.keyspaces;SELECT * FROM system_schema.tables WHERE keyspace_name = 'my_keyspace';Related: README.md | COMPATIBILITY.md | EXAMPLES.md
Last Updated: December 2025