The Artima Developer Community
Sponsored Link

Design Forum
C++ Server: Mult thread VS Single thread

1 reply on 1 page. Most recent reply: May 14, 2007 2:04 PM by Martin Kardigen

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Marcos Eduardo

Posts: 1
Nickname: marcosedu
Registered: May, 2007

C++ Server: Mult thread VS Single thread Posted: May 14, 2007 8:41 AM
Reply to this message Reply
Advertisement
Hi guys,

I startin the project of a (web) server in c++ and i want to able to manage about 1000-2000 clients.

I have been reading alot about Single-thread VS Multi-thread server and i wanna know what u guys think about it.

I do not plan on using one-thread-per-client because i have heard that its too slow for 1000+ clients.

On the begin , i was 100% about using about 5 threads , by service:
1 for the Window Console (so the user can see its information without freezy the window)
1 for sending data
1 for receving data
1 for Accepting new clients
1 for computing the ugly processes (AI)

But then I heard about ppl sayin that have done webservers with only 1 thread (3 in my case, cause 1 for the window, 1 for acceptin new clients and 1 AI, Receving, Sending data), and i came up with the thought that if i do only use 1 thread for Receive,Sending and AI I wouldnt need to Lock/Unlock so much data (in those 3 processes).

What i wanna know is that, would u guys try to put the Receive,Sending and AI in just 1 process?

and

(Even though i believe dont, i need to make sure:) Would the access to the database (mysql in my case) LOCK my thread for a couple ms? or its just like another function call?


Thanks alot for the help =)
Marcosedu


Martin Kardigen

Posts: 6
Nickname: kardigen
Registered: Oct, 2006

Re: C++ Server: Mult thread VS Single thread Posted: May 14, 2007 2:04 PM
Reply to this message Reply
Hi

> I startin the project of a (web) server in c++ and i want
> to able to manage about 1000-2000 clients.

I think it's Your first server ;) At first You should look at some existing implementations f.g.:

Apache - http://apache.org/
THTTPD - http://www.acme.com/software/thttpd/.


> have heard that its too slow for 1000+ clients.

I think, multi-threading is a good approach for servers which process data (make lots calculations), for webservers (which transport data) single-threaded should be enough.
I suggest you to start with single-threaded because it is easier to debug ;) First try to understood how THTTPS works. I thing it will be the best answer for Yours questions for now.

> 1 for the Window Console (so the user can see its
> information without freezy the window)

I'm guessing - You think about MS Windows as a base platform? Read something about a "Logging" systems.

good luck

Flat View: This topic has 1 reply on 1 page
Topic: 100% Unit Test Code coverage using Mock, does it really matter? Previous Topic   Next Topic Topic: wanted: programms with innovativ help-functions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use