[asterisk-users] call file concurrency

Mik Cheez michael_bulk at wildgate.com
Fri Feb 27 18:07:02 CST 2009


Steve Edwards wrote:
> On Fri, 27 Feb 2009, James Sneeringer wrote:
> 
>> If you can get the outgoing directory (or a reaonable parent) on its own 
>> mountable partition or volume, you could accomplish this with disk 
>> quotas. It won't control how many Asterisk processes at once (does it 
>> even handle them in parallel?), but it will control how many can 
>> possibly be queued up waiting to be processed.
> 
> I'm thinking bad things could happen if a call fails (causing the call 
> file to be "appended") when you are at the limit. Also, this implies that 
> the process creating the call files can handle the quota error. This also 
> creates a bit of a "land mine" for the next admin when he replaces the 
> failed disk with one without the quota.
> 
> I think it should be handled by munging the code in pbx_spool.c.
> 
> I took a casual peek at the (1.2) code this morning, so don't hold me to 
> my opinions :)
> 
> The call file directory is scanned every once in a while and for each 
> eligible call file, a detached thread is kicked off to handle it.
> 
> Limiting the number of concurrent threads (call files) would mean 
> incrementing a [locked] counter as each thread is created and decrementing 
> the [locked, non-zero] counter as each thread finishes.
> 
> Then, in the loop that scans the directory, if the counter is greater than 
> the desired limit, exit the loop.
> 
> I'm sure there are more details to be worked out, but I think this could 
> be done easily.
> 
> At the same time, it might be nice to add a feature to "throttle" the 
> thread creation so that if a bunch of call files are dumped into the 
> directory Asterisk doesn't "spike" trying to create "concurrent-limit" 
> threads at "once."
> 
> Thanks in advance,
> ------------------------------------------------------------------------
> Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
> Newline                                             Fax: +1-760-731-3000
> 
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> 
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
> 
> 

Just my 2c, but what I've done in the past is modify the sleep function 
in asterisk from one based on seconds to one based on either 
milliseconds or nanoseconds (don't remember which).  Then I have a 
background daemon which looks to see how many files are in the 
directory, and if it's under threshold it pushes a new file from a queue 
into the directory.

Then, as they say above, you set the ulimit to something like 'ulimit -n 
100000' or whatever it is you want.

Of course, the purpose for sending out a bazillion calls is another 
question . . . play nice.





More information about the asterisk-users mailing list