Your SlideShare is downloading. ×
MySQLでNoSQL - アメーバピグでのNoSQLの実例
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

MySQLでNoSQL - アメーバピグでのNoSQLの実例

17,074
views

Published on

NoSQL with MySQL

NoSQL with MySQL

Published in: Technology

0 Comments
14 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
17,074
On Slideshare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
66
Comments
0
Likes
14
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. MySQL NoSQL NoSQLMySQL Casual Talks #2
    • 2. • id: oinume ( : )
    • 3. • id: oinume ( : )• 2010 3
    • 4. • id: oinume ( : )• 2010 3•
    • 5. • id: oinume ( : )• 2010 3•• SQL MySQL
    • 6. • id: oinume ( : )• 2010 3•• SQL MySQL• ver 3.23 MySQL
    • 7. • MySQL NoSQL( )
    • 8. • MySQL NoSQL( )• MySQL
    • 9. • MySQL NoSQL( )• MySQL• NoSQL(KVS)
    • 10. • MySQL NoSQL( )• MySQL• NoSQL(KVS)• NoSQL(KVS)
    • 11. • Fusion-IO
    • 12. • Fusion-IO• (Java)
    • 13. • Fusion-IO• (Java)• MySQL
    • 14. • Fusion-IO• (Java)• MySQL • Oracle
    • 15. • Fusion-IO• (Java)• MySQL • Oracle•
    • 16.
    • 17. •• 2009 2
    • 18. •• 2009 2• 800 ↑ (2011 7 )
    • 19. •• 2009 2• 800 ↑ (2011 7 )•
    • 20. •• 2009 2• 800 ↑ (2011 7 )• •
    • 21. •• 2009 2• 800 ↑ (2011 7 )• • •
    • 22. •• 2009 2• 800 ↑ (2011 7 )• • • • ( ) ← NEW
    • 23. Browser Web x 35 Memcached x 4 MySQL x 6 with FIO Socket x 70
    • 24. requestBrowser Web x 35 Memcached x 4 MySQL x 6 with FIO Socket x 70
    • 25. requestBrowser swf Web x 35 Memcached x 4 MySQL x 6 with FIO Socket x 70
    • 26. requestBrowser swf Web x 35 Memcached x 4 MySQL x 6 with FIO Socket x 70
    • 27. requestBrowser swf Web x 35 TCP Socket Memcached x 4 MySQL x 6 with FIO Socket x 70
    • 28. requestBrowser swf Web x 35 TCP Socket Memcached x 4 MySQL x 6 with FIO Socket x 70 Java
    • 29. requestBrowser swf Web x 35 TCP Socket Memcached x 4 MySQL x 6 with FIO Socket x 70 Java
    • 30. requestBrowser swf Web x 35 TCP Socket Memcached x 4 MySQL x 6 with FIO Socket x 70 Java
    • 31. requestBrowser swf Web x 35 TCP Socket Memcached x 4 MySQL x 6 with FIO Socket x 70 Java
    • 32. • : 2.1Gbps
    • 33. • : 2.1Gbps• : 100,000
    • 34. • : 2.1Gbps• : 100,000• Web: 36,000 req / s
    • 35. • : 2.1Gbps• : 100,000• Web: 36,000 req / s• Socket: 160,000 req / s
    • 36. • : 2.1Gbps• : 100,000• Web: 36,000 req / s• Socket: 160,000 req / s• Database: 52000 qps (read: 40000, write: 12000)
    • 37. MySQL
    • 38. MySQL
    • 39. MySQL• RDBMS
    • 40. MySQL• RDBMS • KVS + MySQL
    • 41. MySQL• RDBMS • KVS + MySQL • KVS MySQL
    • 42. MySQL• RDBMS • KVS + MySQL • KVS MySQL• IndexPersister MySQL KVS
    • 43. IndexPersister ?
    • 44. IndexPersister• Java MySQL• key / value• SQL•
    • 45. DDLCREATE TABLE `user` ( `id` varbinary(255) NOT NULL, `data` longblob NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8
    • 46. Java@Persistable("user")public class User { @IndexKey @Store(index=0) public int getUserId() { return userId; } @Store(index=1) public String getNickname() { return nickname; } ....}
    • 47. Java Java @Persistable("user") public class User { @IndexKey @Store(index=0) public int getUserId() { return userId; } @Store(index=1) public String getNickname() { return nickname; } .... }
    • 48. Java Java @Persistable("user") public class User { @IndexKey @Store(index=0) public int getUserId() { return userId; } @Store(index=1) public String getNickname() { return nickname; } .... }
    • 49. Java Java @Persistable("user") public class User { @IndexKey @Store(index=0) public int getUserId() { DB return userId; } index=0 0 @Store(index=1) public String getNickname() { return nickname; } .... }
    • 50. select hex(id), hex(data) from user order by id limit 1 ¥Ghex(id) : 00000001hex(data):0700000006000000060103000000020000000E02000B797573616B752D3030303600000019020016E38286E38186E38195E3818F36E58FB7E381A7E381990000000301010100000003010101FFFFFFFF
    • 51. load - 1 ID: 1User user = persister.load(1, User.class);String nickname = user.getNickname();...
    • 52. fetch - 10IndexQuery query = IndexQuery.all();query.limit(10);List<User> users = persister.fetch(query, User.class);for (User user : users) ...
    • 53. fetch - (2) ID:2User user = persister.load(2, User.class);IndexQuery query = IndexQuery.startWith(new IndexValue(user.getUserId()));List<UserItem> userItems = persister.fetch(query, UserItem.class);
    • 54. fetch - (2)@Persistable("user_item")public class UserItem { userId, itemId @IndexKey public IndexKey getKey() { KeyCreator.toValue(userId, itemId); } @Store(index=0) public int getUserId() { return userId; } @Store(index=1) public int getItemId() { return itemId; } ....}
    • 55. fetch - (2) userId itemId 1 1 1 2 1 3 2 10 2 20
    • 56. fetch - (2)User user = persister.load(2, User.class);IndexQuery query = IndexQuery.startWith(new IndexValue(user.getUserId()));List<UserItem> userItems = persister.fetch(query, UserItem.class);◆ SQLselect id, data from user_item where id >= {v1} and id < {v2} v1: 00000002 v2: 00000003
    • 57. • count• exists• remove• save (insert ... on duplicate key update)
    • 58. • MySQL slow query
    • 59. • MySQL slow query•
    • 60. • MySQL slow query•• slow query
    • 61. • MySQL slow query•• slow query• Java
    • 62. • MySQL slow query•• slow query• Java•
    • 63. • load
    • 64. • load • MySQL context switch
    • 65. • load • MySQL context switch • select ... where id in (...)
    • 66. • load • MySQL context switch • select ... where id in (...)• 1 fetch ( )
    • 67. • load • MySQL context switch • select ... where id in (...)• 1 fetch ( ) • key Column
    • 68. • load • MySQL context switch • select ... where id in (...)• 1 fetch ( ) • key Column •
    • 69. • load • MySQL context switch • select ... where id in (...)• 1 fetch ( ) • key Column • • 1 fetch 1000
    • 70. MySQL Key Value Store
    • 71. KVS
    • 72. KVS• SQL
    • 73. KVS• SQL • JOIN
    • 74. KVS• SQL • JOIN • ( )INDEX
    • 75. KVS• SQL • JOIN • ( )INDEX • ( )
    • 76. KVS• SQL • JOIN • ( )INDEX • ( )• ALTER TABLE
    • 77. KVS• SQL • JOIN • ( )INDEX • ( )• ALTER TABLE •
    • 78. KVS• SQL • JOIN • ( )INDEX • ( )• ALTER TABLE • •
    • 79. KVS• SQL • JOIN • ( )INDEX • ( )• ALTER TABLE • •• mongoDB KVS
    • 80. KVS• SQL • JOIN • ( )INDEX • ( )• ALTER TABLE • •• mongoDB KVS • Ameba Pico mongoDB
    • 81. • Column
    • 82. • Column •
    • 83. • Column • • Column
    • 84. • Column • • Column•
    • 85. • Column • • Column• •
    • 86. • Column • • Column• •• Column (ALTER TABLE)
    • 87. • Column • • Column• •• Column (ALTER TABLE) • short -> int Column