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
syamauchi
September 16, 2020
Technology
1.4k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
380
consideration-of-log-compression-by-timesacledb
syamauchi
0
1.5k
Other Decks in Technology
See All in Technology
猫付きpingコマンドを自作
uyuki234
0
270
トヨタ⽣産⽅式(TPS)⼊⾨
recruitengineers
PRO
3
1.1k
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
9.3k
SO-101×VLAによる3色キューブのピック&プレース
abeja
0
220
MulticaとPi Coding Agentで、小規模OSSを30本同時運用した流れ
eiei114
0
130
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
590
Model Studio CLI × Token Plan
maigo999
0
200
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
2
460
【GCC2026】大規模言語モデルを活用した内製検索サービスの社内展開や業務活用
bandainamcostudios
PRO
0
340
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
650
DDDのエッセンスを取り入れたAIでの開発
ak2ie
0
160
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
530
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
220
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
410
Thoughts on Productivity
jonyablonski
76
5.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Why Our Code Smells
bkeepers
PRO
340
58k
Writing Fast Ruby
sferik
630
63k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Design in an AI World
tapps
1
280
My Coaching Mixtape
mlcsv
0
250
GraphQLとの向き合い方2022年版
quramy
50
15k
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容量肥大化のような問題には構成の見直しが必要