Sending Bulk SMS using Multi Threading
-
I have a design issue in my code which I want to clear off. I have an SMS data contains lakhs of records group by an Unique Code in my C# appplication. So under each Unique code, there will tens/thousands/lakhs of records to sent. So currently, applications picks up one Unique code, select all the unsend records and send. Then move forward and picks the next one like this going one. This is creating more delay in sending and clearing off the sms in a single day where we have lakhs of sms to send. So I think of converting the same to Multi-threaded application, so multiple threads starts at same time, picks up each unique id set and select records to sent, there by running two / three process running at same time, and it will be faster, i believe. Please advise if this is the correct method to implement or is there any other better ways.
-
I have a design issue in my code which I want to clear off. I have an SMS data contains lakhs of records group by an Unique Code in my C# appplication. So under each Unique code, there will tens/thousands/lakhs of records to sent. So currently, applications picks up one Unique code, select all the unsend records and send. Then move forward and picks the next one like this going one. This is creating more delay in sending and clearing off the sms in a single day where we have lakhs of sms to send. So I think of converting the same to Multi-threaded application, so multiple threads starts at same time, picks up each unique id set and select records to sent, there by running two / three process running at same time, and it will be faster, i believe. Please advise if this is the correct method to implement or is there any other better ways.
Threading is not a magic bullet: it won't automatically speed things up, indeed it can slow things down! Threads require a free core to run, if one is not available then the thread is suspended until the next one that is free (this is an oversimplification, windows preempts tasks to give other threads a chance). And thread handling adds an processing overhead in terms of both speed and memory - so if the number of threads you create exceeds the number of cores, you get into the realms of diminishing returns. So just "creating threads" to do the job "at the same time" won't necessarily help you - you need to look at how you are sending the SMS: if there is hardware involved such as a mobile phone you are interfacing to, threading will not speed things up as the mobile can only process one SMS at a time. Start by looking at your whole system, and identify where the bottleneck is: you should concentrate of improving that, rather than looking for "magic bullet" solutions.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
I have a design issue in my code which I want to clear off. I have an SMS data contains lakhs of records group by an Unique Code in my C# appplication. So under each Unique code, there will tens/thousands/lakhs of records to sent. So currently, applications picks up one Unique code, select all the unsend records and send. Then move forward and picks the next one like this going one. This is creating more delay in sending and clearing off the sms in a single day where we have lakhs of sms to send. So I think of converting the same to Multi-threaded application, so multiple threads starts at same time, picks up each unique id set and select records to sent, there by running two / three process running at same time, and it will be faster, i believe. Please advise if this is the correct method to implement or is there any other better ways.
Look at the whole process, perhaps plot it out on paper as a chart. You can add code to measure the time of each process, start time and stop time, then stop - start = time. Maybe it's your DB write, when you update the record as sent. Writes can take forever. Consider grabbing 100 numbers at a time, send, update an in memory array, and then grab another 100, and while it's sending, update the database as many in the background.Sort of a flip flop method.
If it ain't broke don't fix it Discover my world at jkirkerx.com