Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Как сэкономить
$1 000 000
на
базах данных
Денис Аникин,
ТехДир Почты/Облака
Mail.Ru
Why use a DBMS?
Why use a DBMS?
+ QUERIES
+ ACID
+ INDEXING
+ TABLES
+ DURABILITY
DatabaseDatabase FileFile
Heavy read workload
APPAPP
DBDB
APPAPP
APPAPP APPAPP
Overloaded
Solution: replication
APPAPP DB MasterDB Master
Update
DB SlaveDB Slave
Replication
Select
DB SlaveDB Slave
DB SlaveDB Sla...
Heavy write workload
APPAPP
DBDB
APPAPP
APPAPP APPAPP
Replication does not scale
writes
Solution: sharding
DBDB DBDB DBDB
DBDB DBDB DBDB
DBDB DBDB DBDB
Replication
Sharding
Who is the next problem?
…
The boss
The boss
Technology
We are loosing money
Close down
What should we do?
Cache!
DBDB DBDB
DBDB DBDB
DBDB DBDB
CacheCache
AppApp
Good
latency
But …
Inconsistency
DBDB DBDB
DBDB DBDB
DBDB DBDB
CacheCache
AppApp
Inconsistency
Still have sharding
DBDB DBDB
DBDB DBDB
DBDB DBDB
CacheCache
AppApp
Inconsistency
Cache does not optimize updates out!
DBDB DBDB
DBDB DBDB
DBDB DBDB
CacheCache
AppApp
Inconsistency
AppApp
CacheCache DBDB
Cache rebooted
Data’s lost
Inconsistency
AppApp
CacheCacheDBDB
Cache rebooted
Data’s lost
Cache
- Inconsistency
- Still need sharding
- What else?
Cache is not a DB
FileFile
Inconsistency
WHAT
TO
DO?
Smart cache
DBDB DBDB
DBDB DBDB
DBDB DBDB
Smart
Cache
Smart
Cache
AppApp
Good
latency
AppApp
Smart
Cache
Smart
Cache DBDB
Cache rebooted
OK
Well it’s better
Well it’s better, but …
Still inconsistency
Cache rebooted
Data lost
AppApp
Smart
Cache
Smart
Cache DBDB
Still sharding
DBDB DBDB
DBDB DBDB
DBDB DBDB
Smart
Cache
Smart
Cache
AppApp
Remember, yourboss …
… doesn’t like sharding
… because it’s way too
expensive
Cache
- Inconsistency
- Still need sharding
- No databaseproperties
- What else?
Cold start
Cold start
DBDB DBDB
DBDB DBDB
DBDB DBDB
CacheCache
Cold
Start
Kills
The
Cache
Cold start
DBDB
DBDB
DBDB
CacheCache
DBDB
DBDB
DBDB
DBDB
DBDB
DBDB
Only to
warmup
cache
Only to
warmup
cache
Cache
- Inconsistency
- Still need sharding
- No databaseproperties
- Cold start
How to warm it up?
How to warm it up?
Persistent cache
DiskDiskMemoryMemory
Dump
Do you like it?
Persistent cache
DiskDiskMemoryMemory
Dump
- IOPS
- STALE DATA
+ FAST WARMUP
How to fix it?
Persistent cache
DiskDiskMemoryMemory
Log
+ IOPS
+ FRESH DATA
+ FAST WARMUP
- BIGGER SIZE
100Mb/sec
There’s still a problem
Persistent cache
DiskDiskMemoryMemory
Dump & Log
+ IOPS
+ FRESH DATA
+ FAST WARMUP
+ OPTIMAL SIZE
Solved!
Cache is warmed up
Cache
Cache
Why use a DBMS at all?
Why use a DBMS at all?
• Durability
• Replication
Why use a DBMS at all?
• Durability. Whatdoes aDB
store?
• Replication
Why use a DBMS at all?
• Durability. What doesaDB
store?Hot&Colddata
• Replication
Temperature of data
9.9Tb9.9Tb100Gb100Gb
Temperature of data
9.9Tb9.9Tb
100Gb100Gb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9...
Why do we copy a DB?
Temperature of data
9.9Tb9.9Tb
100Gb100Gb
Shard
Replicate
100Gb100Gb
100Gb100Gb
100Gb100Gb
100Gb100Gb
100Gb100Gb
100Gb100Gb
The boss’s still angry
Ideas?
Why use a DBMS at all?
• Durability. What doesaDB
store?Well, cacheis also
durablenow
• Replication
An idea!
CACHE
IS THE
PRIMARY
DATA SOURCE
An idea!
CACHE
IS THE
PRIMARY
DATA SOURCE
With replication
An idea!
CACHE
IS THE
PRIMARY
DATA SOURCE
With replication
And with all otherDBfeatures
Cache
Cache
Cache is not a DB
FileFile
Cache can be a DB!
Cache
Can
Be
A
DATABASE
+ CACHE
+ PERSISTENCE
+ ACID TRANSACTIONS
+ REPLICATION
+ STORED PROCEDURES
DatabaseDatabase
Tarantool – forhot data
+ CACHE
+ PERSISTENCE
+ ACID TRANSACTIONS
+ REPLICATION
+ STORED PROCEDURES(LUA)
DatabaseDatabase
Tarantool
We’ve done it!
9.9Tb9.9Tb
100Gb100Gb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9Tb
9.9Tb9.9...
We’ve done it!
9.9Tb9.9Tb
100Gb100Gb
SQL DBMS
Tarantool
Look back
• Shard, replica, cache, smart cache
• Shard exists, replicaback,
• Persistent cache, replication, acid.
Now cac...
Cache. Why not?
• Dependable, durable
• You’reon theroad to cache
• No ACID, no consistency, no
durability
• Leavecozy DB ...
Tarantool in Mail.Ru
Mail.Ru Users’ Profiles
ProfilesProfiles MySQLMySQL
MySQLMySQL
MySQLMySQL
MySQLMySQL
MySQLMySQL
MySQLMySQL
16x1/8 of workl...
Mail.Ru Users’ Profiles
$1.2M upfront
$300K each year
128x MySQL128x MySQL 4x Tarantool4x TarantoolVS
$20K upfront
$5K eac...
Mail.Ru Email &Cloud
$100M+
TarantoolTarantool120+ instances of
The bottom line is …
Right tool forthe job
Saved $1 000 000 on a
feature
Summary
Questions?
Денис Аникин,
техдир Почты/ОблакаMail.Ru
anikin@corp.mail.ru
Skype: danikin2
Whatsapp/Viber: +79165129650
Upcoming SlideShare
Loading in …5
×

Tarantool: как сэкономить миллион долларов на базе данных на высоконагруженном проекте / Аникин Денис (Mail.Ru)

1,946 views

Published on

Когда стоит дилемма, какое DBMS решение выбрать, то приходится принимать во внимание много факторов — latency, bandwidth, ACID-complience, наличие/отсутствие server-side-scripting, возможности репликации, удобство развертывания и администрирования, наличие известных багов или maintenance window и т.д.

Я хочу рассказать лишь об одном из факторов, который имеет особенное значение на проектах с многомиллионными аудиториями — это Total Cost of Ownership или, по-простому, цена. Чем больше аудитория у проекта, тем больше эта аудитория создает нагрузку на базы данных, тем больше должно быть серверов с базами данных, тем больше финансовых затрат это требует.

Можно экстенсивно наращивать количество серверов, но до определенного предела, когда становится понятным, что далее дешевле будет внедрить новое, более производительное решение, которое позволит радикально снизить цену и количество железа.

Мой рассказ будет посвящен тому, как мы в Почте@Mail.Ru перешли на Tarantool, и как его использование сэкономило нам миллион долларов.

Published in: Engineering

Tarantool: как сэкономить миллион долларов на базе данных на высоконагруженном проекте / Аникин Денис (Mail.Ru)

  1. 1. Как сэкономить $1 000 000 на базах данных Денис Аникин, ТехДир Почты/Облака Mail.Ru
  2. 2. Why use a DBMS?
  3. 3. Why use a DBMS? + QUERIES + ACID + INDEXING + TABLES + DURABILITY DatabaseDatabase FileFile
  4. 4. Heavy read workload APPAPP DBDB APPAPP APPAPP APPAPP
  5. 5. Overloaded
  6. 6. Solution: replication APPAPP DB MasterDB Master Update DB SlaveDB Slave Replication Select DB SlaveDB Slave DB SlaveDB Slave DB SlaveDB Slave DB SlaveDB Slave
  7. 7. Heavy write workload APPAPP DBDB APPAPP APPAPP APPAPP
  8. 8. Replication does not scale writes
  9. 9. Solution: sharding DBDB DBDB DBDB DBDB DBDB DBDB DBDB DBDB DBDB Replication Sharding
  10. 10. Who is the next problem? …
  11. 11. The boss
  12. 12. The boss
  13. 13. Technology
  14. 14. We are loosing money
  15. 15. Close down
  16. 16. What should we do?
  17. 17. Cache! DBDB DBDB DBDB DBDB DBDB DBDB CacheCache AppApp Good latency
  18. 18. But …
  19. 19. Inconsistency DBDB DBDB DBDB DBDB DBDB DBDB CacheCache AppApp
  20. 20. Inconsistency Still have sharding DBDB DBDB DBDB DBDB DBDB DBDB CacheCache AppApp
  21. 21. Inconsistency Cache does not optimize updates out! DBDB DBDB DBDB DBDB DBDB DBDB CacheCache AppApp
  22. 22. Inconsistency AppApp CacheCache DBDB Cache rebooted Data’s lost
  23. 23. Inconsistency AppApp CacheCacheDBDB Cache rebooted Data’s lost
  24. 24. Cache - Inconsistency - Still need sharding - What else?
  25. 25. Cache is not a DB FileFile
  26. 26. Inconsistency WHAT TO DO?
  27. 27. Smart cache DBDB DBDB DBDB DBDB DBDB DBDB Smart Cache Smart Cache AppApp Good latency
  28. 28. AppApp Smart Cache Smart Cache DBDB Cache rebooted OK Well it’s better
  29. 29. Well it’s better, but …
  30. 30. Still inconsistency Cache rebooted Data lost AppApp Smart Cache Smart Cache DBDB
  31. 31. Still sharding DBDB DBDB DBDB DBDB DBDB DBDB Smart Cache Smart Cache AppApp
  32. 32. Remember, yourboss …
  33. 33. … doesn’t like sharding
  34. 34. … because it’s way too expensive
  35. 35. Cache - Inconsistency - Still need sharding - No databaseproperties - What else?
  36. 36. Cold start
  37. 37. Cold start DBDB DBDB DBDB DBDB DBDB DBDB CacheCache Cold Start Kills The Cache
  38. 38. Cold start DBDB DBDB DBDB CacheCache DBDB DBDB DBDB DBDB DBDB DBDB Only to warmup cache Only to warmup cache
  39. 39. Cache - Inconsistency - Still need sharding - No databaseproperties - Cold start
  40. 40. How to warm it up?
  41. 41. How to warm it up?
  42. 42. Persistent cache DiskDiskMemoryMemory Dump
  43. 43. Do you like it?
  44. 44. Persistent cache DiskDiskMemoryMemory Dump - IOPS - STALE DATA + FAST WARMUP
  45. 45. How to fix it?
  46. 46. Persistent cache DiskDiskMemoryMemory Log + IOPS + FRESH DATA + FAST WARMUP - BIGGER SIZE 100Mb/sec
  47. 47. There’s still a problem
  48. 48. Persistent cache DiskDiskMemoryMemory Dump & Log + IOPS + FRESH DATA + FAST WARMUP + OPTIMAL SIZE
  49. 49. Solved!
  50. 50. Cache is warmed up
  51. 51. Cache
  52. 52. Cache
  53. 53. Why use a DBMS at all?
  54. 54. Why use a DBMS at all? • Durability • Replication
  55. 55. Why use a DBMS at all? • Durability. Whatdoes aDB store? • Replication
  56. 56. Why use a DBMS at all? • Durability. What doesaDB store?Hot&Colddata • Replication
  57. 57. Temperature of data 9.9Tb9.9Tb100Gb100Gb
  58. 58. Temperature of data 9.9Tb9.9Tb 100Gb100Gb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb Shard Replicate
  59. 59. Why do we copy a DB?
  60. 60. Temperature of data 9.9Tb9.9Tb 100Gb100Gb Shard Replicate 100Gb100Gb 100Gb100Gb 100Gb100Gb 100Gb100Gb 100Gb100Gb 100Gb100Gb
  61. 61. The boss’s still angry
  62. 62. Ideas?
  63. 63. Why use a DBMS at all? • Durability. What doesaDB store?Well, cacheis also durablenow • Replication
  64. 64. An idea! CACHE IS THE PRIMARY DATA SOURCE
  65. 65. An idea! CACHE IS THE PRIMARY DATA SOURCE With replication
  66. 66. An idea! CACHE IS THE PRIMARY DATA SOURCE With replication And with all otherDBfeatures
  67. 67. Cache
  68. 68. Cache
  69. 69. Cache is not a DB FileFile
  70. 70. Cache can be a DB!
  71. 71. Cache Can Be A DATABASE
  72. 72. + CACHE + PERSISTENCE + ACID TRANSACTIONS + REPLICATION + STORED PROCEDURES DatabaseDatabase
  73. 73. Tarantool – forhot data + CACHE + PERSISTENCE + ACID TRANSACTIONS + REPLICATION + STORED PROCEDURES(LUA) DatabaseDatabase
  74. 74. Tarantool
  75. 75. We’ve done it! 9.9Tb9.9Tb 100Gb100Gb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb 9.9Tb9.9Tb Shard Replicate
  76. 76. We’ve done it! 9.9Tb9.9Tb 100Gb100Gb SQL DBMS Tarantool
  77. 77. Look back • Shard, replica, cache, smart cache • Shard exists, replicaback, • Persistent cache, replication, acid. Now cacheisaDB • 2 instances could be enough
  78. 78. Cache. Why not? • Dependable, durable • You’reon theroad to cache • No ACID, no consistency, no durability • Leavecozy DB for cache • Tarantool helps come over • No magic, just anew tool
  79. 79. Tarantool in Mail.Ru
  80. 80. Mail.Ru Users’ Profiles ProfilesProfiles MySQLMySQL MySQLMySQL MySQLMySQL MySQLMySQL MySQLMySQL MySQLMySQL 16x1/8 of workload
  81. 81. Mail.Ru Users’ Profiles $1.2M upfront $300K each year 128x MySQL128x MySQL 4x Tarantool4x TarantoolVS $20K upfront $5K each year 60 times!!! Saved more than $1 000 000
  82. 82. Mail.Ru Email &Cloud $100M+ TarantoolTarantool120+ instances of
  83. 83. The bottom line is …
  84. 84. Right tool forthe job
  85. 85. Saved $1 000 000 on a feature
  86. 86. Summary
  87. 87. Questions? Денис Аникин, техдир Почты/ОблакаMail.Ru anikin@corp.mail.ru Skype: danikin2 Whatsapp/Viber: +79165129650

×