LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-29-2011, 06:16 AM   #1
pritom057
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
How to increase Multi Threaded Server Proficiency


I am implementing a proxy server in c++. It is multithreaded(posix).

Used CPU : Xeon(8core)

Thread number : 8

One main thread, and other 7 thread created by the main thread.

The main thread always listen to ports. When the main thread gets a client data it push the request in a queue[there are one queue(total 7) for each thread] based on ip and then give a signal to the appropriate thread. Then that thread gets the request from it's queue and process data and then forward the data to a appropriate destination. There is another important thing, I assign each thread excluding the main thread to individual core by using affinity.The main thread listens to 5 ports.



Test environment: We run the server. The client sends audio data at a particular rate.



Problems:

1. The main thread CPU usage gets overloaded (above 80%) after a certain load from client.

2. Other cores remain about 0-10%.


The thing is that we want to distribute the load among all the cores equally by multithreading. But how can we do this ? Can the listening task of ports also be distributed ? I need an efficient algorithm for load balancing among threads.


The data sent and receive rate of server is about 8.5MB/s. How can we improve this ?

We are using gigabit LAN card.

When the server only receive data from client it can receive data above 80MB/s. But when it both receives and sends data simultaneously it only manage upto 8.5MB/s. Why is this happening ?


Help needed badly

Thanks
 
Old 05-01-2011, 05:25 PM   #2
plpl303a
Member
 
Registered: May 2011
Posts: 52

Rep: Reputation: 3
You could have several threads, one per port to listen to. But then you'll need to make sure you have locking or some other queuing discipline so that if two threads try to push to the same queue at the same time things don't get corrupted.

Is the main thread overloaded because there are many small messages or because there are fewer very large messages? (Is this a UDP-based approach where the main thread gets a packet, pushes data to a queue and is then done or is it a stream-based (TCP) approach where there is a significant ongoing conversation?)

If your cores are at 0-10%, does that mean that you are I/O bound? If the processing isn't very CPU intensive then perhaps your bottleneck isn't the CPU's at all. In which case, it seems doubtful that more concurrency at the processor level will be helpful. Or do you know that there is a significant amount of computation in progress?

8.5MB/sec = 68Mbit per second -- well below the capacity of a gigabit LAN card...unless the switch itself is the bottleneck. Do you know that the switch is in fact gigabit to all ports? (I know that most of the switches I have worked with, if they have gigabit links at all, it's only one or two uplink ports.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multi-threaded server, pthreads, sleep Parahat Melayev Programming 6 01-17-2012 06:20 AM
Multi-threaded Chat Server sci3ntist Programming 4 10-11-2007 05:49 AM
pthreads - multi-threaded server elitecodex Programming 1 08-20-2005 03:58 PM
how to do waitpid() using a multi-threaded server? Thinking Linux - Software 1 04-13-2005 09:50 PM
Segementation fault on Multi threaded server on ia-64 Linux Latha Linux - Software 3 09-09-2004 06:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration