Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like advice on a scalable server application

Status
Not open for further replies.

BrianJH

Programmer
May 26, 2003
26
US
Hello,

I have developed the client side of a UDP client-server application that will handle about 100 people at a time. I would, however, like some advice on how I should go about building the server. Here's how I have it planned (remember that this is my first try at something like this):

1. The main Thread
- handles form events
- spawns 4 "worker thread"s
- spawns 1 "Master Thread"

2. The Master Thread
- listens for incoming packets
- puts messages into a queue
- checks each thread to see if it is started or not
- if it finds one stopped, activate it
- uses Thread.Start()
- return to listen

3. The worker thread(s)
- Use this sub:
Public queue(100) as string
Public Sub dowork()
...watches the first in the queue (queue(0))
...if it has a message in it, copy it to it's own
personal variables using a custom class.
...delete that message from the queue
...use the custom class for I/O and to handle the command
End Sub


Each person connecting might do a certain amount of work at one time, so I have decided to have an array of user ID's. At the beginning of each message would be the UserID followed by ":" and the command. the worker thread would be able to look at this public userid array and check a corresponding IPEndPoint array to find the users address and port. The worker thread would handle logouts by removing the userid and ipendpoint from the lists and moving the rest down one.

At some point I might add some database calls and I thought I would create 5 more threads for that purpose and do handling that way.

So how does this look? I'm hoping I got it fairly close. One other question: How should I go about making sure only one thread will read/write the Message queue, UserID's and IPEndPoint arrays at one time?

Thank you for your time and advice!

Brian

 
I see my question was overlooked all the way to page 4 of the forums. Is there any other information I can provide to make it easier to answer?
 
You seem to go for a big project. What you write looks good, but it will require a lot of testing. If you have the $$$, you might look at using a Windows server and Microsoft Message queue. This will have a lot of the functionality built in. Otherwise, it might be cheaper to buy more hardware then spend weeks programming resource-allocation thingies. A little hardware-overkill never hurt anybody.
 
I was unaware that there was server software capable of handling message IO's. I will certainly look into it, however I would still like some constructive criticism about my current architechture; this project is as much for learning as it is for anything else. I do have a computer here waiting to have a windows server OS installed, but I was going to put this program onto the server and leave it running.

Thank you for the post Mick, but does anyone have any other criticism about my server architecture? I find it hard to believe I could get it right in one try!

Brian
 
Has anyone here ever developed a server app like this one? If not, could someone direct me to a good article or another forum that might be able to help me better?

I wonder if I gave enough information to enable someone to help me out...if not let me know what kind of information you might need.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top