`
san_yun
  • 浏览: 2638929 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

mongoDB为什么用virtual memory mapping

 
阅读更多

原文: http://blog.mongodb.org/post/10407828262/cache-reheating-not-to-be-ignored

 

An important aspect to keep in mind with databases is the cost of cache reheating after a server restart. Consider the following diagram which shows several cache servers (e.g., memcached) in front of a database server.

This sort of setup is common and can work quite well when appropriate; it removes read load from the database and allows more RAM to be utilized for scaling (when the database doesn’t scale horizontally). But what happens if all the cache servers restart at the same time, say, on a power glitch in a data center?

We then have a cache reheating scenario. After the bounce the full load of all read requests will hit the database server (for a while) given the caches are empty. The server won’t be able to handle it (that’s why the cache servers were there in the first place). Now if the reheat time is short, this is not a big problem : we did go down after all. But if reheat takes a long time, it’s a big problem. Imagine 20 cache servers with 64GB RAM each. 1.2 terabytes of data must be queried from the database to be fully reheated!

Even without a cache server, the same issue exists for almost all databases. Imagine a server restart on a system with 64GB RAM. If loading 100MB/sec, reheat will take 10 minutes. However, if the queries are coming in randomly, it could take much much longer — only with sequential I/O can we get anywhere near that speed.

One could just sequentially read data in and fill the cache. However for databases much larger than RAM, loading in the right portion is difficult. “Hot” data could be at very different locations in the terabyte(s) of on disk data.

A very nice attribute of the MongoDB storage engine is its use of memory-mapped files. In this model the cache is the operating system’s file system cache. Restart the mongod process, and there is no reheat issue at all. Some databases use their own page cache which causes a reheat scenario even on just a process restart. Of course on a full server reboot MongoDB must reheat too.

A few points to keep in mind:

  • Think about reheating and how you will operationally handle it if a scenario involving it occurs. For schedules OS maintenance restart the server during off peak hours to minimize the load during reheat.
  • Restarting the mongod process is safe with respect to reheating.
  • Remounting a volume likely loses all file system cache info for the volume.
  • On a server restart, copy datafiles to /dev/null to force reheating to be sequential and thus much faster. This can be done even if the mongod process is already running. If the database is larger than RAM, copy only the newest datafiles (ones with the highest numbers); while this isn’t perfect, the latest files likely contain the largest percentage of frequently used data.
分享到:
评论

相关推荐

    mongodb数据库详细使用教程.zip_mongodb为什么快

    mongodb数据库详细教程.zip 启动方式:非auth验证方式启动mongo,以auth方式启动mongo 增删查改,批量更新 迁移mongodb数据库 可视化工具 指定数据库文件存放位置 忘记mongodb密码怎么办 mongodb用户认证,权限管理

    11.4.2 为什么在MongoDB中使用Object ID数据类型?.md

    11.4.2 为什么在MongoDB中使用Object ID数据类型?

    windows下mongodb安装与使用整理

    - 为了方便管理和使用 MongoDB,建议将其安装为 Windows 服务。 - 在命令提示符中输入以下命令: ``` >D:\mongodb\bin>mongod --dbpath "D:\mongodb\data\db" --logpath "D:\mongodb\data\log\MongoDB.log" --...

    spring-data使用mongodbTemplate对MongoDB进行读写操作

    Spring Data MongoDB是一个强大的Java库,它为开发人员提供了一种简单的方式来访问和操作MongoDB数据库。这个库是Spring Data框架的一部分,旨在简化数据访问层的实现,尤其在使用NoSQL数据库如MongoDB时。MongoDB...

    如何安装MongoDB 如何使用MongoDB

    本课程是一套关于MongoDB应用开发的实战性教程,名为《深入浅出MongoDB应用实战开发(基础、开发指南、系统管理、集群及系统架构)》,教程侧重于讲解MongoDB的常用特性及高级特性,从实际开发的角度出发对MongoDB...

    geoserver发布mongodb矢量数据地图服务.docx

    本文将介绍如何使用Geoserver将MongoDB矢量数据发布为地图服务。 一、Geoserver概述 Geoserver是基于Java开发的一款开源GIS服务器,能够处理大量的空间数据,提供了强大的空间数据存储、处理和发布功能。Geoserver...

    linux安装mongodb教程

    使用 Windows XP 的 cmd 工具,执行以下命令测试 MongoDB 是否已经成功安装: telnet 服务器 IP 27017 如果配置成功,telnet 命令将返回成功信息。 知识点 8:重启服务器 重启服务器,测试 MongoDB 是否已经自...

    MongoDB实验 - .docx

    本实验报告旨在详细介绍 MongoDB 的安装、配置和基本操作步骤,本报告基于 CentOS 7 系统,通过一步一步的截图和文字说明,帮助读者快速掌握 MongoDB 的使用。 一、安装 MongoDB 首先,我们需要配置 MongoDB 的 ...

    mongodb-测试数据

    MongoDB是一种流行的开源、分布式文档...总的来说,“mongodb-测试数据”这个压缩包为MongoDB的学习和测试提供了一个宝贵的资源库。通过深入研究和操作这些数据,你可以增强对MongoDB的理解,提升数据库管理技能。

    java中mongodb使用环境详细配置

    Java 中 MongoDB 使用环境详细配置 Java 中 MongoDB 使用环境详细配置是指在 Windows 平台(WinXP)上安装、运行、安装 Windows 服务的笔记,以作备忘。下面是一些重要的知识点: 1. MongoDB 的下载和安装 ...

    mongodb Windows7 64位

    打开命令提示符,以管理员身份运行,执行`mongod --config "C:\Program Files\MongoDB\Server\<version>\bin\mongod.cfg" --service install`来安装服务,然后用`net start MongoDB`启动服务。 3. **连接MongoDB** ...

    Centos7下安装MongoDB

    MongoDB是一个基于分布式文件存储的NoSQL数据库,由C++语言编写,运行稳定,性能高旨在为 WEB 应用提供可扩展的高性能数据存储解决方案。 MongoDB的特点包括: 1. 模式自由:可以把不同结构的文档存储在同一个...

    mongodb数据库jar包

    10. GridFS:用于存储和检索大文件,将文件分割为多个块存储在MongoDB中。 使用这个jar包,开发人员可以轻松地在Java应用中集成MongoDB,实现数据持久化、读写操作、备份恢复等功能。在实际项目中,我们还需要了解...

    Thinkphp使用mongodb数据库实现多条件查询方法

    这一修改让Thinkphp框架能够更好地适应使用MongoDB的应用场景,并为开发人员提供了更大的灵活性来处理复杂的查询需求。 总之,Thinkphp虽然支持MongoDB,但在进行复杂查询时需要根据具体需求对驱动文件进行定制和...

    mongodb的odm封装

    MongoDB的ODM(Object-Document Mapping)是用于将数据模型与MongoDB文档数据库之间的映射技术,使得开发者可以用面向对象的方式来操作数据库,而无需直接处理底层的BSON文档。在PHP中,ODM框架可以帮助我们更高效、...

    mongodb常用函数使用案例

    mongodb常用函数使用案例,主要是针对update,insert,find函数

    MongoDB入门指南.pdf

    1. 高性能:MongoDB使用了高性能的存储引擎,可以快速地存储和检索数据。 2. 高可用:MongoDB支持高可用性,可以自动地将数据复制到多个节点上,从而确保数据的安全。 3. 可扩展:MongoDB支持水平扩展,可以根据需要...

    Spring+SpringMVC+MongoDB应用

    在Spring应用中,可以使用Spring Data MongoDB模块与MongoDB进行交互,该模块提供了与MongoDB数据库进行CRUD操作的便捷API,以及对象-文档映射(Object-Document Mapping,ODM)功能。 结合描述,我们可以推断项目...

    mongodb.dll 下载.zip

    正确理解和使用`mongodb.dll`和相应的MongoDB驱动程序是开发和维护MongoDB应用程序的基础。确保你始终使用与MongoDB服务器版本兼容的驱动,以保证最佳的性能和稳定性。在进行任何系统更改前,建议先备份重要数据,...

Global site tag (gtag.js) - Google Analytics