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
100万レコード超えそう(その2)
Search
wakio
June 20, 2024
Programming
1
92
100万レコード超えそう(その2)
wakio
June 20, 2024
Tweet
Share
More Decks by wakio
See All by wakio
世界一流エンジニアの思考法を読んでみた
wakino
1
57
Other Decks in Programming
See All in Programming
Android端末で実現するオンデバイスLLM 2025
masayukisuda
1
170
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
130
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
11
4.4k
今だからこそ入門する Server-Sent Events (SSE)
nearme_tech
PRO
3
250
Swift Updates - Learn Languages 2025
koher
2
490
知っているようで知らない"rails new"の世界 / The World of "rails new" You Think You Know but Don't
luccafort
PRO
1
190
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
アセットのコンパイルについて
ojun9
0
130
Namespace and Its Future
tagomoris
6
710
Laravel Boost 超入門
fire_arlo
3
220
OSS開発者という働き方
andpad
5
1.7k
より安全で効率的な Go コードへ: Protocol Buffers Opaque API の導入
shwatanap
2
720
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Docker and Python
trallard
46
3.6k
Designing Experiences People Love
moore
142
24k
Building Adaptive Systems
keathley
43
2.7k
How GitHub (no longer) Works
holman
315
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Why Our Code Smells
bkeepers
PRO
339
57k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Code Review Best Practice
trishagee
71
19k
Transcript
100万レコード超えそう その2
自己紹介 名前:ミヤワキ 個人開発&受託開発 組込からスマホアプリまでやります 好きな言語はKotlin 山を走るのが趣味
とある家計簿アプリのお話です
基本スタンドアローンで動きますが、 家計簿の同期はサーバ経由です
現在、登録ユーザ1700人→4000人程度で 24万→87万レコードのテーブルがあります 収入・支出履歴テーブルのレコード数の推移
このまま順調にいくと 100万レコードを超えるかも!
100万レコードを超えると パフォーマンスの劣化が顕著になるらしい 実際、1回の同期に5,6秒かかる ケースもでてきた
でも安易にサーバ増強するとか 富豪的アプローチはとりたくない t3.microで頑張りたい! ※ t3.micro: vCPU2個 メモリ1GB
4個の施策 ・手動で同期してもらう ・古いデータをS3に逃がす ・Bulk Insertを使う ・パーティショニング
S3 EC2 RDS 年1の移動 ユーザ登録・ログイン 古いデータをS3に逃がす 2年分だけ保存
1万レコードの挿入(MariaDB) Bulk単位 処理時間(msec) Bulkなし 2,440 1000 410 10000 259 1万レコードの挿入(SQLite)
Bulk単位 処理時間(msec) Bulkなし 44,189 10 2,839 100 1,537 200 1,867 500 2,967 t3.micro Huawei P20lite Android9 Bulk Insertを使う
ここまでやって、現在は1回の同期が 平均90ms未満、最大3秒
100万レコード超えて パフォーマンスが劣化したらやってみます 乞うご期待! パーティショニング