Weitere ähnliche Inhalte
Ähnlich wie ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例 (20)
Kürzlich hochgeladen (20)
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
- 1. – –
MongoDB
5 MongoDB
(@nsega)
GCREST, Inc.
- 2. • (Age:28) (twitter: @nsega)
•
•
•
•
( SNS )
•
• JavaEE
- 5. ?
-@games-
http://www.atgames.jp/
290
- 12. MongoDB
l NoSQL MongoDB
l MongoDB JP
- 17. ( SNS )
• Linux/CentOS v5.4
• Apache v2.2.14
• MySQL v5.5(InnoDB)
• PostgreSQL v9.0.1
• MongoDB v1.8.2-rc3 NEW!!
• PHP v5.2 / symfony v1.2.9
(MongoDriver/mongo.so) NEW!!
- 18. 15 (Web/PC )
3 (Web/Mobile )
mongos
5 (MySQL)
1 :Master / 3 :Slave/ 1 :
- 19. 3 (MongoDB) NEW!!
• CPU:Intel(R) Xeon(R) 2.13GHz 8core
• Memory:16GB
• HDD: 550GB
(xfs 400GB/mongo )
- 20. Web Server
x 18 (PC/MB)
mongos
Server1 Server2 Server3
CONFIG
CONFIG
CONFIG
Sharding
PRIMARY
PRIMARY
PRIMARY
ReplicaSet ReplicaSet ReplicaSet
SECONDARY
SECONDARY
SECONDARY
- 24. l Shard Key
( ID( )) mod 100
md Shard Key
l 100 (0~99) 3 Shard
- 25. l Chunk (split )
/usr/local/mongodb/bin/mongo localhost/admin;
db.runCommand({split:sns.footprints,middle:{md:0}});
db.runCommand({split:sns.footprints,middle:{md:1}});
:
db.runCommand({split:sns.footprints,middle:{md:98}});
db.runCommand({split:sns.footprints,middle:{md:99}});
- 26. l Chunk (moveChunk )
db.runCommand({moveChunk:sns.footprints,
find:{md:0},to:”mongo01});
db.runCommand({moveChunk:sns.footprints,
find:{md:1},to:”mongo02});
:
db.runCommand({moveChunk:sns.footprints,
find:{md:98},to:”mongo03});
db.runCommand({moveChunk:sns.footprints,
find:{md:99},to:”mongo01});
- 28. MongoDB DataAccess
Class MogoKeyValue MongoDB
Class Class
DiaryEvalMongoKeyVale FootprintsMongoKeyVale
DAO
- 31. explain
db.footprints.find({fromId:5439901,”dateType:{$gt:0}})
Ø .sort({date:-1}).explain();
{
cursor : BasicCursor,
INDEX
nscanned : 30178,
nscannedObjects : 30178,
n : 54,
scanAndOrder : true,
millis : 31,
nYields : 0,
nChunkSkips : 0,
isMultiKey : false,
indexOnly : false,
indexBounds : {
}
}
- 32. INDEX
db.footprints.ensureIndex({fromId:1,dataType:1,date:-1});
db.footprints.getIndexes();
[
:
wkwk
{
_id : ObjectId(4e2c5aff4ab228594428620c),
ns : sns.footprints,
key : {
fromId : 1,
”dataType : 1,
INDEX
date : -1
},
name : fromId_1_dataType_1_date_-1,
v : 0
}
]
- 33. explain
db.footprints.find({fr:5439901,ty:{$gt:0}}).sort({dt:-1}).explain();
{
cursor : BtreeCursor fromId_1_dataType_1_date_-1,
nscanned : 54,
nscannedObjects : 54, INDEX
n : 54,
scanAndOrder : true,
millis : 1,
nYields : 0,
nChunkSkips : 0,
isMultiKey : false,
indexOnly : false, ( )
indexBounds : {
:
- 37. db.diaryeval.findOne();
{
_id : ObjectId(4e2afdc86978a9bb76000000),
md : 32,
diaryId : 2224,
fromId : 5472732,
toId : 5439901,
md/ fromId mod 100
”dataType : 1,
diaryId/ DiaryID
date : 2011/07/24 01:58:48
}
fromId/ ID
toId/ ID
dateType/
date/
(YYYY/MM/DD HH24:MI:SS)
- 42. DB
db.footprints.find({”dataType:0,date:{$lt:110624000000}})
.count();
359832 36
- 43. DB
perl remove.ashiato.over.one.month.pl
[2011-06-24 14:28:45] TARGET 110624
[2011-06-24 14:28:45] END $VAR1 = 1;
36
!
- 44. DB
db.footprints.find({”dataType:0,date:{$lt:110624000000}})
.count();
359832
orz
- 45. DB
( ´ ) (´ )( )( )
db.footprints.find({”dataType:0,date:{$lt:110624000000}})
.count();
0
DB
( )
- 49. mongod
:
[conn38666] JS Error: out of memory
- 50. mongod
l mongod AP
accept
l AP MongoDB
l
- 52. SECONDARY
[rs Manager] replSet can't see a majority, will not try to elect self
elect
- 53. mongo1
mongo1
server2
SECONDARY
- 54. mongo1
mongo1
server1 priority
server2 (default 01)
- 57. slowms
/usr/local/mongodb/bin/mongod --slowms 500
--logpath /var/log/mongodb/data.log
500ms
- 58. Fri Jul 22 15:48:24 [conn171] query sns.$cmd ntoreturn:
1 command: { count: footprints,
query: { toId: , $where: this.dataType 0 } } reslen:64 607ms
Fri Jul 22 17:53:00 [conn33887] query sns.$cmd ntoreturn:
1 command: { count: footprints,
query: { toId: , $where: this.dataType 0 } } reslen:64 527ms
( `д ´)
- 62. l
l MongoDB
l Map/Reduce
- 63. MongoDB
group Map/Reduce
http://www.mongodb.org/pages/viewpage.action?pageId=6750296