Cassandra Interview Questions
Q1) What is Apache Cassandra?
Ans: Apache Cassandra is an open-source, distributed, and decentralized/distributed storage system (database), for managing very large amounts of structured data spread out across the world. It provides a highly available service with no single point of failure. It was developed at Facebook for inbox search and it was open-sourced by Facebook in July 2008.
Q2) What is NoSQL Database?
Ans: NoSQL database (sometimes called Not Only SQL) is a database that provides a mechanism to store and retrieve data other than the tabular relations used in relational databases. These databases are schema-free, support easy replication, have simple API, eventually consistent, and can handle huge amounts of data.
Q3) Cassandra is written in which language?
Q4) How many types of NoSQL databases?
- Document Stores (MongoDB, Couchbase)
- Key-Value Stores (Redis, Volgemort)
- Column Stores (Cassandra)
- Graph Stores (Neo4j, Graph)
Q5) What is the relationship between Apache Hadoop, HBase, Hive, and Cassandra?
- Apache Hadoop, File Storage, Grid Compute processing via Map Reduce.
- Apache Hive, SQL like interface on top of Hadoop.
- Apache Hbase, Column Family Storage built like BigTable
- Apache Cassandra, Column Family Storage build like BigTable with Dynamo topology and consistency.
Q6) What happens to exist data in my cluster when I add new nodes?
Ans: When a new node joins a cluster, it will automatically contact the other nodes in the cluster and copy the right data to itself.
Q7)What are "Seed Nodes" in Cassandra?
Ans: A seed node in Cassandra is a node that is contacted by other nodes when they first start up and join the cluster. A cluster can have multiple seed nodes. Seed node helps the process of bootstrapping for a new node joining a cluster. It is recommended using the 2 seed node per data center.
Q8) List out some key features of Apache Cassandra?
- It is scalable, fault-tolerant, and consistent.
- It is a column-oriented database.
- Its distribution design is based on Amazon’s Dynamo and its data model on Google’s Bigtable.
- Created at Facebook, it differs sharply from relational database management systems.
- Cassandra implements a Dynamo-style replication model with no single point of failure but adds a more powerful “column family” data model.
- Cassandra is being used by some of the biggest companies such as Facebook, Twitter,
- Cisco, Rackspace, eBay, Twitter, Netflix, and more.
Q9) What do you understand by Data Replication in Cassandra?
- Database replication is the frequent electronic copying of data from a database in one computer or server to a database in another so that all users share the same level of information.
- Cassandra stores replicas on multiple nodes to ensure reliability and fault tolerance. A replication strategy determines the nodes where replicas are placed. The total number of replicas across the cluster is referred to as the replication factor. A replication factor of 1 means that there is only one copy of each row on one node. A replication factor of 2 means two copies of each row, where each copy is on a different node. All replicas are equally important; there is no primary or master replica. As a general rule, the replication factor should not exceed the number of nodes in the cluster. However, you can increase the replication factor and then add the desired number of nodes later.
Q10) What do you understand by Node in Cassandra?
Ans: Node is the place where data is stored.
Q11) What do you understand by Datacenter in Cassandra?
Ans: Datacenter is a collection of related nodes.
Q12) What do you understand by Cluster in Cassandra?
Ans: Cluster is a component that contains one or more data centers.
Q13) What do you understand by Commit log in Cassandra?
Ans: The commit log is a crash-recovery mechanism in Cassandra. Every write operation is written to the commit log.
Q14) What do you understand by Mem-table in Cassandra?
Ans: Mem-table is a memory-resident data structure. After the commit log, the data will be written to the mem-table. Sometimes, for a single-column family, there will be multiple mem-tables.
Q15) What do you understand by SSTabl in Cassandra?
Ans: SSTable is a disk file to which the data is flushed from the mem-table when its contents reach a threshold value.
Q16) What do you understand by Bloom filter in Cassandra?
Ans: Bloom filter is nothing but quick, nondeterministic, algorithms for testing whether an element is a member of a set. It is a special kind of cache. Bloom filters are accessed after every query.
Q17) What do you understand by CQL?
Ans: User can access Cassandra through its nodes using Cassandra Query Language (CQL). CQL treats the database (Keyspace) as a container of tables. Programmers use cqlsh: a prompt to work with CQL or separate application language drivers.
Q18) What do you understand by Column Family?
Ans: Column family is a container for an ordered collection of rows. Each row, in turn, is an ordered collection of columns.
Q19) What is the use of the "void close()" method?
Ans: This method is used to close the current session instance.
Q20) What is the use of the "ResultSet execute(Statement statement)" method?
Ans: This method is used to execute a query. It requires a statement object.
Q21) Which command is used to start the cqlsh prompt?
Q22) What is the use of the "cqlsh --version" command?
Ans: This command will provides the version of the cqlsh you are using.
Q23) What are the collection data types provided by CQL?
- List: A list is a collection of one or more ordered elements.
- Map: A map is a collection of key-value pairs.
- Set: A set is a collection of one or more elements.
Q24) What is Cassandra's database used for?
Ans: Apache Cassandra is a second-generation distributed database originally open-sourced by Facebook. Its write-optimized shared-nothing architecture results in excellent performance and scalability. The Cassandra storage cluster and S3 archival layer are designed to expand horizontally to any arbitrary size with a linear cost. Cassandra’s memory footprint is more dependent on the number of column families than on the size of the data set. Cassandra scales pretty well horizontally for storage and IO, but not for memory footprint, which is tied to your schema and your cache settings regardless of the size of your cluster. some of the important links about Cassandra are available-here.
Q25) What is the syntax to create keyspace in Cassandra?
The syntax for creating keyspace in Cassandra is
CREATE KEYSPACE <identifier> WITH <properties>
Q26) What is a keyspace in Cassandra?
Ans: In Cassandra, a keyspace is a namespace that determines data replication on nodes. A cluster consists of one keyspace per node.
Q27) What is cqlsh?
Ans: cqlsh is a Python-based command-line client for Cassandra.
Q28) Does Cassandra works on Windows?
Ans: Yes, Cassandra works pretty well on windows. Right now we have Linux and Windows compatible versions available.
Q29) What do you understand by Consistency in Cassandra?
Ans: Consistency means to synchronize and how up-to-date a row of Cassandra data is on all of its replicas.
Q30) Explain Zero Consistency?
Ans: In this write, operations will be handled in the background, asynchronously. It is the fastest way to write data and the one that is used to offer the least confidence that operations will succeed.
Q31) What do you understand by Thrift?
Ans: Thrift is the name of the RPC client used to communicate with the Cassandra server.
Q32) What do you understand by Kundera?
Ans: Kundera is an object-relational mapping (ORM) implementation for Cassandra wrote using Java annotations.
Q33) What does JMX stand for?
Ans: JMX stands for Java Management Extension
Q34) How Cassandra provides a High availability feature?
Ans: Cassandra is a robust software. Nodes joining and leaving are automatically taken care of. With proper settings, Cassandra can be made failure resistant. That means that if some of the servers fail, the data loss will be zero. So, you can just deploy Cassandra over cheap commodity hardware or a cloud environment, where hardware or infrastructure failures may occur.
Inclined to build a profession as Cassandra Tutorials? Then here is the blog post on, explore Cassandra Tutorials
Q35) When to use Cassandra?
Ans: Being a part of the NoSQL family Cassandra offers solutions for a problem where your requirement is to have a very heavy write system and you want to have quite a responsive reporting system on top of that stored data. Consider the use case of Web analytic where log data is stored for each request and you want to build an analytical platform around it to count hits by the hour, by browser, by IP, etc in a real-time manner.
Q36) When should you not use Cassandra? OR When to use RDBMS instead of Cassandra?
Ans: Cassandra is based on the NoSQL database and does not provide ACID and relational data property. If you have a strong requirement of ACID property (for example Financial data), Cassandra would not be a fit in that case. Obviously, you can make work out of it, however, you will end up writing lots of application code to handle ACID property and will loose on time to market badly. Also managing that kind of system with Cassandra would be complex and tedious for you.
Q37) What are secondary indexes?
Ans: Secondary indexes are indexes built over column values. In other words, let’s say you have a user table, which contains a user’s email. The primary index would be the user ID, so if you wanted to access a particular user’s email, you could look them up by their ID. However, to solve the inverse query given an email, fetch the user ID requires a secondary index.
Q38) When to use secondary indexes?
Ans: You want to query on a column that isn't the primary key and isn't part of a composite key. The column you want to be querying on has few unique values (what I mean by this is, say you have a column Town, that is a good choice for secondary indexing because lots of people will form the same town, date of birth however will not be such a good choice).
Q39) When to avoid secondary indexes?
Ans: Try not using secondary indexes on columns contain a high count of unique values and that will produce few results.
Q40) I have a row or key cache hit rate of 0.XX123456789 reported by JMX. Is that XX% or 0.XX%?
Q41) What ports does Cassandra use?
Ans: By default, Cassandra uses 7000 for cluster communication, 9160 for clients (Thrift), and 8080 for JMX. These are all editable in the configuration file or bin/cassandra.in.sh (for JVM options). All ports are TCP.
Q42) What do you understand by High availability?
Ans: A high availability system is the one that is ready to serve any request at any time. High availability is usually achieved by adding redundancies. So, if one part fails, the other part of the system can serve the request. To a client, it seems as if everything worked fine.
For an in-depth knowledge of Cassandra, click on below
- Cassandra NoSQL
- How To Install Cassandra Ubuntu 14.04
- Cassandra Architecture
- CQL Datatypes in Cassandra
- CQL Collections in Cassandra
- Cassandra Data Types