Our SMS API is now twice as fast*
Yes, it’s another of those outlandish claims about how our latest release has made things twice as fast. But we feel we can back it up.
Recently one of our larger customers asked if there was any way we could speed up sending large batches of 40,000+ text messages. They currently break the send down into blocks of 500 messages and send these over our XML API.
This got us thinking about all the steps a text message has to go through so we ran some tests to get a base line figure.
To make sure we were seeing performance similar to our customers, we ran all our tests on Redhat Linux 5 box over our office ADSL connection pointed at the same servers our customers use.
Our test script sent 10,000 messages as 20 batches of 500. Each batch was encoded in XML and the HTTP request timed. We also tried 4 concurrent sends as we recommend people multi-thread for improved throughput.
Initial test results
A single process sending 10,000 messages took exactly 3 minutes 45 seconds giving a rate of 44 sms/second
Four processes sending 10,000 each took 4 minutes 27 seconds giving us a rate of 150 sms/second
Digging through log files we could see that reading in and validating the XML request took about 7 or 8 seconds, so this was an obvious place to optimise, next step code profiling.
Bring on the code profiler
After a bit of experimenting, we settled on JetBrains dotTrace which can do line by line profiling rather than just function calls. The output from this looks like this: The highlighted line shows exactly where the problem is, each call to Log takes about 1ms, unfortunately there are 6000 of these calls, totalling 6 seconds.
Hmmm... that's a bit slow
6 seconds just for logging is horribly slow, so what to do about it….
Step 1: Disable logging and try again This worked exactly as expected and cut about 7 seconds off the processing time.
Step 2: Research We were using BitFactory.Logging version 1.4 by The Object Guy what else is available to fix the problem?
Step 3: Fix it We upgraded to version 1.5 of the BitFactory logging framework, and swapped our logger to the new Asynchronous Logger and re ran our tests on the development platform. It ran as if there was no logging at all.
We released the SMS API using the updated logging framework on Monday and re-ran our test.
The single process sending 10,000 messages took 1 minute 10 seconds, thats 90 sms/second, just over double the original speed.
Four concurrent processes sending 10,000 messages each took 1 minute 7 seconds, giving 373 sms/second, that’s almost 2.5 times the original throughput.
The asterisk (*) from the title
So, in conclusion, if you send batches of 500 messages you should see a significant improvement in the speed of your sends. Individual sends to a single number will see much smaller savings, maybe only a few milliseconds. In my opinion, that backs up the claim nicely.