MongoDB3.0中的压缩选项

在MongoDB 3.0中,WiredTiger为集合提供三个压缩选项:

  1. 无压缩
  2. Snappy(默认启用) – 很不错的压缩,有效利用资源
  3. zlib(类似gzip) – 出色的压缩,但需要占用更多资源

有索引的两个压缩选项:

  1. 无压缩
  2. 前缀(默认启用) – 良好的压缩,资源的有效利用

请记住哪些适用于MongoDB的3.0所有压缩选项:

  1. 随机数据不能压缩
  2. 二进制数据不能压缩(它可能已经被压缩)
  3. 文本压缩效果特别好
  4. 对于文件中的字段名压缩效果特别好(尤其对短字段名来说)

官方说法:

Compression

With WiredTiger, MongoDB supports compression for all collections and indexes. Compression minimizes storage use at the expense of additional CPU.

By default, WiredTiger uses block compression with the snappy compression library for all collections andprefix compression for all indexes.

For collections, block compression with zlib is also available. To specify an alternate compression algorithm or no compression, use the storage.wiredTiger.collectionConfig.blockCompressor setting.

For indexes, to disable prefix compression, use thestorage.wiredTiger.indexConfig.prefixCompression setting.

Compression settings are also configurable on a per-collection and per-index basis during collection and index creation. See Specify Storage Engine Options and db.collection.createIndex() storageEngine option.

For most workloads, the default compression settings balance storage efficiency and processing requirements.

The WiredTiger journal is also compressed by default. For information on journal compression, see Journal.

MongoDB 3.0 WiredTiger Compression and Performance

  • 转自:http://objectrocket.com/blog/company/mongodb-wiredtiger

One of the most exciting developments over the lifetime of MongoDB must be the inclusion of the WiredTiger storage engine in MongoDB 3.0. Its very design and core architecture are legions ahead of the current MMAPv1 engine and comparable to most modern day storage engines for various relational and non-relational stores. One of the most compelling features of the WiredTiger storage engine is compression. Let's talk a bit more about performance and compression.

Configuration

MongoDB 3.0 allows the user to configure different storage engines through the storage engine API. For the first time ever we have an amazing array of options for setting up MongoDB to match our workloads and use-cases. To run WiredTiger the version must be 3.0 or higher and the configuration file must call for WiredTiger. For example:

storage:dbPath: "/data/mongodb" journal: enabled: true engine: "wiredTiger" wiredTiger: engineConfig: cacheSizeGB: 99 journalCompressor: none directoryForIndexes: "/indexes/mongodb/" collectionConfig: blockCompressor: snappy indexConfig: prefixCompression: true systemLog: destination: file path: "/tmp/mongodb.log" logAppend: true processManagement: fork: true net: port: 9005 unixDomainSocket: enabled : true 

There are a lot of new configuration options in 3.0 so let's take the notable options one by one.

  • storage.engine. The setting ensures we are using the WiredTiger storage engine. Should be set to "wiredTiger" to use the WiredTiger engine. It can also be set to "mmapv1". MMAPv1 is the default in 3.0, but in MongoDB 3.1 (potentially) this will change to wiredTiger.

  • storage.wiredTiger.engineConfig.cacheSizeGB. This sets up a page cache for WiredTiger to cache frequently used data and index blocks in GB. If this is not specified, MongoDB will automatically assign memory up to about 50% of total addressable memory.

  • storage.wiredTiger.engineConfig.directoryForIndexes. Yes! We can now store indexes on a separate block device. This should help DBAs size, capacity plan, and augment performance as needed.

  • storage.wiredTiger.collectionConfig.blockCompressor. This can be set to 'snappy' or 'zlib'. Snappy having higher performance and lower compression than zlib. Some more detail later on compression algorithms.

  • storage.wiredTiger.indexConfig.prefixCompression. This setting enables prefix compression for indexes. Valid options are true|false and the default is true.

Let's talk performance

WiredTiger is going to be much faster than MMAPv1 for almost all workloads. Its real sweet spot is highly concurrent and/or workloads with lots of updates. This may surprise some folks because traditionally compression is a trade off. Add compression, lose performance. That is normally true, but a couple of things need to be considered here. One, we are comparing the MMAPv1 engine with database level locking to WiredTiger with document level locking. Any reasonable concurrent workload is almost always bound by locking and seldom by pure system level resources. Two, WiredTiger does page level compression. More on this later.

There are a few things that make WiredTiger faster other than its locking scope. WiredTiger also has a streamlined process for free space lookups and management and it has a proper cache with its own I/O components.

Because WiredTiger allows for compression, a common worry is the potential for overall performance impact. But as you can see, in a practical sense this worry is mostly unfounded.

A couple graphs for relative performance difference for sysbench-mongodb. It should be noted that WiredTiger is using defaults in this configuration, including snappy compression and index prefix compression.

Let's break it down a bit more:

The relative CPU usage for each:

Let's talk more about compression

Compressing data inside a database is tricky. WiredTiger does a great job at handling compression because of its sophisticated management approach:

The cache generally stores uncompressed changes (the exception is for very large documents). The default snappy compression is fairly straightforward: it gathers data up to a maximum of 32KB, compresses it, and if compression is successful, writes the block rounded up to the nearest 4KB.

The alternative zlib compression works a little differently: it will gather more data and compress enough to fill a 32KB block on disk. This is more CPU intensive but generally results in better compression ratios (independent of the inherent differences between snappy and zlib).

—Michael Cahill

This approach is great for performance. But compression still has overhead and can vary in effectiveness. What this means for users is two-fold:

  • Not all data sets compress equally, it depends on the data format itself.
  • Data compression is temporal. One day being better than another depending on the specific workload.

One approach is to take a mongodump of the dataset in question then mongorestore that data to a compressed WiredTiger database and measure the difference. This gives a rough measurement of what one can expect the compression ratio to be. That said, as soon as the new compressed database starts taking load, that compression ratio may vary. Probably not by a massive margin however.

It should be noted there are some tricky bits to consider when running a database using compression. Because WiredTiger compresses each page before it hits the disk the memory region is uncompressed. This means that highly compressed data will have a large ratio between its footprint on disk and the cache that serves it. Poorly compressed data the opposite. The effect may be the database becomes slow. It will be hard to know that the problem is the caching pattern has changed because the compression properties of the underlaying data have changed. Keeping good time series data on the cache utilization, and periodically checking the compression of the data by hand may help the DBA understand these patterns better.

For instance, note the different compression ratios of various datasets:

Take Aways

  • MongoDB 3.0 has a new storage engine API, and is delivered with the optional WiredTiger engine.
  • MongoDB 3.0 with WiredTiger is much faster than MMAPv1 mostly because of increased concurrency.
  • MongoDB 3.0 with WiredTiger is much faster than MMAPv1 even when compressing the data.

Lastly, remember, MongoDB 3.0 is a new piece of software. Test before moving production workloads to it. TEST TEST TEST.

If you would like to test MongoDB 3.0 with WiredTiger, ObjectRocket has it as generally available and it's simple and quick to setup. As with anything ObjectRocket, there are a team of DBAs and Developers to help you with your projects. Don't be shy hitting them up at support@objectrocket.com with questions or email me directly.

Note: test configuration and details documented here.

转载于:https://www.cnblogs.com/bonelee/p/6289909.html

MongoDB 3.0 WiredTiger Compression and Performance相关推荐

  1. 新年新技术:MongoDB 3.0

    前一篇介绍了HTTP/2,这一篇简单介绍下3月3号发布的MongoDB 3.0. What's new in MongoDB 3.0? 新的存储引擎WiredTiger MongoDB 3.0的存储引 ...

  2. MongoDB 3.0新增特性一览

    引言 在历经版本号修改(2.8版本直接跳到3.0版本)和11个rc版本之后,MongoDB 3.0于2015年3月3日正式发布.可以毫不夸张的说,该版本的新增特性标志着MongoDB这款典型的NoSQ ...

  3. MongoDB 4.0 事务实现解析

    上个月底 MongoDB Wolrd 宣布发布 MongoDB 4.0, 支持复制集多文档事务,阿里云数据库团队 研发工程师第一时间对事务功能的时间进行了源码分析,解析事务实现机制. MongoDB ...

  4. 【转】MongoDB 3.0 正式版本即将发布,强力推荐

    MongoDB 今天宣布3.0 正式版本即将发布.这标志着 MongoDB 数据库进入了一个全新的发展阶段,提供强大.灵活而且易于管理的数据库管理系统. MongoDB 3.0 在性能和伸缩性方面都有 ...

  5. MongoDB 3.0 新增特性一览

    引言 在历经版本号修改(2.8版本直接跳到3.0版本)和11个rc版本之后,MongoDB3.0于2015年3月3日正式发布.可以毫不夸张的说,该版本的新增特性标志着MongoDB这款典型的NoSQL ...

  6. CentOS7 安装MongoDB 3.0服务

    1,下载&安装 MongoDB 3.0 正式版本发布!这标志着 MongoDB 数据库进入了一个全新的发展阶段,提供强大.灵活而且易于管理的数据库管理系统.MongoDB宣称,3.0新版本不只 ...

  7. MongoDB 4.0 RC 版本强势登陆

    MongoDB 因其灵活的文档模型.可扩展分布式设计广受开发者喜爱,在此基础上,MongoDB 4.0 推出了更强大的功能支持,目前4.0第一个RC版本已经发布,本文将介绍 MongoDB 4.0 核 ...

  8. MongoDB 3.0 新特性【转】

    本文来自:http://www.open-open.com/lib/view/open1427078982824.html#_label3 更多信息见官网: http://docs.mongodb.o ...

  9. 故障分析 | MongoDB 5.0 报错 Illegal instruction 解决

    作者:任仲禹 爱可生 DBA 团队成员,擅长故障分析和性能优化,文章相关技术问题,欢迎大家一起讨论. 本文来源:原创投稿 *爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源. ...

最新文章

  1. Swift-跳转到tableView指定位置
  2. 对象数组空指针异常说明——C#中使用对象数组必须分别为其开辟空间
  3. 学会python之后-学会Python后,人生简直开挂了!
  4. 音频在计算机中的存储
  5. linux网络编程之用epoll实现io复用(基于tcp)
  6. 计算机补丁的概念,补丁是什么意思?网上说的打补丁什么意思
  7. STM32F103--DHT11的配置
  8. phphstudy运行不了网站_【SEO优化】企业网站进行SEO优化优那些小技巧
  9. Caffe模型详细介绍
  10. 解决wget下载过慢的问题
  11. 制作动画的软件flash
  12. 共用计算机如何加密,局域网共享文件,教您局域网共享文件怎么加密
  13. JS 阻止键盘输入event.preventDefault 和window.event.returnValue
  14. 不等缓和曲线计算公式及坐标?
  15. 微信收银扫码枪的实现原理你了解吗?
  16. 2019个人目标——计划未来
  17. Word2003画箭头锦囊 斜线箭头、双箭头、折线箭头
  18. 实现表格内容第一行居中,其他行与第一行左对齐
  19. 无迹卡尔曼滤波UKF_代码及调参(2)
  20. 差动变压器测位移实验 原理及结论

热门文章

  1. html5如何让保存的信息立即显示出来,如何用HTML5存储用户输入的信息
  2. oracle在哪些系统运行,ORACLE 查看系统运行情况
  3. 经典mysql数据库表案例_MySQL数据库的“十宗罪”(附10大经典错误案例)
  4. python爬虫源码下载 视频_Python爬虫下载视频文件部分源码
  5. oracle数据库的详细安装,Oracle 11g数据库详细安装图文教程
  6. 加白名单_【食品加奖学金】宁波大学张鑫团队:青钱柳黄酮对昼夜节律紊乱小鼠的肠道菌群和肝脏时钟基因的调节作用...
  7. 【机器学习】朴素贝叶斯、SVM和数据分布检验分析
  8. python【数据结构与算法】棋盘覆盖问题
  9. python【蓝桥杯vip练习题库】ALGO-75筛选号码(约瑟夫环)
  10. Oracle版本对应得使用的jar包