Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Writing a very scalable and specialized server

Posted on 2004-09-30
5
Medium Priority
?
297 Views
Last Modified: 2006-11-17
I've got the task of creating a server that simply recieves a connection and ~500 bytes of data immediately, then sends a few bytes of data and closes the connection. So I'm dealing with very short-lived connections, but I need to handle as many as possible.

I'm using winsock, and the server is a XP Pro machine with 2GB of memory and dual CPUs.

There seems several strategies for writing such a server, blocking, asynchronous, multi-threaded, single threaded, 2 threads per CPU, overlapped IO, and using IO completion ports.

AcceptEx() seems like a handy function (works with overlapped IO using either windows events or completion ports), in that it accepts a connection and recieves the first bit of data (which is all the data in my case) I then only need to send the response (simply a minimal http 404 response) and then close the connection. The processing on the data simply involves a hash table lookup and appending the buffer as is to a linked list. A seperate worker thread traverses the hash table at intervals looking for stale data and saving it to a database.

What kind of server model would suit me best?

Thanks for any information on the subject,
-Sandra
0
Comment
Question by:Sandra-24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1400 total points
ID: 12194073
I'd suggest the completion port approach - simply because this technology is (even since VMS) *the* base technology in the NT architecture and therefor *probably* scales best. A great sample can be found here: http://win32.mvps.org/network/sockhim.html (code at http://win32.mvps.org/network/sockhim.zip - plain C :o)
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 300 total points
ID: 12194445
Yep, that  AcceptEx() thing is one thing Microsoft did well, putting a whole lot of your basic connection startup code right into the TCP kernel.  Can't beat that with a stick.

0
 
LVL 1

Assisted Solution

by:drush_koders
drush_koders earned 300 total points
ID: 12196177
AcceptEx is the API apache uses.  You can see the actual Apache implementation here:
http://www.koders.com/c/fid0BD8A00D9DD136B078A793D719E26E389C0E8F95.aspx?s=AcceptEx

Hopefully this can help you get started a bit quicker.
0
 
LVL 1

Expert Comment

by:drush_koders
ID: 12196205
I would also suggest that you leverage an existing server like Apache or IIS to do the legwork for handling connections etc. for you.  If possible, you should build your app on a higher layer, possibly using modules for apache or ISAPI filters on IIS.  

At least for the first round, this will be the fastest way to get a functional application, and you can build your own server later if needed - but I wouldn't expect you really want to get into that business if you can avoid it.  The Apache team has spent a lot of optimizing and making custom extensions fast.  

0
 
LVL 3

Author Comment

by:Sandra-24
ID: 12196650
Well that makes things simpler, AcceptEx with completion ports it is.

You've got a good idea about Apache drush, but I'm going to do things the hard way. I value the experience at least as much as the end result. The way I figure it, it should only be about 1500-2000 lines for the network oriented code. How long could that take? I'll guess 2 weeks, which means it'll probably be done at the end of October, but I'll be able to put winsock programming with completion ports on my resume :)

Thanks guys,
-Sandra
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question