<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Mongo on 积极向上</title>
    <link>https://www.keyboard-man.com/tags/mongo/</link>
    <description>Recent content in Mongo on 积极向上</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <lastBuildDate>Wed, 26 Oct 2022 10:02:38 +0800</lastBuildDate>
    <atom:link href="https://www.keyboard-man.com/tags/mongo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>优化Mongo降CPU</title>
      <link>https://www.keyboard-man.com/post/mongo_cpu/</link>
      <pubDate>Wed, 26 Oct 2022 10:02:38 +0800</pubDate>
      <guid>https://www.keyboard-man.com/post/mongo_cpu/</guid>
      <description>&lt;h4 id=&#34;一背景&#34;&gt;一、背景&lt;/h4&gt;&#xA;&lt;p&gt;前面&lt;a href=&#34;../wgame_group/&#34;&gt;腾讯云mongo服务采坑&lt;/a&gt;中提到每次水晶活动才开始的时候会吸引大量玩家来抽卡，会导致cpu居高。当然就算没有水晶活动每日凌晨跨天游戏玩法重置等入库外加新的一天较多玩家同时进入也会导致cpu比平时多挺多，如图所示。&#xA;&#xA;        &lt;img class=&#34;mx-auto&#34; alt=&#34;tencent-mongo-cpu-0916&#34; src=&#34;https://storage.keyboard-man.com/site-web/images/tencent-mongo-cpu-0916.png&#34; /&gt;   &#xA;    &lt;/p&gt;&#xA;&lt;h4 id=&#34;二降cpu&#34;&gt;二、降CPU&lt;/h4&gt;&#xA;&lt;h5 id=&#34;加机器&#34;&gt;加机器&lt;/h5&gt;&#xA;&lt;p&gt;避免单实例cpu太高的方法也可以通过加机器(增加mongo服务实例)来解决，但是已经在当前实例的数据库迁移到新实例的话需要关服以及处理一些配置，这不是我们想要的。&lt;/p&gt;&#xA;&lt;h5 id=&#34;加索引&#34;&gt;加索引&lt;/h5&gt;&#xA;&lt;p&gt;如果更新mongo的集合不是以&lt;code&gt;_id&lt;/code&gt;为筛选条件的话，大多时候都需要增加对应的索引，避免更新时遍历全表。事实上我们基本每个表在上线前都已经加上了索引，查看慢查询补上遗漏的几张表的索引后有少许好点，但问题依然很严重。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
