Some of you may have seen my post in another thread about a web server I had written in less than 100 lines. I've since developed it to multithreading whilst keeping the same basic code. Interested in performance I run a stress test on both of them and thought you might be interested. I can't guarentee that there was a constant number of requests on the servers. So from the graph I'd guess that the single threaded was quicker until there were more than one and then it spiked quite high. The multi threaded remained fairly constant except for at the end when the screen saver came on.
Pete
[attachment deleted by admin]
Web Servers
Re:Web Servers
Does your web server have support for cgi scripts? Like php or perl for instance.
Re:Web Servers
No, not even files. It merely returns:-
The idea was just to write a small thing. Here's the multithreaded version. Its only 81 lines of neat C.
My main aim is to use it for embedding in other applications.
Pete
[attachment deleted by admin]
Code: Select all
<h1>Hello World</h1>
You requested : [page name]
My main aim is to use it for embedding in other applications.
Pete
[attachment deleted by admin]
Re:Web Servers
These results aren't too surprising. Remember that there's a small amount of overhead involved in switching between threads -- that's the price you pay for more flexible programming. It's because of this that a dual CPU system is less than twice as fast as an equivalent single CPU system.
If you're interested in more speed, you could look at I/O completion ports (Windows only). Using an IOCP lets you have a fixed number of threads (usually one per CPU) servicing all clients. Each thread waits on a single IOCP by calling GetQueuedCompletionStatus. When something happens on a file/socket attached to the IOCP, one thread unblocks and can do some processing.
If you're interested in more speed, you could look at I/O completion ports (Windows only). Using an IOCP lets you have a fixed number of threads (usually one per CPU) servicing all clients. Each thread waits on a single IOCP by calling GetQueuedCompletionStatus. When something happens on a file/socket attached to the IOCP, one thread unblocks and can do some processing.