High-performance distributed analytical database + Spark SQL queries + built for streaming.
_______ __ ____ ____ / ____(_) /___ / __ \/ __ ) / /_ / / / __ \/ / / / __ | / __/ / / / /_/ / /_/ / /_/ / /_/ /_/_/\____/_____/_____/
Columnar, versioned layers of data wrapped in a yummy high-performance analytical database engine.
See architecture and datasets and reading for more information. Also see the Spark Notebooks under
doc... there is one for time-series/geo analysis of the NYC Taxi dataset, and one for interactive charting of the GDELT dataset!
Table of Contents generated with DocToc
- Getting Started
- Introduction to FiloDB Data Modelling
- Using FiloDB Data Source with Spark
- Using the CLI
- Current Status
- Monitoring and Metrics
- Code Walkthrough
- Building and Testing
- You can help!
FiloDB is a new open-source distributed, versioned, and columnar analytical database designed for modern streaming workloads.
- High performance - competitive with Parquet scan speeds, plus filtering along two or more dimensions
- Very flexible filtering: filter on only part of a partition key, much more flexible than allowed in Cassandra
- Much faster bulk ingestion than raw Cassandra tables
- Compact storage - within 35% of Parquet for CassandraColumnStore
- Up to 27x more data stored per GB, compared to Cassandra 2.x, in real world fact table storage
- See the blog post on Apache Cassandra for analytics: a performance and storage analysis
- Idempotent writes - primary-key based appends and updates; easy exactly-once ingestion from streaming sources
- Distributed - pluggable storage engine includes Apache Cassandra and in-memory
- Low-latency - minimal SQL query latency of 15ms on one node; sub-second easily achievable with filtering and easy to use concurrency control
- SQL queries - plug in Tableau or any tool using JDBC/ODBC drivers
- Ingest from Spark/Spark Streaming from any supported Spark data source
Overview presentation -- see the docs folder for design docs.
To compile the .mermaid source files to .png's, install the Mermaid CLI.
- Storage and analysis of streaming event / time series data
- Data warehousing
- In-memory database for Spark Streaming analytics
- Low-latency in-memory SQL database engine
- Heavily transactional, update-oriented workflows
Your input is appreciated!
NOTE: Please beware that significant storage-layer changes are taking place. For a stable version, please use the
v0.4 release/tag. At the next release, the storage layer should be stable for production use.
- Kafka input API / connector (without needing Spark)
- In-memory caching for significant query speedup
- True columnar querying and execution, using late materialization and vectorization techniques. GPU/SIMD.
- Projections. Often-repeated queries can be sped up significantly with projections.
- Java 8
- SBT to build
- Apache Cassandra 2.x or 3.x (We prefer using CCM for local testing) (Optional if you are using the in-memory column store)
- Apache Spark (2.0)
NOTE: Please check out the
spark1.6 branch for Spark 1.6 version.
Clone the project and cd into the project directory,
$ git clone https://github.com/tuplejump/FiloDB.git $ cd FiloDB
- It is recommended you use the last stable released version.
- To build, run
filo-cli(see below) and also
Choose either the Cassandra column store (default) or the in-memory column store.
- Start a Cassandra Cluster.
core/src/main/resources/filodb-defaults.confand modify the Cassandra settings for your cluster. This step and passing in a custom config may be skipped for a localhost Cassandra cluster with no auth.
- Or, use FiloDB's in-memory column store with Spark (does not work with CLI). Pass the
spark-shell. This is a great option to test things out, and is really really fast!
For Cassandra, update the
keyspace-replication-optionsconfig, then run
filo-cli -Dconfig.file=/path/to/my/filo.conf --command initto initialize the default
filodb_adminkeyspace. In addition, you should use CQLSH to create any additional keyspaces you desire to store FiloDB datasets in.
- Dataset creation can be done using
filo-clior using Spark Shell / Scala/Java API.
- Inserting data can be done using
filo-cli(CSV only), using Spark SQL/JDBC (INSERT INTO), or the Spark Shell / Scala / Java API.
- Querying is done using Spark SQL/JDBC or Scala/Java API.
- Listing/deleting/maintenance can be done using
filo-cli. If using Cassandra,
cqlshcan also be used to inspect metadata.
Note: There is at least one release out now, tagged via Git and also located in the "Releases" tab on Github.
Introduction to FiloDB Data Modelling
Perhaps it's easiest by starting with a diagram of how FiloDB stores data.
|Column A||Column B|
|Partition key 1||Segment 1||Segment 2||Segment 1||Segment 2|
|Partition key 2||Segment 1||Segment 2||Segment 1||Segment 2|
Three types of key define the data model of a FiloDB table.
- partition key - decides how data is going to be distributed across the cluster. All data within one partition key is guaranteed to fit on one node. May consist of multiple columns.
- segment key - groups row values into efficient chunks. Segments within a partition are sorted by segment key and range scans can be done over segment keys.
- row key - acts as a primary key within each partition and decides how data will be sorted within each segment. May consist of multiple columns.
The PRIMARY KEY for FiloDB consists of (partition key, segment_key, row key). When choosing the above values you must make sure the combination of the three are unique. If any component of a primary key contains a null value, then a default value will be substituted.
Specifying the partitioning column is optional. If a partitioning column is not specified, FiloDB will create a default one with a fixed value, which means everything will be thrown into one node, and is only suitable for small amounts of data. If you don't specify a partitioning column, then you have to make sure combination of segment key and row key values are all unique.
For examples of data modeling and choosing keys, see the examples below as well as datasets.
For additional information refer to Data Modeling and Performance Considerations.
You may specify a function, or computed column, for use with any key column, except for row keys. This is especially useful for computing a good segment key, or hashing values to generate a good partition key.
|string||returns a constant string value||
|getOrElse||returns default value if column value is null. This is not needed most of the time as FiloDB will use a default value in case of null, though
|round||rounds down a numeric column. Useful for bucketing by time or bucketing numeric IDs.||
|stringPrefix||takes the first N chars of a string; good for partitioning||
|hash||hashes keys of any type to an int between 0 and N||
|timeslice||bucketizes a Long (millisecond) or Timestamp column using duration strings - 500ms, 5s, 10m, 3h, etc.||
|monthOfYear||return 1 to 12 (IntColumn) for the month number of a Long (millisecond) or Timestamp column||
FiloDB vs Cassandra Data Modelling
- Like Cassandra, partitions (physical rows) distribute data and clustering keys act as a primary key within a partition
- Like Cassandra, a single partition is the smallest unit of parallelism when querying from Spark
- Wider rows work better for FiloDB (bigger chunk/segment size)
- FiloDB does not have Cassandra's restrictions for partition key filtering. You can filter by any partition keys with most operators. This means less tables in FiloDB can match more query patterns.
- Cassandra range scans over clustering keys is available over the segment key
Data Modelling and Performance Considerations
Choosing Partition Keys.
- Partition keys are the most efficient way to filter data. Remember that, unlike Cassandra, FiloDB is able to efficiently filter any column in a partition key -- even string contains, IN on only one column. It can do this because FiloDB pre-scans a much smaller table ahead of scanning the main columnar chunk table. This flexibility means that there is no need to populate different tables with different orders of partition keys just to optimize for different queries.
- If there are too few partitions, then FiloDB will not be able to distribute and parallelize reads.
- If the numer of rows in each partition is too few, then the storage will not be efficient.
- If the partition key is time based, there may be a hotspot in the cluster as recent data is all written into the same set of replicas, and likewise for read patterns as well.
- Consider picking a column or group of columns with low cardinality, and has good distribution so that data is distributed across the cluster.
- Consider only those columns that do not get updated. Since partition key is part of primary key, partition key columns cannot get updated.
Segment Key and Chunk Size.
Within each partition, data is delineated by the segment key into segments. Within each segment, successive flushes of the MemTable writes data in chunks. The segmentation is key to sorting and filtering data within partitions, and the chunk size (which depends on segmentation) also affects performance. The smaller the chunk size, the higher the overhead of scanning data becomes.
Segmentation and chunk size distribution may be checked by the CLI
analyze command. In addition, the following configuration affects segmentation and chunk size:
memtable.flush-trigger-rowsaffects how many rows are kept in the MemTable at a time, and this along with how many partitions are in the MemTable directly leads to the chunk size upon flushing.
- The segment size is directly controlled by the segment key. Choosing a segment key that groups data into big enough chunks (at least 1000 is a good guide) is highly recommended. Experimentation along with running
filo-cli analyzeis recommended to come up with a good segment key. See the Spark ingestion of GDELT below on an example... choosing an inappropriate segment key leads to MUCH slower ingest and read performance.
chunk_sizeoption when creating a dataset caps the size of a single chunk.
- Avoid picking any column that has the possibility of getting updated as a segment key column.
- Consider a low cardinal column within partition for segment key. Ideal segment key will hold at least 1000 values in a chunk as explained above. Use a computed column like
:string /0as the segment key if there are no good candidates available or your chosen segment key has potential to hold very few values in chunks under each segment key.
- Consider moving one of the partition keys as segment keys if your partition is not too wide. Use the
analyzefilo-cli command to discover partition size.
- Cosider creating computed columns to make good segment key. Ex: Rounding date to month etc.
- Ideal segment key would have chunks filled with thousands of values and frequently gets used as filter in queries.
To help with planning, here is an exact list of the predicate pushdowns (in Spark) that help with reducing I/O and query times:
- Partition key column(s): =, IN on any partition key column
- = on every partition key results in a single-partition query
- = or IN on every partition key results in a multi-partition query, still faster than full table scan
- Otherwise, a filtered full table scan results - partitions not matching predicates will not be scanned
- Segment key: must be of the form
segmentKey >/>= value AND segmentKey </<= valueor
segmentKey = valueSegment Key predicates will pushdown to cassandra if your storage engine is in Cassandra. FiloDB segment keys map to cluster key of the underlying cassandra storage.
Note: You can see predicate pushdown filters in application logs by setting logging level to INFO.
Example FiloDB Schema for machine metrics
This is one way I would recommend setting things up to take advantage of FiloDB.
The metric names are the column names. This lets you select on just one metric and effectively take advantage of columnar layout.
- Partition key = hostname
- Row key = timestamp (say millis)
- Segment key =
:round timestamp 10000(Timestamp rounded to nearest 10000 millis or 10 seconds)
- Columns: hostname, timestamp, CPU, load_avg, disk_usage, etc.
You can add more metrics/columns over time, but storing each metric in its own column is FAR FAR more efficient, at least in FiloDB. For example, disk usage metrics are likely to have very different numbers than load_avg, and so Filo can optimize the storage of each one independently. Right now I would store them as ints and longs if possible.
With the above layout, as long as there aren’t too many hostnames, set the memtable max size and flush trigger to both high numbers, you should get good read performance. Queries that would work well for the above layout:
- SELECT avg(load_avg), min(load_avg), max(load_avg) FROM metrics WHERE timestamp > t1 AND timestamp < t2 etc.
Queries that would work well once we expose a local Cassandra query interface:
- Select metrics from one individual host
Another possible layout is something like this:
- Partition key = hostname % 1024 (or pick your # of shards)
- Row key = hostname, timestamp
FiloDB will automatically form a cluster (via Akka Cluster), divide the range of partition keys amongst the nodes using a consistent-hashing algorithm, and re-route incoming records to the right ingestion node. Thus, users no longer need to sort their incoming data in Spark.
Using FiloDB Data Source with Spark
FiloDB has a Spark data-source module -
filodb.spark. So, you can use the Spark Dataframes
write APIs with FiloDB. To use it, follow the steps below
- Start Cassandra and update project configuration if required.
- From the FiloDB project directory, execute,
$ sbt clean $ ./filo-cli --command init $ sbt spark/assembly
- Use the jar
FiloDB/spark/target/scala-2.10/filodb-spark-assembly-0.4.jarwith Spark 1.6.x.
The options to use with the data-source api are:
|dataset||name of the dataset||read/write||No|
|database||name of the database to use for the dataset. For Cassandra, defaults to
|row_keys||comma-separated list of column name(s) to use for the row primary key within each partition. Computed columns are not allowed.||write||No if mode is OverWrite or creating dataset for first time|
|segment_key||name of the column (could be computed) to use to group rows into segments in a partition.||write||yes - defaults to
|partition_keys||comma-separated list of column name(s) or computed column functions to use for the partition key. If not specified, defaults to
|splits_per_node||number of read threads per node, defaults to 4||read||Yes|
|reset_schema||If true, allows dataset schema (eg partition keys) to be redefined for an existing dataset when SaveMode.Overwrite is used. Defaults to false.||write||Yes|
|chunk_size||Max number of rows to put into one chunk. Note that this only has an effect if the dataset is created for the first time.||write||Yes|
|flush_after_write||initiates a memtable flush after Spark INSERT / DataFrame.write; this ensures all the rows are flushed to ColumnStore. Might want to be turned off for streaming||write||yes - default true|
|version||numeric version of data to write, defaults to 0||read/write||Yes|
Partitioning columns could be created using an expression on the original column in Spark:
val newDF = df.withColumn("partition", df("someCol") % 100)
or even UDFs:
val idHash = sqlContext.udf.register("hashCode", (s: String) => s.hashCode()) val newDF = df.withColumn("partition", idHash(df("id")) % 100)
However, note that the above methods will lead to a physical column being created, so use of computed columns is probably preferable.
Some options must be configured before starting the Spark Shell or Spark application. FiloDB executables are invoked by spark application. These configuration settings can be tuned as per the needs of individual application invoking filoDB executables. There are two methods:
- Modify the
application.confand rebuild, or repackage a new configuration.
- Override the built in defaults by setting SparkConf configuration values, preceding the filo settings with
spark.filodb. For example, to change the default keyspace, pass
--conf spark.filodb.cassandra.keyspace=mykeyspaceto Spark Shell/Submit. To use the fast in-memory column store instead of Cassandra, pass
- It might be easier to pass in an entire configuration file to FiloDB. Pass the java option
-Dfilodb.config.file=/path/to/my-filodb.conf, for example using
Note that if Cassandra is kept as the default column store, the keyspace can be changed on each transaction by specifying the
database option in the data source API, or the database parameter in the Scala API.
For a list of all configuration params as well as a template for a config file, see the
filodb_defaults.conf file included in the source and packaged with the jar as defaults.
For metrics system configuration, see the metrics section below.
Passing Cassandra Authentication Settings
Typically, you have per-environment configuration files, and you do not want to check in username and password information. Here are ways to pass in authentication settings:
- Pass in the credentials on the command line.
- For Spark,
- For CLI, other apps, pass in JVM args:
- For Spark,
Put the credentials in a local file on the host, and refer to it from your config file. In your config file, do
include "/usr/local/filodb-cass-auth.properties". The properties file would look like:
Spark Data Source API Example (spark-shell)
You can follow along using the Spark Notebook... launch the notebook using
EXTRA_CLASSPATH=$FILO_JAR ADD_JARS=$FILO_JAR ./bin/spark-notebook & where
FILO_JAR is the path to
filodb-spark-assembly jar. See the FiloDB_GDELT notebook to follow the GDELT examples below, or the NYC Taxi notebook for some really neat time series/geo analysis!
Or you can start a spark-shell locally,
bin/spark-shell --jars ../FiloDB/spark/target/scala-2.11/filodb-spark-assembly-0.7.0.spark20-SNAPSHOT.jar --packages com.databricks:spark-csv_2.11:1.4.0 --driver-memory 3G --executor-memory 3G
Loading CSV file from Spark:
scala> val csvDF = spark.read.format("com.databricks.spark.csv"). option("header", "true").option("inferSchema", "true"). load("../FiloDB/GDELT-1979-1984-100000.csv")
Creating a dataset from a Spark DataFrame,
scala> import org.apache.spark.sql.SaveMode import org.apache.spark.sql.SaveMode scala> csvDF.write.format("filodb.spark"). option("dataset", "gdelt"). option("row_keys", "GLOBALEVENTID"). option("segment_key", ":round GLOBALEVENTID 10000"). option("partition_keys", "MonthYear"). mode(SaveMode.Overwrite).save()
Above, we partition the GDELT dataset by MonthYear, creating roughly 72 partitions for 1979-1984, with the unique GLOBALEVENTID used as a row key. We group every 10000 eventIDs into a segment using the convenient
:round computed column (GLOBALEVENTID is correlated with time, so in this case we could pack segments with consecutive EVENTIDs). You could use multiple columns for the partition or row keys, of course. For example, to partition by country code and year instead:
scala> csvDF.write.format("filodb.spark"). option("dataset", "gdelt_by_country_year"). option("row_keys", "GLOBALEVENTID"). option("segment_key", ":string 0"). option("partition_keys", "Actor2CountryCode,Year"). mode(SaveMode.Overwrite).save()
Note that in the above case, since events are spread over a much larger number of partitions, it no longer makes sense to use GLOBALEVENTID as a segment key - at least with the original 10000 as a rounding factor. There are very few events for a given country and year within the space of 10000 event IDs, leading to inefficient storage. Instead, we use a single segment for each partition. We probably could have used
:round GLOBALEVENTID 500000 or some other bigger factor as well. Using
:round GLOBALEVENT 10000 lead to 3x slower ingest and at least 5x slower reads.
The key definitions can be left out for appends:
sourceDataFrame.write.format("filodb.spark"). option("dataset", "gdelt"). mode(SaveMode.Append).save()
Note that for efficient columnar encoding, wide rows with fewer partition keys are better for performance.
By default, data is written to replace existing records with the same primary key. To turn this primary key replacement off for faster ingestion, set
Reading the dataset,
val df = spark.read.format("filodb.spark").option("dataset", "gdelt").load()
The dataset can be queried using the DataFrame DSL. See the section Querying Datasets for examples.
Note: For your production data loads sort the data frame before saving to FiloDB when the data source is not Cassandra. This will ensure to efficiently load segment chunks. Refer to Distributed Partitioning for additional info.
There is a more typesafe API than the Spark Data Source API.
import filodb.spark._ spark.saveAsFilo(df, "gdelt", rowKeys = Seq("GLOBALEVENTID"), segmentKey = ":round GLOBALEVENTID 10000", partitionKeys = Seq("MonthYear"))
The above creates the gdelt table based on the keys above, and also inserts data from the dataframe df.
NOTE: If you are running Spark Shell in DSE, you might need to do
Please see the ScalaDoc for the method for more details -- there is a
database option for specifying the Cassandra keyspace, and a
mode option for specifying the Spark SQL SaveMode.
There is also an API purely for inserting data... after all, specifying the keys is not needed when inserting into an existing table.
import filodb.spark._ spark.insertIntoFilo(df, "gdelt")
The API for creating a DataFrame is also much more concise:
val df = spark.filoDataset("gdelt") val df2 = spark.filoDataset("gdelt", database = Some("keyspace2"))
The above method calls rely on an implicit conversion. From Java, you would need to create a new
FiloContext fc = new filodb.spark.FiloContext(sparkSession.sqlContext); fc.insertIntoFilo(df, "gdelt");
Spark Streaming Example
It's not difficult to ingest data into FiloDB using Spark Streaming. Simple use
foreachRDD on your
DStream and then transform each RDD into a DataFrame.
For an example, see the StreamingTest.
bin/spark-sql --jars path/to/FiloDB/spark/target/scala-2.10/filodb-spark-assembly-0.4.jar
(NOTE: if you want to connect with a real Hive Metastore, you should probably instead start the thrift server, also adding the
--jars above, and then start the
Create a temporary table using an existing dataset,
create temporary table gdelt using filodb.spark options ( dataset "gdelt" );
Then, start running SQL queries!
You probably want to create a permanent Hive Metastore entry so you don't have to run
create temporary table every single time at startup:
CREATE TABLE gdelt using filodb.spark options (dataset "gdelt");
Once this is done, you could insert data using SQL syntax:
INSERT INTO TABLE gdelt SELECT * FROM othertable;
Of course, this assumes
othertable has a similar schema.
Now do some queries, using the DataFrame DSL:
scala> df.select(count(df("MonthYear"))).show() ...<skipping lots of logging>... COUNT(MonthYear) 4037998
or SQL, to find the top 15 events with the highest tone:
scala> df.registerTempTable("gdelt") scala> sqlContext.sql("SELECT Actor1Name, Actor2Name, AvgTone FROM gdelt ORDER BY AvgTone DESC LIMIT 15").collect() res13: Array[org.apache.spark.sql.Row] = Array([208077.29634561483])
Now, how about something uniquely Spark .. feed SQL query results to MLLib to compute a correlation:
scala> import org.apache.spark.mllib.stat.Statistics scala> val numMentions = df.select("NumMentions").map(row => row.getInt(0).toDouble) numMentions: org.apache.spark.rdd.RDD[Double] = MapPartitionsRDD at map at DataFrame.scala:848 scala> val numArticles = df.select("NumArticles").map(row => row.getInt(0).toDouble) numArticles: org.apache.spark.rdd.RDD[Double] = MapPartitionsRDD at map at DataFrame.scala:848 scala> val correlation = Statistics.corr(numMentions, numArticles, "pearson")
Notes: You can also query filoDB tables using Spark thrift server. Refer to SQL/Hive Example for additional information regarding thrift server.
FiloDB logs can be viewed in corresponding spark application logs by setting appropriate settings in
logback.xml for DSE.
Using the CLI
filo-cli accepts arguments as key-value pairs. The following keys are supported:
|dataset||It is required for all the operations. Its value should be the name of the dataset|
|database||Specifies the "database" the dataset should operate in. For Cassandra, this is the keyspace. If not specified, uses config value.|
|limit||This is optional key to be used with
|columns||This is required for defining the schema of a dataset. Its value should be a comma-separated string of the format,
|rowKeys||This is required for defining the row keys. Its value should be comma-separated list of column names or computed column functions to make up the row key|
|segmentKey||The column name or computed column for the segment key|
|partitionKeys||Comma-separated list of column names or computed columns to make up the partition key|
|command||Its value can be either of
Note: The sort column is not optional.
Note: The CSV file should be delimited with comma and have a header row. The column names must match those specified when creating the schema for that dataset.
delete command is used to delete datasets, like a drop.
truncate truncates data for an existing dataset to 0. |
| select | Its value should be a comma-separated string of the columns to be selected,
./filo-cli --dataset playlist --select album,title
The result from
select is printed in the console by default. An output file can be specified with the key
--outfile. For example,
./filo-cli --dataset playlist --select album,title --outfile playlist.csv |
| delimiter | This is optional key to be used with
importcsv command. Its value should be the field delimiter character. Default value is comma. |
| numSegments | The maximum number of segments to analyze for the analyze command. Prevents analyze of large tables from taking too long. Defaults to 10000. |
| timeoutSeconds | The number of seconds for timeout for initialization, table creation, other quick things |
Running the CLI
You may want to customize a configuration to point at your Cassandra cluster, or change other configuration parameters. The easiest is to pass in a customized config file:
./filo-cli -Dfilodb.config.file=/path/to/myfilo.conf --command init
You may also set the
FILO_CONFIG_FILE environment var instead, but any
-Dfilodb.config.file args passed in takes precedence.
Individual configuration params may also be changed by passing them on the command line. They must be the first arguments passed in. For example:
./filo-cli -Dfilodb.columnstore.segment-cache-size=10000 --command ingestcsv ....
-D config options must be passed before any other arguments.
You may also configure CLI logging by copying
cli/src/main/resources/logback.xml to your deploy folder, customizing it, and passing on the command line
You can also change the logging directory by setting the FILO_LOG_DIR environment variable before calling the CLI.
NOTE: The CLI currently only operates on the Cassandra column store. The
--database option may be used to specify which keyspace to operate on. If the keyspace is not initialized, then FiloDB code will automatically create one for you, but you may want to create it yourself to control the options that you want.
The following examples use the GDELT public dataset and can be run from the project directory.
Create a dataset with all the columns :
Verify the dataset metadata:
./filo-cli --command list --dataset gdelt
Import data from a CSV file:
./filo-cli --command importcsv --dataset gdelt --filename GDELT-1979-1984-100000.csv
Query/export some columns:
./filo-cli --dataset gdelt --select MonthYear,Actor2Code --limit 5 --outfile out.csv
Version 0.4 is the stable, latest released version. It has been tested on a cluster for a different variety of schemas, has a stable data model and ingestion, and features a huge number of improvements over the previous version.
Upcoming version 0.7 changes:
- NEW storage layout with incremental indices, provides much better ingestion for large partitions and skewed data
- Spark 2.0 and Scala 2.11 (master branch)
- Automatic routing of ingestion records across the network - no need to
sortyour DataFrame in Spark
- creating a function for checking java and another to check sbt (@jenaiz)
Version 0.4 change list:
- Defaults to Spark 1.6.1
- New metrics and monitoring framework based on Kamon.io, with built in stats logging and statsd output, and tracing of write path
- Replaced Phantom with direct usage of Java C* driver. Bonus: use prepared statements, should result in better performance all around especially on ingest; plus supports C* 3.0+
- WHERE clauses specifying multiple partition keys now get pushed down. Should result in much better read performance in those cases.
- New :hash function makes it easier to hash partition key components into smaller cardinality (but specify the full key in WHERE clauses)
- New config
filodb.cassandra.keyspace-replication-optionsallows any CQL replication option to be set when FiloDB keyspaces are created with CLI --command init
- A few new configs for Cassandra CQL / chunk / sstable compression; can help improve remote read performance
- CLI log directory can be easily changed with FILO_LOG_DIR env var
- CLI analyze command can now analyze segments from multiple partitions up to a configurable maximum # of segments
- Allow comma-separated list of hosts for
- Fix missing data on read issue with wrapping token ranges in C*
- Fix actor path uniqueness issue on ingestion
- sbt spark/assembly
- sbt cli/assembly
core/src/main/resources/application.confand modify as needed for your own config file
- Set FILO_CONFIG_FILE to the path to your custom config
- Run the cli jar as the filo CLI command line tool and initialize keyspaces if using Cassandra:
filo-cli-*.jar --command init
Note that if you are using DSE or have vnodes enabled, a lower number of vnodes (16 or less) is STRONGLY recommended as higher numbers of vnodes slows down queries substantially and basically prevents subsecond queries from happening.
By default, FiloDB nodes (basically all the Spark executors) talk to each other using a random port and locally assigned hostname. You may wish to set
filodb.spark.executor.port to assign specific ports (for AWS, for example) or possibly use a different config file on each host and set
akka.remote.netty.tcp.hostname on each host's config file.
Monitoring and Metrics
FiloDB uses Kamon for metrics and Akka/Futures/async tracing. Not only does this give us summary statistics, but this also gives us Zipkin-style tracing of the ingestion write path in production, which can give a much richer picture than just stats.
- statsd sink - this is packaged into FiloDB's spark module (but not the CLI module) by default. All you need to do is stand up statsd, Statsite, or equivalent daemon. See the Kamon Statsd module guide for configuration.
- Kamon metrics logger - this is part of the coordinator module and will log all metrics (including segment trace metrics) at every Kamon tick interval, which defaults to 10 seconds. It is disabled by default but could be enabled with
--conf spark.filodb.metrics-logger.enabled=trueor changing
filodb.metrics-logger.enabledin your conf file. Also, which metrics to log including pattern matching on names can be configured.
- Kamon trace logger - this logs detailed trace information on segment appends and is always on if detailed tracing is on.
Kamon has many configurable options. To get more detailed traces on the write / segment append path, for example, here is how you might pass to
spark-shell options to set detailed tracing on and to trace 3% of all segment appends:
--driver-java-options '-XX:+UseG1GC -XX:MaxGCPauseMillis=500 -Dkamon.trace.level-of-detail=simple-trace -Dkamon.trace.random-sampler.chance=3'
To change the metrics flush interval, you can set
kamon.statsd.flush-interval. The statsd flush-interval must be equal to or greater than the tick-interval.
Methods of configuring Kamon (except for the metrics logger):
- The best way to configure Kamon is to pass this Java property:
-Dkamon.config-provider=filodb.coordinator.KamonConfigProvider. This lets you configure Kamon through the same mechanisms as the rest of FiloDB:
-Dfilo.config.filefor example, and the configuration is automatically passed to each executor/worker. Otherwise:
- Passing Java options on the command line with
-D, or for Spark,
- Passing options in a config file and using
-Dfilo.config.filewill not work because Kamon uses a different initialization stack. Need to be done for both drivers and executors.
Please go to the architecture doc.
Building and Testing
Run the tests with
sbt test, or for continuous development,
sbt ~test. Noisy cassandra logs can be seen in
To run benchmarks, from within SBT:
cd jmh jmh:run -i 5 -wi 5 -f3
You can get the huge variety of JMH options by running
There are also stress tests in the stress module. See the Stress README.
You can help!
Contributions are welcome!