-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.3] HELP-43867: rework ledger/modb/services at month's end (#5829)
* [4.3] HELP-43867: rework ledger/modb/services at month's end
- Loading branch information
1 parent
da82c40
commit ccf681e
Showing
54 changed files
with
799 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
applications/crossbar/priv/couchdb/schemas/system_config.tasks.ledger_rollover.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"_id": "system_config.tasks.ledger_rollover", | ||
"description": "Schema for tasks.ledger_rollover system_config", | ||
"properties": { | ||
"refresh_in_parallel": { | ||
"default": 50, | ||
"description": "tasks ledger_rollover refresh_in_parallel", | ||
"type": "integer" | ||
}, | ||
"refresh_view_enabled": { | ||
"default": false, | ||
"description": "tasks ledger_rollover refresh_view_enabled", | ||
"type": "boolean" | ||
}, | ||
"rollover_in_parallel": { | ||
"default": 10, | ||
"description": "How many accounts to rollover per-pass (in parallel)", | ||
"type": "integer" | ||
} | ||
}, | ||
"type": "object" | ||
} |
18 changes: 18 additions & 0 deletions
18
applications/crossbar/priv/couchdb/schemas/system_config.tasks.modb_creation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"_id": "system_config.tasks.modb_creation", | ||
"description": "Schema for tasks.modb_creation system_config", | ||
"properties": { | ||
"create_in_parallel": { | ||
"default": 1, | ||
"description": "How many accounts to process per pass (in parallel).", | ||
"type": "integer" | ||
}, | ||
"creation_day": { | ||
"default": 28, | ||
"description": "Which day of the month (of current month) to create next month's MODBs on", | ||
"type": "integer" | ||
} | ||
}, | ||
"type": "object" | ||
} |
13 changes: 13 additions & 0 deletions
13
applications/crossbar/priv/couchdb/schemas/system_config.tasks.services_rollover.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"_id": "system_config.tasks.services_rollover", | ||
"description": "Schema for tasks.services_rollover system_config", | ||
"properties": { | ||
"rollover_in_parallel": { | ||
"default": 10, | ||
"description": "How many accounts to rollover services for per pass (in parallel)", | ||
"type": "integer" | ||
} | ||
}, | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Ledger Rollover Task | ||
|
||
The ledger rollover task, at the start of the month, walks the accounts and rolls over their ledger amount from the previous month to the new MODB. | ||
|
||
There is also a task to refresh the primary ledgers view, `totals_by_source`, to make sure the index isn't too far behind when the monthly rollover task occurs. | ||
|
||
## Rollover | ||
|
||
Rollover sums up the ledgers of the previous month's MODB and creates a new ledger in the now-current MODB for that amount. | ||
|
||
Set `tasks.ledger_rollover`'s `rollover_in_parallel` to control how many accounts to roll over at a time. | ||
|
||
## Refresh | ||
|
||
Refresh the view index for the `ledgers/totals_by_source` view to process any docs. | ||
|
||
For reference, running the rollover on an unindexed MODB with 12,000 docs (318 of which are ledger docs) took ~6 seconds. Running the same view on an up-to-date index took 70 milliseconds. Similar to CDRs, this is a good one to enable. | ||
|
||
Set `tasks.ledger_rollover`'s `refresh_view_enabled` to `true` to enable the job (performed daily). | ||
|
||
Set `tasks.ledger_rollover`'s `refresh_in_parallel` to control how many MODBs to refresh at a time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# MODB Creation Task | ||
|
||
Create account MODBs ahead of time. | ||
|
||
## Metered creation | ||
|
||
On the configured day of the month (the 28th by default), the task will calculate the seconds left until the start of the next month. Based on that time range and the number of accounts, MODB creation will be spaced across that time period. | ||
|
||
For instance: | ||
|
||
``` | ||
% May 28 2019 = 63726220800 | ||
% June 1 2019 = 63726566400 | ||
DiffS = (63726566400 - 63726220800) = 345600s | ||
Accounts = 1000 | ||
DelayPerAccount = (DiffS / Accounts) = 345600 / 1000 = 345s | ||
``` | ||
|
||
An MODB will be created every 345s until the end of the month. | ||
|
||
## Manually run | ||
|
||
If you need to manually run the task, you can use SUP to accomplish it: | ||
|
||
``` | ||
sup kt_modb_creation create_modbs | ||
``` | ||
|
||
This will spawn a worker and return immediately with the PID of that worker. | ||
|
||
## System Config | ||
|
||
### Date of starting creation | ||
|
||
System admins can select which day of the month to start MODB creation for the next month. Set `tasks.modb_creation` doc's `creation_day` to a number in `1..28` to ensure each month will trigger creation. | ||
|
||
### Parallel Creation | ||
|
||
System admins can speed this up by increasing the `tasks.modb_creation` doc's `create_in_parallel` (default is 1). If set to `10` for instance, the delay becomes `(DiffS / InParallel) / Accounts` or `34s` - 10 MODBs created every 34 seconds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Services Rollover Task | ||
|
||
Handles rolling over service totals to the new MODB. | ||
|
||
Set `tasks.services_rollover`'s `rollover_in_parallel` to control how many accounts to process at the same time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.