Skip to content

Instantly share code, notes, and snippets.

@isublimity
Created March 5, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isublimity/4974919e38c66367804d to your computer and use it in GitHub Desktop.
Save isublimity/4974919e38c66367804d to your computer and use it in GitHub Desktop.
<pre>
<?php
function gen_uuid() {
return 'u'.mt_rand( 0,10000000000 );
}
$id=gen_uuid();
$id2=gen_uuid();
echo "id:$id\n\n";
error_reporting( E_ALL );
ini_set('expose_php',1);
ini_set('display_errors',1);
mb_internal_encoding("UTF-8");
ini_set('date.timezone',"Europe/Moscow");
$port=intval($_GET['port']);
// ---------------------------------------------------------------
echo $mongo_DSN="mongodb://sfa28.server.com:".$port."/target";
echo "\n";
$mc=new MongoClient($mongo_DSN);
$m=$mc->selectDB('ttx_u_'.$port);
$col=$m->selectCollection('uuids_'.$port);
if (stripos(@$_GET['type'],'w')!==false)
{
echo 'write';
$u=array('_id'=>$id,'time'=>time());
if (@$_GET['writeConcern_false'])
{
echo '[nw]';
$col->insert($u,array('w'=>0));
}
else
{
$col->insert($u);
}
}
if (stripos(@$_GET['type'],'r')!==false)
{
echo 'r';
$u=array('_id'=>$id2);
$r=$col->findOne($u);
//print_r($r);
}
Exists servers hetzner :
sfa32 - only for run WRK
sfa30 - nginx + php5-fpm
sfa28 - mongos servers ( 22017 - engine WiredTiger v3.0.0 , 21017 - v3.0.0 , 20017 - v2.6.8 )
---------------------
pecl Mongo 1.6.3
Test version 3.0.0
PHP only connect mongodb - no wrtie no read :
40 threads and 1300 connections
668947 requests in 32.00s, 243.59MB read
Requests/sec: 20905.21
---------- Write ( check size ) -----------
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=w" -c 1300 -d 32 -t 20
530365 requests in 32.00s, 195.67MB read
Requests/sec: 16575.85
{
"Collection" : "uuids_21017",
"Count" : NumberInt(513067),
"Size" : NumberInt(24627328),
"Storage Size" : NumberInt(37797888),
"Avg Object Size" : NumberInt(48),
"Indexes" : NumberInt(1),
"Index Size" : NumberInt(21306656),
"Padding" : 1.0,
"User Flags" : NumberInt(1)
}
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=21017&type=w" -c 1300 -d 32 -t 20
513502 requests in 31.99s, 189.43MB read
Requests/sec: 16049.47
{
"Collection" : "uuids_22017",
"Count" : NumberInt(530152),
"Size" : NumberInt(21149810),
"Storage Size" : NumberInt(9162752),
"Avg Object Size" : NumberInt(39),
"Indexes" : NumberInt(1),
"Index Size" : NumberInt(7331840)
}
----------------- random read ---------------
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=21017&type=r" -c 1300 -d 32 -t 20
Requests/sec: 17191.97
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=r" -c 1300 -d 32 -t 20
Requests/sec: 17238.87
----------------- random Read + Write ---------------
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=21017&type=rw" -c 1300 -d 32 -t 20
Requests/sec: 14085.75
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=rw" -c 1300 -d 32 -t 20
Requests/sec: 14270.32
Stat :
{
"Collection" : "uuids_21017",
"Count" : NumberInt(963820),
"Size" : NumberInt(46263504),
"Storage Size" : NumberInt(86310912),
}
{
"Collection" : "uuids_22017",
"Count" : NumberInt(986469),
"Size" : NumberInt(39358109),
"Storage Size" : NumberInt(17088512),
}
------------------------------------------------------------------------
Install PECL Mongo 1.6.4 (Default writeConcern not write safe on standalone node)
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=21017&type=rw" -c 1300 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 12425
Requests/sec: 10336.28
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=rw" -c 1300 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 8042
Requests/sec: 14328.04
------------------------------------
Restart:
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=21017&type=rw" -c 1300 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 6310
Requests/sec: 13635.25
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=rw" -c 1300 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 6505
Requests/sec: 14106.18
----------------------------- 2.6.8 VS 3.0.0 ------------
Read empty DB:
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=r" -c 500 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 1000
Requests/sec: 17098.62
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=20017&type=r" -c 500 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 755
Non-2xx or 3xx responses: 6
Requests/sec: 17391.45
-----------------------------
Only WRITE:
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=20017&type=w" -c 500 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 4144
Requests/sec: 2722.78
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=w" -c 500 -d 32 -t 20
Socket errors: connect 0, read 0, write 0, timeout 724
Requests/sec: 14901.23
WTF ???????????
Try repeat :
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=20017&type=w" -c 500 -d 32 -t 20
Requests/sec: 2486.48
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=w" -c 500 -d 32 -t 20
Requests/sec: 13131.72
WTF ????????
Check DB size:
2.6
"count" : NumberInt(166981),
"size" : NumberInt(8015168),
"avgObjSize" : NumberInt(48),
"storageSize" : NumberInt(11182080)
3.0
"count" : NumberInt(897242),
"size" : NumberInt(35797624),
"avgObjSize" : NumberInt(39),
"storageSize" : NumberInt(15552512)
Per item
(15552512/897242) = 17.33
(11182080/166981) = 66.97
WTF ? 75% compress ?
-------------------------------------------------------------------------------------------------
try set writeConcern = 0 ( new pecl module )
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=w&writeConcern_false=1" -c 500 -d 32 -t 20
478666 requests in 32.00s, 178.41MB read
Socket errors: connect 0, read 0, write 0, timeout 1699
Non-2xx or 3xx responses: 29
Requests/sec: 14957.87
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=20017&type=w&writeConcern_false=1" -c 500 -d 32 -t 20
388425 requests in 32.00s, 144.78MB read
Socket errors: connect 0, read 0, write 0, timeout 831
Requests/sec: 12138.42
fuhhh ;)
-------------------------------------------------------------------------------------------------
Read & Write
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=20017&type=rw&writeConcern_false=1" -c 500 -d 32 -t 20
20 threads and 500 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 65.86ms 631.33ms 27.22s 98.59%
Req/Sec 455.22 219.77 1.32k 67.19%
287406 requests in 32.00s, 107.39MB read
Socket errors: connect 0, read 0, write 0, timeout 2827
Non-2xx or 3xx responses: 108
Requests/sec: 8981.00
Transfer/sec: 3.36MB
root@sfa32 ~/wrk # ./wrk "http://sfa30.server.com/m.php?port=22017&type=rw&writeConcern_false=1" -c 500 -d 32 -t 20
20 threads and 500 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.00s 4.31s 27.19s 94.42%
Req/Sec 722.09 369.12 2.29k 68.09%
447016 requests in 32.00s, 167.04MB read
Socket errors: connect 0, read 0, write 0, timeout 1859
Non-2xx or 3xx responses: 52
Requests/sec: 13968.75
Transfer/sec: 5.22MB
WTF ???? + 50% Boost ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment