Cassandra是否适合存储文件?

sia*_*one 19 data-storage file-storage cassandra nosql

我正在开发一个PHP平台,它将大量使用图像,文档和任何文件格式,这些都会在我脑海中浮现,所以我想知道Cassandra是否是我需要的好选择.

如果没有,你能告诉我应该如何存储文件吗?我想继续使用cassandra,因为它具有容错能力,并且在节点之间使用自动复制.

感谢帮助.

sbr*_*ges 13

来自cassandra wiki,

Cassandra's public API is based on Thrift, which offers no streaming abilities 
any value written or fetched has to fit in memory. This is inherent to Thrift's 
design and is therefore unlikely to change. So adding large object support to
Cassandra would need a special API that manually split the large objects up 
into pieces. A potential approach is described in http://issues.apache.org/jira/browse/CASSANDRA-265.    
As a workaround in the meantime, you can manually split files into chunks of whatever 
size you are comfortable with -- at least one person is using 64MB -- and making a file correspond 
to a row, with the chunks as column values.
Run Code Online (Sandbox Code Playgroud)

因此,如果您的文件<10MB,您应该没问题,只需确保限制文件大小,或将大文件分成块.

  • FWIW:Thrift API 已被弃用。但是“将大文件分块”规则似乎仍然存在。有一篇关于 Walmart 使用 Cassandra 存储大量图像文件的文章,讲了相同的策略:https://medium.com/walmartlabs/building-object-store-storing-images-in-cassandra-walmart-scale- a6b9c02af593 。 (2认同)

Chr*_*ain 6

您应该可以使用10MB的文件.事实上,如果我没有弄错的话,DataStax Brisk会将文件系统置于Cassandra之上:http://www.datastax.com/products/enterprise.

(我不会以任何方式与他们联系 - 这不是广告)


fga*_*akk 5

作为最新信息,Netflix为他们的cassandra客户端提供了名为astyanax的实用程序,用于将文件存储为经处理的对象存储。描述和示例可以在这里找到。最好使用astyanax编写一些测试并将Cassandra评估为文件存储是一个很好的起点。