<分区> 分区>
我刚开始使用 Mongodb v2.4.8,全局锁定百分比平均为 80%,这对我来说似乎相当高。在运行 Ubuntu 12.04 64 位的 2 核、2GB RAM、SSD VPS 上,CPU 使用率约为 120%。 iotop 显示偶尔的磁盘写入速度约为 10KB/s。 htop 显示 2GB 中仅使用了 358 MB 内存。
2 Python 进程不断地在 mongo 上执行查找/插入/更新操作。查找操作中使用的字段被索引。
为什么全局锁%这么高?我们如何解决这个问题?
彩信
db.serverStatus()
"myCollection" : {
"timeLockedMicros" : {
"r" : NumberLong(161149047),
"w" : NumberLong(38511071963)
},
"timeAcquiringMicros" : {
"r" : NumberLong(11738433),
"w" : NumberLong(6056873726)
}
},
mongostat
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
*0 *0 73 *0 0 75|0 0 1.61g 3.42g 283m 0 testCollection:95.7% 0 0|0 0|0 13k 10k 13 15:56:06
*0 *0 52 *0 0 54|0 0 1.61g 3.42g 283m 0 testCollection:83.6% 0 0|0 0|1 9k 8k 13 15:56:07
*0 *0 67 *0 0 68|0 0 1.61g 3.42g 283m 0 testCollection:89.4% 0 0|0 0|0 12k 9k 13 15:56:08
1 1 17 1 1 173|0 0 1.61g 3.42g 283m 0 testCollection:34.3% 0 0|0 0|1 18k 40k 13 15:56:09
*0 *0 45 *0 0 46|0 0 1.61g 3.42g 283m 0 testCollection:69.2% 0 0|0 0|1 8k 7k 13 15:56:10
*0 *0 46 *0 0 48|0 0 1.61g 3.42g 283m 0 testCollection:101.2% 0 0|0 0|1 8k 7k 13 15:56:11
*0 *0 48 *0 0 50|0 0 1.61g 3.42g 283m 0 testCollection:100.5% 0 0|0 0|0 8k 8k 13 15:56:12
*0 *0 62 *0 0 63|0 0 1.61g 3.42g 283m 0 testCollection:91.5% 0 0|0 0|0 11k 9k 13 15:56:13
*0 *0 52 *0 0 53|0 0 1.61g 3.42g 283m 0 testCollection:94.4% 0 0|0 0|1 9k 8k 13 15:56:14
*0 *0 34 *0 0 36|0 0 1.61g 3.42g 283m 0 testCollection:94.8% 0 0|0 0|1 6k 6k 13 15:56:15
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
4 1 8 2 1 167|0 0 1.61g 3.42g 283m 0 testCollection:15.3% 0 0|0 0|1 17k 39k 13 15:56:16
*0 *0 41 *0 0 43|0 0 1.61g 3.42g 283m 0 testCollection:97.4% 0 0|0 0|1 7k 7k 13 15:56:17
*0 *0 45 *0 0 46|0 0 1.61g 3.42g 283m 0 testCollection:95.3% 0 0|0 0|1 8k 7k 13 15:56:18
*0 *0 50 *0 0 52|0 0 1.61g 3.42g 283m 0 testCollection:90.0% 0 0|0 0|1 9k 8k 13 15:56:19
*0 *0 57 *0 0 58|0 0 1.61g 3.42g 283m 0 testCollection:93.2% 0 0|0 0|1 10k 8k 13 15:56:20
*0 *0 46 *0 0 48|0 0 1.61g 3.42g 283m 0 testCollection:105.6% 0 0|0 0|1 8k 7k 13 15:56:21
*0 *0 58 *0 0 60|0 0 1.61g 3.42g 283m 0 testCollection:95.9% 0 0|0 0|0 10k 9k 12 15:56:22
1 1 12 1 1 167|0 0 1.61g 3.42g 283m 0 testCollection:14.5% 0 0|0 0|1 16k 39k 13 15:56:23
*0 1 49 *0 0 52|0 0 1.61g 3.42g 283m 0 testCollection:98.8% 0 0|0 0|1 9k 11k 13 15:56:24
*0 *0 49 *0 0 51|0 0 1.61g 3.42g 283m 0 testCollection:101.9% 0 0|0 0|0 9k 8k 13 15:56:25
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
*0 *0 49 *0 0 50|0 0 1.61g 3.42g 283m 0 testCollection:95.0% 0 0|0 0|1 8k 8k 13 15:56:26
*0 *0 60 *0 0 62|0 0 1.61g 3.42g 283m 0 testCollection:94.2% 0 0|0 0|1 10k 9k 13 15:56:27
*0 *0 46 *0 0 47|0 0 1.61g 3.42g 283m 0 testCollection:94.2% 0 0|0 0|1 8k 7k 13 15:56:28
*0 *0 35 *0 0 38|0 0 1.61g 3.42g 283m 0 testCollection:90.6% 0 0|0 0|0 6k 6k 12 15:56:29
1 1 1 *0 1 155|0 0 1.61g 3.42g 283m 0 testCollection:0.9% 0 0|0 0|0 15k 38k 13 15:56:30
1 *0 42 1 0 45|0 0 1.61g 3.42g 283m 0 testCollection:93.3% 0 0|0 0|1 7k 7k 13 15:56:31
*0 *0 57 *0 0 68|0 0 1.61g 3.42g 283m 0 testCollection:89.6% 0 0|0 0|1 10k 14k 13 15:56:32
*0 *0 46 *0 0 48|0 0 1.61g 3.42g 283m 0 testCollection:91.9% 0 0|0 0|1 8k 7k 13 15:56:33
*0 *0 53 *0 0 54|0 0 1.61g 3.42g 283m 0 testCollection:92.2% 0 0|0 0|1 9k 8k 13 15:56:34
*0 *0 61 *0 0 63|0 0 1.61g 3.42g 283m 0 testCollection:89.3% 0 0|0 0|1 11k 9k 13 15:56:35
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
*0 *0 40 *0 0 61|0 0 1.61g 3.42g 283m 0 testCollection:53.7% 0 0|0 0|0 9k 8k 13
mongotop
ns total read write 2014-01-01T15:59:33
testCollection.oooc 868ms 0ms 868ms
testCollection. 5ms 5ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.oook 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
ns total read write 2014-01-01T15:59:34
testCollection.oooc 891ms 0ms 891ms
testCollection. 0ms 0ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.oook 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
ns total read write 2014-01-01T15:59:35
testCollection.oooc 838ms 0ms 838ms
testCollection. 0ms 0ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.oook 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
ns total read write 2014-01-01T15:59:36
testCollection.oooc 889ms 0ms 889ms
testCollection. 0ms 0ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.oook 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
ns total read write 2014-01-01T15:59:37
testCollection.oooc 831ms 0ms 831ms
testCollection. 0ms 0ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.oook 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
ns total read write 2014-01-01T15:59:38
testCollection.oooc 249ms 0ms 249ms
testCollection.oook 62ms 62ms 0ms
testCollection. 0ms 0ms 0ms
testCollection.depth 0ms 0ms 0ms
testCollection.system.indexes 0ms 0ms 0ms
testCollection.system.namespaces 0ms 0ms 0ms
testCollection.system.users 0ms 0ms 0ms
testCollection.users 0ms 0ms 0ms
Python 代码
这是导致 Adam C 指出的减速的代码。
for date, row in oooc.T.iterkv():
docExist = db.oooc.find({'timestamp': row['timestamp']})
if docExist.count() == 0:
data = json.loads(pd.concat([row, id]).to_json())
db.oooc.insert(data)
else:
data = json.loads(row.to_json())
db.oooc.update({'timestamp': data['timestamp']}, {'$set': data})
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
华为OD机试题本篇题目:明明的随机数题目输入描述输出描述:示例1输入输出说明代码编写思路最近更新的博客华为od2023|什么是华为od,od薪资待遇,od机试题清单华为OD机试真题大全,用Python解华为机试题|机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为o
我想解析一个已经存在的.mid文件,改变它的乐器,例如从“acousticgrandpiano”到“violin”,然后将它保存回去或作为另一个.mid文件。根据我在文档中看到的内容,该乐器通过program_change或patch_change指令进行了更改,但我找不到任何在已经存在的MIDI文件中执行此操作的库.他们似乎都只支持从头开始创建的MIDI文件。 最佳答案 MIDIpackage会为您完成此操作,但具体方法取决于midi文件的原始内容。一个MIDI文件由一个或多个音轨组成,每个音轨是十六个channel中任何一个上的
本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决