473,438 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,438 software developers and data experts.

client/server question.

Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #1
6 1118
Hi,

The thread pool is definitely preferred. There's indeed no use in running
thousands of threads - the context switching overhead will be so big that
you won't gain any performance increase, I'd even say you'll get performance
degrade. Therefore, use the thread pool and make sure the packet processing
is very quick - in this case, the 25 or so working threads should be
efficiently handling the request queue.

Of course I am assuming you have decent hardware - if the workload is
planned to be really high, you might want to consider a multi-CPU system.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:2A**********************************@microsof t.com...
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.



Nov 17 '05 #2
if there will be thousands of connections it is better to use threadpool, or
there is also CompletionPort implementation in the internet.

This solution is more scalable than just using thread/connection.
Great number of threads is bad, because not all of them will perform
efficiently...

http://www.codeproject.com/internet/winsockiocp.asp

--
Vadym Stetsyak aka Vadmyst

"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:2A**********************************@microsof t.com...
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #3
Why a new thread for each packet? Many times a new thread for each "client"
is very workable, but not a new thread for each packet. Think you need to
expand more on your requirements before we go farther down the road here.
Cheers.

--
William Stacey [MVP]

"Naveen Mukkelli" <Na************@discussions.microsoft.com> wrote in
message news:2A**********************************@microsof t.com...
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #4
Do you expect all 1000 packets to be arriving and processing concurrently? I
would guess no. Try to get a feeling for; 1) the average rate at which
packets arrive, and 2) the average time it takes to process a packet.

Given these figures you can calculate how big a pool you would require such
that there would always be an available thread in the pool to handle an
incoming packet. I'm guessing this will be much less than the thousands of
Thread objects needed to handle all the packets.

-- Tom

"Naveen Mukkelli" wrote:
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #5
If the ThreadPool can fulfill your needs, there is no way I would recommend
spawning individual threads.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Naveen Mukkelli" wrote:
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #6
Thanks for your response. I will implement thread pools and let you know the
result.

"Cowboy (Gregory A. Beamer) - MVP" wrote:
If the ThreadPool can fulfill your needs, there is no way I would recommend
spawning individual threads.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Naveen Mukkelli" wrote:
Hi,

I'm working on a client/server application.
In the current design, a new thread will be spawn, both on server and
client side,
to process every packet received.

As both client and server and client applications will be receiving
thousands of
of packets in any single session, there would be thousands of threads
created
to process the packets and then destroyed. I read in one of the
microsofts article
that this is an extra overhead and hence not recommended.

On the other hand, if we use thread pool, there would be only 25 threads
available to process the thousands of packets received.

In this scenario, what would be the better choise between a thread for a
packet,
thread pool.

kindly let me know. If you need any more information do not hesitate to
contact
me.

Cheers,

Naveen.


Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server...
18
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
7
by: CT | last post by:
Hi, This might seem like a basic question but I have some doubts, please humour me. I have a client-server application using java where each client on each machine needs to directly...
12
by: ShepardBerry | last post by:
This may be a dumb question, but I'm not finding anything specifically what I'm looking for. Still kind of new to .NET as well. What I'm trying to do that I know I could do in VB6.0/ASP is to...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
9
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that...
1
by: Frank Millman | last post by:
Hi all I am developing a multi-user business/accounting application. It is coming along nicely :-), though rather slowly :-( I have hit an issue which will require a lot of changes to the code...
2
by: Wimpie van Lingen | last post by:
Hey I have some more questions with regards to Remoting in .NET 2. I'm using TCP with the Binary formatter. My solution consists of 4 projects: - Class Library containing the server classes...
11
by: Jeff | last post by:
Hello everyone. I've searched through the archives here, and it seems that questions similar to this one have come up in the past, but I was hoping that I could pick your Pythonic brains a bit. ...
6
by: 7stud | last post by:
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv textport = sys.argv s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.