Saturday 21 February 2015

Fast Traffic Packet Processing In Multi Threaded Environment

Topic:  Discussion on do we require multi thread in network packet processing engines (A packet processing linux based application) 

What is most important to us 
a)      Packet processing must be faster 
                                 i.            There shouldn't be packet queuing in the application
                                ii.            Should use less resource  (i.e)   minimum memory  on the socket receive front
Hence will have less kernel memory utilized
                              iii.            The CPU utilization should not be high ,  overall load average of the CPU should be in control
b)      Database update upon packet processing should be success
                                 i.            There shouldn't be data update missing after packet processing 
                                ii.            Updating your data from the packet shouldn't be delayed  nor missed

How To Approach :
There are multiple architectures which could help to achieve this "Fast Packet Processing Engine".

1)      The first item is all about , what is the data incoming on the receive socket , and what are we doing to do with that data. Do we store it independent  [OR] we just need to act as Gateway [OR]  Relay the packet , and so on .
2)      Based on the data structure design ,  we would able to conclude the architecture for the "Fast Packet Processing Engine"
3)      After deciding the available factors,  we shall go for the "Hardware and CPU Optimized Configurations"
Here Am going to elaborate on  "Fast Packet Processing Engine  For Internet Users"
     
Fast Packet Processing  Engine Specifications:
ü  Multi Processing
ü  Multi Threading  Queue
ü  Radix Tree Implementation for data store

Work Flow :
v    Multiple instance of child processes  -- Decide based on the network traffic in the systems .   A process does packet  receiving functionality and given to  thread worker queue.
v  Pthread worker queue, does the job of handling the packet , and update the data on Radix Databases.  The lock mechanism applied using mutex.
v  The processes scheduling , and load sharing the incoming traffic are implicit from the features of Linux Kernel. Hence the traffic  load distributed  among the number of the  "Child Process Instances"
v  Consider  "Internet User ID" - Example: Mobile Number, Wifi  Client ID, etc . (i.e) A Unique Client ID will be the key for Radix Database.
Achievement :
·          Packet processed at the high rate that of incoming packets.
·         Never packet data got missed, since the pthead packet processing queue will take care of queuing it , if the number of packets are more than the threads.
·         Thereby Fast Packet Processing Engine shall be achieved

Disadvantages:
Ø   Mutex Locking, could lead to race condition,  however as we have handled properly in the Code Implementation, this shall be avoided
Linux Server Specifications:

*       Multi Core, Multi CPU Platform , 64 GB RAM (any high end server configuration shall be applied).


FEEL FREE TO COMMENT . 

 Thanks . 

No comments:

Post a Comment