BillRun is open-source billing solution for enterprise, which built on top of MongoDB.
This presentation took place on Israeli MongoDB User Group meeting, February 20, 2014, at John Bryce college, Tel Aviv.
Find out more: http://billrun.net
4. Who am I
●
●
●
●
●
Open Source Evangelist
Board member
Started from DevOp
Shifted to Biz
Co-Founder at S.D.O.C. Ltd.
○ open source solutions for enterprises
● Mongo user since 2012
6. How it all began
● Partnering a startup Golan Telecom (GT)
● Telecom CDR first use - Anti-Fraud
○ CDR = Call/Charge detail record
● CDR Types: MOC, MTC & Data
○ 3 Different data structure
○ MOC/MTC duration=0 means SMS
7. SQL Implementation
$base_query = "SELECT imsi FROM moc WHERE callEventStartTimeStamp >=" . $start
. " UNION SELECT imsi FROM mtc WHERE callEventStartTimeStamp >=" . $start
$base_query = "SELECT imsi FROM (" . $base_query . ") AS qry ";
if (isset($args['imsi']))
$base_query .= "WHERE imsi = '" . $this->_connection->real_escape_string($args['imsi']) . "'";
$base_query .= "GROUP BY imsi ";
$mtc_join_query = "SELECT 'mtc' AS type, imsi, SUM(callEventDuration) AS duration, SUM(CEILING(callEventDuration/60)*60) AS duration_round "
. ", SUM(chargeAmount) charge "
. ", SUM(IF(SUBSTRING(callingNumber, 1, 3)='972', callEventDuration, IF(CHAR_LENGTH(callingNumber)<=10, callEventDuration, 0))) AS israel_duration "
. ", SUM(IF(SUBSTRING(callingNumber, 1, 3)='972', CEILING(callEventDuration/60)*60, IF(CHAR_LENGTH(callingNumber)<=10, CEILING
(callEventDuration/60)*60, 0))) AS israel_duration_round "
. ", SUM(IF(SUBSTRING(callingNumber, 1, 3)!='972', IF(CHAR_LENGTH(callingNumber)>10, callEventDuration, 0), 0)) AS non_israel_duration "
. ", SUM(IF(SUBSTRING(callingNumber, 1, 3)!='972', IF(CHAR_LENGTH(callingNumber)>10, CEILING(callEventDuration/60)*60, 0), 0)) AS
non_israel_duration_round "
. ", SUM(IF(callEventDuration = 0, 1, 0)) AS sms_count "
. "FROM mtc "
. "WHERE callEventStartTimeStamp >=" . $start . " "
. "GROUP BY type, imsi";
9. It still continues
$group_query = "SELECT base.imsi, moc.duration AS moc_duration, moc.charge AS moc_charge, "
. "mtc.duration AS mtc_duration, mtc.charge AS mtc_charge, "
. "mtc.duration_round AS mtc_duration_round, moc.duration_round AS moc_duration_round, "
. "moc.israel_duration AS moc_israel_duration, moc.non_israel_duration AS moc_non_israel_duration, "
. "moc.israel_duration_round AS moc_israel_duration_round, moc.non_israel_duration_round AS moc_non_israel_duration_round, "
. "mtc.israel_duration AS mtc_israel_duration, mtc.non_israel_duration AS mtc_non_israel_duration, "
. "mtc.israel_duration_round AS mtc_israel_duration_round, mtc.non_israel_duration_round AS mtc_non_israel_duration_round, "
. "mtc.sms_count AS mtc_sms_count, moc.sms_count AS moc_sms_count "
. "FROM "
. "( " . $base_query . " ) AS base "
. " LEFT JOIN (" . $mtc_join_query . " ) AS mtc ON base.imsi = mtc.imsi "
. " LEFT JOIN (" . $moc_join_query . " ) AS moc ON base.imsi = moc.imsi " ;
if (isset($args['limit'])) {
$limit = (int) $args['limit'];
} else {
$limit = 100000;
}
13. Next - Small (ILDs) Billing
● Billing only for ILDs (A.K.A. MABAL)
○ Received 6 types of CDRs *almost* the same
○ Each MABAL do what is under his 7th letter
● We decide from day 1 to go with Mongo
14. Small Billing - TCO
● 2 weeks of dev
● 2 days of deployment and first run
● 10,000 invoices
● Low maintenance=>Avg of 2 hours per month
● Base architecture for the main billing
16. Main Billing storage requirements
● 10 types of CDRs
○ Some binary hierarchical - Nokia Siemens
specification
● 500,000,000 CDRs per month
● Requirement to save each CDR in DB
storage.
● Fields can be added on the fly
17. Main Billing storage size
● 500,000,000/28 days/24 hr/60 min/60 sec
○ 232 CDRs per second
18. Main Billing storage size
● 500,000,000/5 days/24 hr/60 min/60 sec
○ 1152 CDRs per second
19. Main Billing storage size
● Today GT have 400,000 subscribers
● Might be 800,000 in the near future
● Data usage (CDRs) increasing (40% of the storage)
● Zero downtime
● 2 data centers redundancy
22. Sharding
● Shard key
○ Requirement for good balancing
● Updates are really fast with shard key
○ No collection lock yet
○ But lock only part of the DB (1 shard)
25. Pay attention
● With SSD you get x20 more performance
○ 5000 lines/second inserted during peak
● Mongo loves RAM
○ All used indexes must to be in RAM
○ Means, each shard have 64 GB in our env
30. Billing - Maintenance
● MongoDB subscription
○ Leverage your professionalism
○ Special for enterprise or start-up
○ Low TCO
● Monitoring
○ Built in commands for kick-off
○ MMS the best tool for this purpose
31. Billing - Maintenance
● Backup - hot or cold
○ With replica it’s pretty easy (without downtime)
○ Can be done with MMS or simple script
32. Billing - BI
● MongoDB to SQL
○ Script convert hierarchy to one dimensional object
○ Script to CSV to MySQL
● Pentaho BI tool
33. Billing - TCO
● 3 months dev
● 1 month without SSD
● 2 months QA
● Solution can be extends easily
○ Without app change