Unload asterisk server - Batch save cdr
Hi All,
This chronicle will be use to give you tips where you can unload your asterisk server and make him do what heĀ is suppose to do : Take calls.
One departement were you can save processing is CDR logging and database writing.
By default, asterisk will write or post your call detail record (CDR) at the end of every calls. This help keeping track of all calls including bill seconds. But if you have too many calls, the load of your server writing CDR or inserting in the database can become enormous.
You can add some options in /etc/asterisk/cdr.conf. For example, asterisk can just collect the cdr and after 10 calls ou 5 minutes, write the call details in a file or insert them in the database.
Here are options that will help you doing so:
vi /etc/asterisk/cdr.conf
[general]
batch=yes
size=100
time=300
scheduleronly=no
safeshutdown=yes
!!! WARNING (PLEASE READ) !!!
You need to know exactly what every parameter means here and need to tune in those parameters to fit your environment or type of business.
- batch = yes. This means that asterisk will keep CDRs for x seconds (see parameter size and time) and post them all at once. This also means that if your asterisk server crash, or if you manually kills it (kill -9 asterisk) you will loose every CDR in memory. So, if CDRs are very critical for your business and your asterisk server trends to crash sometime, you may consider not enabling this feature. But, if you want to easy loads on asterisk and databases, you can do it. However, you can reduce how many CDR you may lost in case of crash but using ’size’ and ‘time’ parameters.
- size = 100. This means that, at any time, if the number of CDR kept in memory reach 100, they will be post or send in the database.
- time = 300. This means that, every single 300 seconds (5 minutes), the CDR will be post whatever the size is.
- scheduleronly=no. Asterisk has one thread (a kind of separate internal process) whose only job will be to post CDR when comes the time to do so or when the size is reach. If set to ‘no’, everytime the size will be reach, asterisk will start a new thread to post your CDR. If set to ‘yes’, only one still active thread will do the job again and again. Why is this important ? If you set it to ‘yes’ and the same thread is responsible of doing the same job, if you have any kind of delay while posting CDR, the following CDR will be block until the previous are done. That’s why I recommand one separate thread every time specially if your size is big.
-safeshutdown=yes. When you run ‘asterisk> stop now’ in asterisk cli, if this option is set to ‘yes’, asterisk will issue the last CDR post before shutting down, if not, your still-in-memory-CDR may be lost. So, keep this to yes unless CDRs are not very relevant in your business.
Comments
Leave a Reply