MongoDB huge perf loss on server

36 views
Skip to first unread message

Nicolas KERMARC

unread,
Jul 1, 2011, 8:31:37 PM7/1/11
to mongodb-user
Hello, i'm facing the following (and strange) problem : i have a php
website running on my local server (mac osx 64bits), i'm doing kinda
fatty request on a 400k items tables which takes around 1.5s on my
Mac, but I received my dedicated server (something like 24gb ram,
twelve dual-core or something) the exact same code with the exact same
db (and running localhost on the dedicated) is taking 5sec (given what
is mongod showing me on the console)...

The only difference is the version of the mongod..... Any ideas?

james33

unread,
Jul 1, 2011, 10:48:56 PM7/1/11
to mongodb-user
Did you check to make sure the index got created when you transferred
the database?

Nicolas KERMARC

unread,
Jul 2, 2011, 8:48:02 AM7/2/11
to mongodb-user
The indexes are exactly the same, as well as the database content and
the php code. Feeling really lost here. I really can't see how a
computer 10 times faster as mine can't take 5x more time for process
the same request.

Nat

unread,
Jul 2, 2011, 9:02:50 AM7/2/11
to mongod...@googlegroups.com
can you show mongostat, db.stats(), iostat -x2 when you put test load on mongodb?
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Nicolas KERMARC

unread,
Jul 2, 2011, 9:25:50 AM7/2/11
to mongodb-user
Yeh, I'll do it in a sec. I just thought about one thing : on my
dedicated server, there was Plesk installed by default, which was
adding me crappy settings to my php like open_basedir whatever. It
seems that actually, the request on my dedicated is taking too long
because the parsing of the cursor (i'm doing a foreach in php) is
longer : so I'm wondering, is there some kind of php restrictions that
can make the php driver lag or something? I thought about cursor
batchSize or whatever. Thanks by advance, I'll check the stats

Nicolas KERMARC

unread,
Jul 3, 2011, 11:32:30 AM7/3/11
to mongodb-user
Some benchmark :
local server (macbook pro) : test get map : 1.21967506409 test1 :
0.0742831230164 test2 : 0.0758030414581
dev server : test get map : 1.0872988700867 test1 : 0.07145881652832
test2 :0.070747852325439
dedicated server(8cores 24gb ram) : test get map : 3.2268710136414
test1 : 0.16562485694885 test2 :0.16163206100464

get map is a double foreach grabbing stuff from db and doing calcs.
test1 and test2 are simple foreach grabbing stuff from db.

really strange...

Nicolas KERMARC

unread,
Jul 3, 2011, 11:56:30 AM7/3/11
to mongodb-user
Just tried the benchmark given on github php driver

I'm doing 5k ops/sec in local, 9k ops/sec on my dedicated.. So the
problem is not coming from the link between php and mongo.. I'm really
lost :/

Shimon Doodkin

unread,
Jul 3, 2011, 2:31:25 PM7/3/11
to mongodb-user
maybe php is configured to use php-cgi which is super slow but multi
user secure
a faster version is php as apache module / server module
apache might be not configured for performance

the fastest solution is nginx or lighty + php-fast-cgi

maybe you have to use db.slaveOk() until you do it it reads like from
a single thread

Nicolas KERMARC

unread,
Jul 3, 2011, 5:57:42 PM7/3/11
to mongodb-user
Just build nginx with php fpm and apc... I won 0.5sec, but it still
fuckin' slow... Wtf is going on seriously :/

Dan Pasette

unread,
Jul 5, 2011, 12:45:49 AM7/5/11
to mongodb-user
You said that the only difference is the version of mongod, what are
the versions on each machine?

Nicolas KERMARC

unread,
Jul 6, 2011, 10:15:11 AM7/6/11
to mongodb-user
Managed to fix the problem, which was pretty amazing. Actually I
dumped the DB from my dev server using mongodump and restoring it on
the prod server using mongorestore.
I tried to directly db.copyDatabase, and, *magic* performances were
good....

Any idea about why mongodumping/mongorestoring could affect
performances? It was looking like the db was kinda corrupted or so...

Thanks for your help

Scott Hernandez

unread,
Jul 6, 2011, 11:22:04 AM7/6/11
to mongod...@googlegroups.com
Depending on the version and usage the database files can become
sparse (and require more memory for the same working set of data). A
dump/restore will compact the data and rebuild the indexes. In 1.9.x
(soon 2.0) there is a compact command to specifically address this,
and other issues.

Nicolas KERMARC

unread,
Jul 6, 2011, 11:40:12 AM7/6/11
to mongodb-user
Thank you very much for these informations Scott.
Reply all
Reply to author
Forward
0 new messages