没想太多就用了 MongoDB 的结果 (下)

除了(中)提到的问题以外,使用久了之後,又出现其他问题,有些是在 mongoDB 里无法解决的,我们就在 application 层级解决。

变大後,首先最需要处理的就是效能问题。此外,还有 disk 大小本身也是用越多花越多钱。
所以要想办法有效应用,想办法降低 data 容量。

我们具体有做的是,定期在後端加入判断,如果出现以後绝对不会说话的对话的配对(例如封锁对方),我们会删除来节省空间。

这边奇怪的是,单纯删除也不会增加容量,一定要跑这个指令才行:
db.runCommand({compact: 'collection name'})
而且,跑这个指令,还要按照以下的步骤执行才可以。

	/*
	 * We do compaction by copying blocks from the end of the file to the
	 * beginning of the file, and we need some metrics to decide if it's
	 * worth doing.  Ignore small files, and files where we are unlikely
	 * to recover 10% of the file.
	 */

	/* Sum the available bytes in the initial 80% and 90% of the file. */

	/*
	 * Skip files where we can't recover at least 1MB.
	 *
	 * If at least 20% of the total file is available and in the first 80%
	 * of the file, we'll try compaction on the last 20% of the file; else,
	 * if at least 10% of the total file is available and in the first 90%
	 * of the file, we'll try compaction on the last 10% of the file.
	 *
	 * We could push this further, but there's diminishing returns, a mostly
	 * empty file can be processed quickly, so more aggressive compaction is
	 * less useful.
	 */

这个我们当时找了很久,才解决这个问题。

最新文章会分享在脸书:https://www.facebook.com/gigi.wuwu/
欢迎留言讨论


<<:  Day 7:CSS的display

>>:  离职倒数24天:说出内心烦恼、学到新知识、得到新的角度,三个愿望一次满足

Azure Database for MySQL 手把手基础教学

葛瑞部落格欢迎光顾 Azure Database for MySQL 前置作业 一组有效的Azure...

Day29 NodeJS实作 III

新增功能完成後,接着是待办事项列表与删除待办事项。 前两天为了说明前後端应用程序和关联把文章写得有点...

伸缩自如的Flask [day14] 档案下载 及 其他传值方法

从官网的攻略介绍来看,因为安全考量,所以平常都应该使用send_from_directory(),而...

[Day-9] R语言 - K - means ++ 实作 ( K - means ++ in R.Studio)

您的订阅是我制作影片的动力 订阅点这里~ 影片程序码 library(naniar) data(ir...

予焦啦!附录:诡异的时间中断(timer interrupt)搁置位元(pending bit)

在 3.0 那一篇,笔者介绍时间中断与简单的实作。也许也有读者注意到了不太顺畅的部分,那就是直接跳跃...