Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
reduce-db-data-with-cloudian
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
syamauchi
September 16, 2020
Technology
1.3k
1
Share
reduce-db-data-with-cloudian
syamauchi
September 16, 2020
More Decks by syamauchi
See All by syamauchi
Survey on how to protect PostgreSQL child process from OOM-killer
syamauchi
0
360
consideration-of-log-compression-by-timesacledb
syamauchi
0
1.4k
Other Decks in Technology
See All in Technology
試されDATA SAPPORO [LT]Claude Codeで「ゆっくりデータ分析」
ishikawa_satoru
0
340
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
2
260
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.3k
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
5
1.3k
機能・非機能の学びを一つに!Agent Skillsで月間レポート作成始めてみた / Unifying Bug & Infra Insights — Building Monthly Quality Reports with Agent Skills
bun913
5
3.9k
さくらのAI Engineから始める クラウドネイティブ意識
melonps
0
130
Discordでリモートポケカしてたら、なぜかDOを25分間動かせるようになった話
umireon
0
110
Proxmox超入門
devops_vtj
0
150
デシリアライゼーションを理解する / Inside Deserialization
tomzoh
0
220
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
140
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
160
🀄️ on swiftc
giginet
PRO
0
280
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
120
GitHub's CSS Performance
jonrohan
1032
470k
Skip the Path - Find Your Career Trail
mkilby
1
100
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
300
Documentation Writing (for coders)
carmenintech
77
5.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Deep Space Network (abreviated)
tonyrice
0
110
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
180
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1k
Tell your own story through comics
letsgokoyo
1
890
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
Odyssey Design
rkendrick25
PRO
2
570
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容量肥大化のような問題には構成の見直しが必要