[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] MHD_handle_connection() performance issue

From: Eivind Sarto
Subject: [libmicrohttpd] MHD_handle_connection() performance issue
Date: Tue, 22 Mar 2011 20:16:18 -0400

I am using libmicrohttpd to serve a large number of video players that is using 
a "smooth" streaming format.
That means the video stream is divided into separate chunks and that the client 
can decide to jump to a
faster or slower encoding of the video stream on any chunk boundary.  The 
length of a video chunk is
typically several seconds (<= 10 sec).
(If you have 1000 clients all playing videos in 10 second chunks, you will have 
100 requests/sec)

I wrote a client simulator so I can do some load testing without buying a whole 
bunch of client devices.

The server gets extremely busy as crank up the number of clients.  I am running 
the server with 
The reason for this appears to be that MHD_handle_connection() will poll both 
the connection socket and
the listen/server socket.  And every time there is a new connection, all the 
active connections will return
from poll, because they are also polling the listen/server socket.
It gets pretty awful as you try and crank up 1000 simulated streams.  The cpus 
are almost completely saturated with
each connection/thread polling again and again, each time a new connection is 

I made a debug version of  MHD_handle_connection() that only polls the 
connection socket, and I can run several
1000 video clients with almost no cpu load.
But, each connection thread can no longer detect if the server is shutting down.

Any suggestion or feedback about what could be done to improve this situation?

Note: I am using the latest svn version with the fixes to MHD_poll() for 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]