Performance
Production
The speed ultimately is determined by
- how fast you can prepare the messages
- network bandwidth
- performance on the remote side (SMPP Server)
- how fast you can process responses
On good tuned production systems you can reach 500 messages/seconds.
Tuning
You can try to play with following optimization parameters:
Change number of threads that process received messages. Dafault is 3.
client.WorkerThreads = 10;
Change receive or send buffer size for the TCP socket
client.ReceiveBufferSize = 32 * 1024 * 1024;
client.SendBufferSize = 32 * 1024 * 1024;
A larger buffer size might delay the recognition of connection difficulties. Consider increasing the buffer size if you are using a high bandwidth, high latency connection (such as a satellite broadband provider.)
Local Test
Inetlab.SMPP performance on local machine with disabled logging shows following results
Performance: 20356 m/s
Following code demonstrate this
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
using Inetlab.SMPP;
using Inetlab.SMPP.Common;
using Inetlab.SMPP.Logging;
namespace TestLocalPerformance
{
class Program
{
static void Main(string[] args)
{
LogManager.SetLoggerFactory(new ConsoleLogFactory(LogLevel.Info));
StartApp().ConfigureAwait(false);
Console.ReadLine();
}
public static async Task StartApp()
{
using (SmppServer server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777)))
{
server.evClientBind += (sender, client, data) => { /*accept all*/ };
server.evClientSubmitSm += (sender, client, data) => {/*receive all*/ };
server.Start();
using (SmppClient client = new SmppClient())
{
await client.ConnectAsync("localhost", 7777);
await client.BindAsync("username", "password");
Console.WriteLine("Performance: " + await RunTest(client, 50000) + " m/s");
}
}
}
public static async Task<int> RunTest(SmppClient client, int messagesNumber)
{
List<Task> tasks = new List<Task>();
Stopwatch watch = Stopwatch.StartNew();
for (int i = 0; i < messagesNumber; i++)
{
tasks.Add(client.SubmitAsync(
SMS.ForSubmit()
.From("111")
.To("222")
.Coding(DataCodings.UCS2)
.Text("test")));
}
await Task.WhenAll(tasks);
watch.Stop();
return Convert.ToInt32(messagesNumber / watch.Elapsed.TotalSeconds);
}
}
}