Xafari Server Performance - Xafari Framework

Xafari Server is a separate service that handles the tasks in the Message Queue, and stores the results in  XAF application database. This post discusses its performance. Using the server significantly accelerated querying compared to querying in the application , even if the server and the application is deployed on a single workstation. Acceleration is achieved through the use of multi-threading and a pool of database connections. Additional features are a cancellation request, to add (delete) message handler.  Server does not supports asynchronous automatically. To implement an asynchronous message handler, the developer must define the beginning of the substantive work in a separate thread. See, for example, implementation of the IMessageHandler.StartHandler method in XafariMQSample.

        public void StartHandler()
        {
            _cancellationToken = _source.Token;
 
            LockReportMessage();
 
            var handlerTask = Task.Factory.StartNew(ProcessMessage, _cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
            Task.Factory.ContinueWhenAll(new[] { handlerTask }, tasks => FinishProcessing(), _cancellationToken);
        }

Creating a task to handle the message:

var handlerTask = Task.Factory.StartNew(ProcessMessage, _cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);

The main logic of the handler is encoded in the ProcessMessage delegate.

The table below shows the results of running various message handlers. For testing was used XafariMQSample application and one Xafari Server. Workstation : Intel Core i3-3220 processor and 8 Gb RAM.

Step Message handler specific The average intensity of message processing,message / s Average message processing time, s
1 Handler does nothing 2223 0.00047
2 Handler runs in a separate thread, changes the message status and supports the cancel of execution 370 0.0027
3 The handler as in step 2, added function to save result in DB 77 0.013
4 The handler as in step 2, added function to perform an operation lasting 10 seconds 56 0.0179
5

The handler as in step 2, added 2 functions:

  • to perform an operation lasting 10 seconds
  • to save result in DB
36 0.0278

Server performance was more than 2000 messages in 1 second, excluding message processing. Needless to say, after the addition of the various operations handler, the performance will drop somewhat. If the message processing  in the thread is longer 50 ms., then for the creation of thread it is recomended to use TaskCreationOptions.LongRunning option.

Related Posts

Leave a reply