Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
reduce-db-data-with-cloudian
Search
syamauchi
September 16, 2020
Technology
1
1.3k
reduce-db-data-with-cloudian
syamauchi
September 16, 2020
Tweet
Share
More Decks by syamauchi
See All by syamauchi
Survey on how to protect PostgreSQL child process from OOM-killer
syamauchi
0
310
consideration-of-log-compression-by-timesacledb
syamauchi
0
1.3k
Other Decks in Technology
See All in Technology
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
160
高度サイバー人材育成専科資料(前半)
nomizone
0
410
Database イノベーショントークを振り返る/reinvent-2025-database-innovation-talk-recap
emiki
0
250
【U/Day Tokyo 2025】Cygames流 最新スマートフォンゲームの技術設計 〜『Shadowverse: Worlds Beyond』におけるアーキテクチャ再設計の挑戦~
cygames
PRO
2
1.1k
2025-12-18_AI駆動開発推進プロジェクト運営について / AIDD-Promotion project management
yayoi_dd
0
150
ESXi のAIOps だ!2025冬
unnowataru
0
160
AI駆動開発の実践とその未来
eltociear
1
460
JEDAI認定プログラム JEDAI Order 2026 エントリーのご案内 / JEDAI Order 2026 Entry
databricksjapan
0
150
M&Aで拡大し続けるGENDAのデータ活用を促すためのDatabricks権限管理 / AEON TECH HUB #22
genda
0
190
Amazon Bedrock Knowledge Bases × メタデータ活用で実現する検証可能な RAG 設計
tomoaki25
6
2k
AgentCore BrowserとClaude Codeスキルを活用した 『初手AI』を実現する業務自動化AIエージェント基盤
ruzia
7
810
SQLだけでマイグレーションしたい!
makki_d
0
1.2k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
286
14k
It's Worth the Effort
3n
187
29k
GraphQLとの向き合い方2022年版
quramy
50
14k
Music & Morning Musume
bryan
46
7k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Building AI with AI
inesmontani
PRO
1
560
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
2
2.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Test your architecture with Archunit
thirion
1
2.1k
Statistics for Hackers
jakevdp
799
230k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
140
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
115
91k
Transcript
#RAKUSMeetup ©2020 RAKUS Co., Ltd. ©2020 RAKUS Co., Ltd. DB容量肥大化への取り組み
山内 覚
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 自己紹介 •前職 • メールとウェブからの情報漏洩対策ソフトの開発 •現職
• 2019年7月 株式会社ラクス入社 • 楽楽販売の開発チームに所属 • バージョンアップなど運用周りの業務を担当
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 楽楽販売の紹介 •クラウド型販売管理システム •導入社数1,000社超 •10年以上続くサービス
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 楽楽販売の概要 •Webデータベース • ブラウザを使ってデータの登録、更新、検索ができる •
販売情報を管理するデータベースを作れる •構成 • PHP + PostgreSQL
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 楽楽販売が抱えていた問題 •DB容量の肥大化 • 既存顧客のデータ容量の増加 •
新規顧客の増加 •PostgreSQLのI/O負荷の増加 •バックアップ取得などのメンテナンス時間の増加
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 当時のデータ状況 • DB全体 • 一番サイズが大きいDB
ファイルによりDB容量が増えている状態 合計サイズ(GB) ファイルサイズ(GB) ファイル数 サイズにおける ファイルの割合 1,106 829 4,872,548 75% サイズ(GB) ファイルサイズ(GB) ファイル数 サイズにおける ファイルの割合 127 124 244,664 98%
#RAKUSMeetup ©2020 RAKUS Co., Ltd. DB以外のファイル保存先の検討 • 選定 • ファイルが増加しても性能が劣化しづらい
• 障害に強い構成をとれる • プログラムから扱いやすい • Cloudian HyperStore • オブジェクトストレージ • ノードとファイルの多重化 • Amazon S3 と同じインタフェース(AWS SDK for PHPを使える) ※ラクスの他のサービスですでに使用していた
#RAKUSMeetup ©2020 RAKUS Co., Ltd. Cloudianを使った楽楽販売の構成 Cloudian 楽楽販売1/ 楽楽販売N/ 楽楽販売1
楽楽販売N ・ ・ ・ ・ ・ ・
#RAKUSMeetup ©2020 RAKUS Co., Ltd. ファイル保存方法の変更 file_id loid 0001 0010
・・・ ・・・ loid data 0010 ・・・ ・・・ 楽楽販売1/ 0001 ファイル一覧テーブル pg_largeobject ファイル一覧テーブル Before After Cloudian file_id loid 0001 0010 ・・・ ・・・
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題1 ファイルの追加・削除 • トランザクションで管理で きない
• ファイルの登録 1. Cloudianにファイルを登録 2. ファイル一覧にレコード追加 • ファイルの削除 1. ファイル一覧のレコード削除 2. Cloudianのファイルを削除 ※定期的なごみ掃除が必要 楽楽販売1/ 0001 ファイル一覧テーブル After Cloudian file_id loid 0001 0010 ・・・ ・・・
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題2 バックアップオプション •バックアップオプション • 過去7日分のバックアップをユーザが確認できる機能
日 月 火 水 木 金 土 通常環境 バックアップオプション
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題2 バックアップオプション (ファイルをコピーする場合) Cloudian バックアップオプションのファイルもCloudianで管理
すると・・・ ・大量のファイルコピーがCloudian内で発生する! 日 月 火 水 木 金 土 通常環境 バックアップオプション 通常環境/ バックアップ オプション(日)/ ・ ・ ・ バックアップ オプション(土)/
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題2 バックアップオプション (ファイルを共通化する場合) 通常環境/ 通常環境と同じファイルを見る
file_id 0001 0002 file_id 0001 0002 0001 0002 file_idが0002のファイルはファイル一 覧テーブルにあるが、Cloudianから 削除されているためアクセスできない Cloudian 日 月 火 水 木 金 土 通常環境 バックアップオプション
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題2 バックアップオプション (削除タイミングの変更) 削除日の2週間後に削除する file_id
delete_date 0001 0002 2020/09/16 file_id 0001 0002 file_idが0002のファイルにア クセスできる 日 月 火 水 木 金 土 通常環境 バックアップオプション 通常環境/ 0001 0002 Cloudian
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題3 既存ファイルの移行 file_id loid 0001
0010 ・・・ ・・・ loid data 0010 ・・・ ・・・ 楽楽販売1/ 0001 ファイル一覧テーブル pg_largeobject ファイル一覧テーブル Before After Cloudian file_id loid 0001 0010 ・・・ ・・・
#RAKUSMeetup ©2020 RAKUS Co., Ltd. 課題3 既存ファイルの移行 •DB全体 • サービス停止して一度に移行するのは難しい
• サービス移行中にバッチ処理で少しずつ移行 • 2019-11~2020-02の間で移行 合計サイズ(GB) ファイルサイズ(GB) ファイル数 サイズにおける ファイルの割合 1,106 829 4,872,548 75%
#RAKUSMeetup ©2020 RAKUS Co., Ltd. まとめ •DBに保存していたファイルをオブジェクトスト レージに保存した • 問題となっていたDB容量の肥大化に対応できた
• 一方、アプリの考慮点が増えた • DB容量肥大化のような問題には構成の見直しが必要