19. Session
Management
Authentication
& Authorization
Billing
API Gateway
API
API
Polaris: Cellular Core Interfaces
implemented as distributed system
Cellular Core Network
reinvented on AWS
Availability Zone
Availability Zone
IoT
Devices
3G/
LTE
MNO AWS
Direct
Connect
Dipper: Set of micro services that enable
Polaris and API
Amazon
DynamoDB
今日の本題
43. • IMSIは単独でPrimary Key
• Partition Keyのみのスキーマを選択
• GroupIdのGSIを作成
SubscriberテーブルにIndexを張る
IMSI (Part) OperatorID Status Group ID
1234567890000001 OP0012345678 active 1234-5678-…
1234567890000002 OP0012345678 ready abcd-cafe-…
1234567890000003 instock cdef-beef-…
Group ID (Part) IMSI (Sort) Status …
1234-5678-… 1234567890000001 active …
abcd-cafe-… 1234567890000002 ready …
Subscribers Base Table
Group ID Index
OperatorID (Part) Group ID (Sort)
OP0012345678 1234-5678-…
OP0012345678 abcd-cafe-…
OP0012345679 cdef-beef-…
Group Table
49. • Conditional Updateを使った楽観的ロック
楽観的ロックもうまく使うと強力です
Increment version iff version == 1
Version = 1 -> 2
Increment version iff version == 1
@DynamoDBTable(tableName=“subscriber
”)
public class Subscriber {
@DynamoDBHashKey
public String getImsi(){ … }
@DynamoDBAttribute
public String getOperatorId(){ ... }
@DynamoDBVersion
public Long getVersion() {…}
}DynamoDBMapperなら モデルクラスに
@DynamoDBVersion アノテーションをつけるだけ!
51. 楽観的ロックを活用したJobスケジューラ
Job ID (Part) Time to Fire Status
1234-5678 2018-11-01-17:20 notStarted
9abc-def0 2018-10-31-09:30 Executing
5678-9abc 2018-10-29-19:15 Finished
1. Fetch a job to execute
2. Update status iff status == notStarted
3. Execute Job because step 2 succeeds
Status = notStarted -> Executing
1. Fetch a job to execute
2. Update status iff status == notStarted
3. Skip the job because step failed
•Jobテーブルを複数WorkerでPollingして未実行のイ
ベントを見つけたらStatusを更新して実行
52. 楽観的ロックを活用したJobスケジューラ
Job ID (Part) Time to Fire Status PartitionId
1234-5678 2018-11-01-17:20 notStarted 1
9abc-def0 2018-10-31-09:30 Executing
5678-9abc 2018-10-29-19:15 Finished
def0-9abc 2018-11-02-19:39 notStarted 10
• 未実行の処理を並列に効率よく見つけるためにSparse Index
• 各Jobに一定範囲 (e.g. 1〜10) の乱数をPartitionIdとして設定してGSI
• 各Workerは乱数の範囲をそれぞれクエリしてJob取得
• 終わったらPartitionIdを消す( Sparse Indexから消える)
Partiction ID (Part) Time to Fire (Sort) Status Job ID
1 2018-11-01-17:20 notStarted 1234-5678
10 2018-11-02-19:39 notStarted def0-9abc
Job登録
1からい
きまーす
自分は5
から