たれぱんのびぼーろく

わたしの備忘録、生物学とプログラミングが多いかも

DBのList/Scan操作

コスト(負荷、金銭)がきつい.
一部へのListが大事.
DynamoDBのindex使ったListが重要.

費用

計算方法

attributeName: ${attributeName.length} bytes
Strings: UTF-8-encoded bytes
Numbers: ~ (1 byte per two significant digits) + (1 byte) (leading/trailing zero are trimmed)
binary: byte (regardless of size, sent format should be base64)
Null, Boolean: 1 byte
List, Map: contents + 3 bytes

試算

以下のRecordを保存し、Scanによるデータ取得を定期的に行うとする。

interface Record {
    id: string; // UUID??
    t: number; // UnixTime
    w: number; // Float
}

料金計算をすると

  • attriuteNames: 4 bytes
  • contentUser: 16 bytes
  • contentTime: (10桁) 5 + 1 = 6 bytes
  • contentWeight: (3-4桁) 2+1 = 3 bytes

=> 30 bytes/record
4KBが1ユニットなので330recordsくらい入る.

10分1回要求して、1回2000record要求とする。
2467 units/day ~ 1K units/day
30K units/month
DynamoDB readが0.285USD/1000K unitsなので 0.00855USD/month < 1 yen/month
まったくもって問題ない.

storageは 0.285USD/(GB・month)
50,000 recordsで 50K*30bytes = 1.5MBなので
storageは 0.0004275 USD/month < 0.1 yen/month