Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra: Issue with blob creation for large file

Tags:

cassandra

blob

We are trying to load a file in to a blob column in Cassandra. When we load files of 1-2 MB files, it goes through fine. While loading large file, say around 50 MB, getting following error:

Cassandra failure during write query at consistency LOCAL_QUORUM (1 responses were required but only 0 replica responded, 1 failed)

It is a single node development DB. Any hints or support will be appreciated.

like image 319
Ashok Setty Avatar asked Oct 19 '22 04:10

Ashok Setty


1 Answers

50mb is pretty big for a cell. Although a little out of date its still accurate: http://cassandra.apache.org/doc/4.0/faq/#can-large-blob

There is no mechanism for streaming out of cells in Cassandra so the cells content needs to be serialized in as single response, in memory. Your probably hitting a limit or bug somewhere thats throwing an exception and causing the failed query (check cassandras system.log, may be an exception in there that will describe whats occuring better).

If you have a CQL collection or logged batch there are additional lower limits. http://docs.datastax.com/en/cql/3.3/cql/cql_reference/refLimits.html

You can try chunking your blobs into parts. Id actually recommend like 64kb, and on client side, iterate through them and generate a stream (to also prevent loading it completely in memory on your side).

CREATE TABLE exampleblob (
  blobid text,
  chunkid int,
  data blob,
  PRIMARY KEY (blobid, chunkid));

Then just SELECT * FROM exampleblob WHERE blobid = 'myblob'; and iterate through results. Inserting gets more complex though since you have to have logic to split up your file, this can also be done in streaming fashion though and be memory efficient on your app side.

Another alternative is to just upload the blob to S3 or some distributed file store, use a hash of the file as the bucket/filename. In Cassandra just store the filename as a reference to it.

like image 89
Chris Lohfink Avatar answered Oct 21 '22 05:10

Chris Lohfink