• Save
ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例
Upcoming SlideShare
Loading in...5
×
 

ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例

on

  • 5,536 views

2011/07/30(土)、第五回MongoDB勉強会の発表資料。要旨は、次の通りです。オンラインゲームポータルサイト – アットゲームズ – ...

2011/07/30(土)、第五回MongoDB勉強会の発表資料。要旨は、次の通りです。オンラインゲームポータルサイト – アットゲームズ – で、大規模リニューアルを7月上旬に行いました。その際LAMP環境で構築されているサイト内のSNS機能にMongoDBを導入した機能拡張を行いました。その時の開発の事例についてご紹介いたします。

Statistics

Views

Total Views
5,536
Views on SlideShare
4,697
Embed Views
839

Actions

Likes
16
Downloads
0
Comments
0

10 Embeds 839

http://www.gamebusiness.jp 704
http://sanma.seo-devel.net 53
http://slide.localhost 49
http://gamebusiness.jp 12
http://paper.li 8
https://twitter.com 5
http://www.linkedin.com 4
http://www.slideshare.net 2
http://webcache.googleusercontent.com 1
http://orhowilearnedtolovetheperl.com 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例 ココロもつながるオンラインゲーム–アットゲームズ–のMongoDB導入事例 Presentation Transcript

  • – – MongoDB  5 MongoDB (@nsega) GCREST, Inc.
  • •  (Age:28) (twitter: @nsega) •  •  •  •   ( SNS ) •  •  JavaEE
  • Agenda •  •  MongoDB •  •  •  •  • 
  • ?
  • ? -@games- http://www.atgames.jp/  290
  • MongoDB
  • MongoDB SNS  ( )  
  • •   •  MySQL • 
  • •  •  
  • MongoDB •   •  NoSQL
  • MongoDB l  NoSQL MongoDB l  MongoDB JP
  • MongoDB
  • ( 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!!
  • 15 (Web/PC ) 3 (Web/Mobile ) mongos 5 (MySQL) 1 :Master / 3 :Slave/ 1 :
  • 3 (MongoDB) NEW!! •  CPU:Intel(R) Xeon(R) 2.13GHz 8core •  Memory:16GB •  HDD: 550GB (xfs 400GB/mongo )
  • Web Server x 18 (PC/MB) mongos Server1 Server2 Server3 CONFIG CONFIG CONFIG Sharding PRIMARY PRIMARY PRIMARY ReplicaSet ReplicaSet ReplicaSet SECONDARY SECONDARY SECONDARY
  • MongoDB DataAccess
  •   MongoDB ( ) ( ) ( )
  •  l Shard Key  ( ID( )) mod 100 md Shard Key  l 100 (0~99) 3 Shard  
  •  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}});
  •  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"});
  • MongoDB DataAccess •  Symfony(PHP) + MongoDB • 
  • MongoDB DataAccess Class MogoKeyValue MongoDB Class Class DiaryEvalMongoKeyVale FootprintsMongoKeyVale DAO
  • •  explain  • 
  • > db.footprints.findOne();{"_id" : ObjectId("4e0967ac6978a9cf03000027"),"md" : 73, "fromId" : 5439901, md/ ID mod 100 "toId” : 5484473, fromId/ ID "date" : 1106281433, toId/ ID date/ (YYMMDDHH24MISS)”dataType" : 0 dateType/}> db.footprints.count(); ( ) 30282 30,000
  • 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" : { } }
  • 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 } ]
  • 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" : {:
  •  AP DB
  •  orz •  MongoDB •  PHP 
  •  > 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)
  • NG OK /
  • ( Д ) !!
  • DB (perl)
  • DB perl 2011/6/24
  • DB >db.footprints.find({”dataType":0,"date":{$lt:110624000000}}) .count();359832 36
  • 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 !
  • DB >db.footprints.find({”dataType":0,"date":{$lt:110624000000}}) .count();359832 orz
  • DB ( ´ ) (´ )( )( )>db.footprints.find({”dataType":0,"date":{$lt:110624000000}}) .count(); 0 DB  ( )
  • 
  • / ( )  
  • 
  • mongod
  • mongod mongod(primary)
  • mongod : [conn38666] JS Error: out of memory
  • mongod l  mongod AP accept  l  AP MongoDB l 
  • server1 mongod(PRIMARY)ReplicaSet SECONDARY PRIMARY ( д )
  • SECONDARY [rs Manager] replSet cant see a majority, will not try to elect self elect
  • mongo1 mongo1 server2 SECONDARY
  • mongo1 mongo1 server1 priority  server2 (default 01)
  • ReplicaSet SECONDARYpriority 1 PRIMARY  SECONDARY (*´ ) ( д lll) ( )
  •   ( )
  •  slowms >/usr/local/mongodb/bin/mongod --slowms 500 --logpath /var/log/mongodb/data.log 500ms
  •  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 ( `д ´)
  •  printShardingSizes() 2 1 moveChunk() 
  •  printShardingSizes() 7/26 (7/5) 3 2GB
  • l   l MongoDB   l  Map/Reduce
  • MongoDBgroup Map/Reduce http://www.mongodb.org/pages/viewpage.action?pageId=6750296
  • • RDBMS  •   •   
  • ( )
  •