mongodb 压缩——3.0+支持zlib和snappy

本文涉及的产品
云数据库 MongoDB,通用型 2核4GB
简介:

转自:https://scalegrid.io/blog/enabling-data-compression-in-mongodb-3-0/

MongoDB 3.0 with the wired tiger storage engine enables you to transparently compress the data stored in your database. This is a fairly exciting and useful feature that can be used to reduce the disk space usage of your fast growing data. By default wired tiger uses the ‘Snappy’ block compression engine for all the collections. You can turn off compression by default using the following options in the mongodb server config file .

1
2
3
4
5
storage:
   engine: wiredTiger
   wiredTiger:
     collectionConfig:
       blockCompressor: none

The compression algorithm can be specified at the collection level during cluster creation. Here is an example of creating a collection with ‘zlib’ compression

1
db.createCollection( "test" , {storageEngine:{wiredTiger:{configString: 'block_compressor=zlib' }}} );

MongoDB wiredtiger storage engine provides two options for compression – snappy and zlib. There is essentially a tradeoff between the extent of compression and the amount of CPU load to decompress. ‘Zlib’ achieves a lot more compression and is correspondingly less performant. ‘Snappy’ aims for ‘aims for very high speeds and reasonable compression’.

We ran some simple unscientific tests to measure the compression performance. We used one of data sets storing strings which we felt would compress well. Here is the basic structure of each document.

1
2
3
4
5
{
'_id' : <ObjectID>,
'name' : <Five character string>,
'value' : <Random 1MB string>
}

We inserted about 5000 of these documents (about 5GB of data). The results were fairly impressive. Zlib achieves considerable amount of compression. Snappy also achieves a fair amount of compression with little or no load on the system.

  Zlib Snappy uncompressed
Data size (MB) 5000.5 5000.5 5000.5
Storage size (MB) 19.62 254.37 5019

MongoDB 3.0 snappy vs zlib vs uncompressed

 

As always you need to run some tests to understand the performance gains for your data set.  Here are some more detailed benchmark studies on compression performance and tradeoffs

http://www.mongodb.com/blog/post/new-compression-options-mongodb-30
http://www.acmebenchmarking.com/2015/02/mongodb-v30-compression-benchmarks.html
https://comerford.cc/2015/02/04/mongodb-3-0-testing-compression/















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6289874.html,如需转载请自行联系原作者


相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。 &nbsp; 相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
相关文章
|
NoSQL 关系型数据库 MySQL
DLA支持分析MongoDB/RDS只读实例
在对Mysql,MongoDB等数据库系统进行分析时,经常面临的一个问题是在进行分析查询时如何避免对实时业务产生影响,也就是OLAP负载和OLTP负载隔离的问题。针对这个问题,阿里云数据湖团队一直在努力优化,提供满足不同场景的解决方案。
721 0
DLA支持分析MongoDB/RDS只读实例
|
运维 NoSQL atlas
MongoDB Server 3.4版本将于2020年1月31日停止支持
MongoDB日前宣布, MongoDB Server 3.4版本生命周期将于2020年1月31日结束,公司也将同步停止对3.4版本的支持工作。我们强烈建议大家将MongoDB升级到最新稳定版本(当前为4.2版本),本文提供了在线升级过程的文档链接。
|
Dubbo NoSQL 应用服务中间件
春节好消息 | Dubbo拥抱Apache,MongoDB支持事物……
大年初五好,一个年过了好些天了,软件方面都有哪些重大更新呢?我们一起来看看吧。 1.Dubbo通过投票正式进入Apache基金会孵化器 2018年2月9日,Apache基金会发起了是否允许阿里巴巴的分布式框架Dubbo项目进入Apache 孵化器的投票讨论。
1225 0
|
存储 NoSQL 分布式数据库
遇见未来 | MongoDB增强事务支持,向NewSQL的方向迈进
MongoDB于2009年发布,其最初的设计目标是性能和易于存取数据。作为文档数据库,允许数据以嵌套的状态保存,并且能够以任意方式查询嵌套的数据。这使得它能够灵活地处理各类大小任务,正因为多功能、强大、灵活,因而广泛被使用。
4986 0
|
存储 Web App开发 NoSQL
云数据库MongoDB全面支持3.4版本,支持多存储引擎
云数据库MongoDB全面支持MongoDB3.4版本,全面支持WiredTiger,RocksDB,TerarkDB三种存储引擎,本文讲述了云数据库MongoDB全面升级后,功能性能上有了哪些重大突破以及典型应用场景介绍。
1566 0