RE: Asynchronous vs Synchronous network communication
From: Daniel Roth [MSFT] (daroth_at_online.microsoft.com)
Date: 01/01/05
- Next message: Keith Rome: "Re: Troubleshooting a GC Collection?"
- Previous message: David Browne: "Re: Garbage Collection/OutOfMemory Exception"
- In reply to: Daniel Roth [MSFT]: "RE: Asynchronous vs Synchronous network communication"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 01 Jan 2005 01:16:41 GMT
In response to your second question about network throttling, some bandwidth management should be performed by the underlying Winsock implementation. You should
probably make sure you set a limit on the total number of outstanding requests so that you don’t build up an ever-growing backlog. For example, if you need to do a DNS
lookup and there’s 1000 already pending, the new one shouldn’t be allowed.
At the DNS protocol level, you could implement a simple wait and retry algorithm. For example, the first time out could be set to 1 second and the retry count could be set to
3. Each time the UDP request has timed out, multiply the timeout by 3 or some other constant factor and retry.
Daniel Roth
--------------------
| X-Tomcat-ID: 368661862
| References: <2cd15a34.0412052010.37ec416b@posting.google.com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: daroth@online.microsoft.com (Daniel Roth [MSFT])
| Organization: Microsoft
| Date: Fri, 31 Dec 2004 18:21:38 GMT
| Subject: RE: Asynchronous vs Synchronous network communication
| X-Tomcat-NG: microsoft.public.dotnet.framework.clr
| Message-ID: <v0DxPW27EHA.768@cpmsftngxa10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.clr
| Lines: 82
| Path: cpmsftngxa10.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:12618
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Noel,
|
| The benefit of doing asynchronous network communication is that you maximize the use of you processing power. Synchronous calls will waste processing time as your
| program waits for network communication to occur.
|
| To perform asynchronous operations, some sort of threading model must be used. A simple example would be to use one thread per request. Unfortunately, there is
| overhead associated with threading, so this simple example does not scale well. The threading model used by the .NET Framework takes advantage of Windows I/O
| Completion Ports (a form of thread pooling) in order to achieve maximum scalability. For optimal performance, the asynchronous pattern should always be used.
|
| Daniel Roth
|
|
| --------------------
| | From: noelhustler@gmail.com (Noel)
| | Newsgroups: microsoft.public.dotnet.framework.clr
| | Subject: Asynchronous vs Synchronous network communication
| | Date: 5 Dec 2004 20:10:22 -0800
| | Organization: http://groups.google.com
| | Lines: 23
| | Message-ID: <2cd15a34.0412052010.37ec416b@posting.google.com>
| | NNTP-Posting-Host: 201.128.126.165
| | Content-Type: text/plain; charset=ISO-8859-1
| | Content-Transfer-Encoding: 8bit
| | X-Trace: posting.google.com 1102306222 20848 127.0.0.1 (6 Dec 2004 04:10:22 GMT)
| | X-Complaints-To: groups-abuse@google.com
| | NNTP-Posting-Date: Mon, 6 Dec 2004 04:10:22 +0000 (UTC)
| | Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.com!border1.nntp.dca.giganews.com!
| nntp.giganews.com!news.glorb.com!postnews.google.com!not-for-mail
| | Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:12403
| | X-Tomcat-NG: microsoft.public.dotnet.framework.clr
| |
| | Hi,
| | I am a tad confused about if there are any benefits from using
| | asynchronous vs synchronous network communication.
| | As my example, I have been writing a dns lookup stack with a network
| | communication class switchable between asynchronous and synchronous.
| | When I use asynchronous udp communication I find that if I want to
| | process a large amount of dns lookups I have one dns provider with
| | many state objects passing through (and a high object churn rate). If
| | I use synchronous udp communication I don't need state objects, but
| | have many providers each in a thread (although these providers are
| | static and so there is low churn).
| | It seems to me that both methods amount to the same result other than
| | the fact that using asynchronous communication results in a higher
| | object churn rate (leading to higher memory usage).
| | Can anybody clarify whether there really is an advantage in using one
| | over the other?
| |
| | My second question is a bit of a throwaway. Using whatever network
| | communication, what kind of techniques exist to throttle something
| | like this based on available bandwidth?
| |
| | Thanks,
| | Noel
| |
|
|
| --
|
| This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
| http://www.microsoft.com/info/cpyright.htm
|
| Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
|
|
-- This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
- Next message: Keith Rome: "Re: Troubleshooting a GC Collection?"
- Previous message: David Browne: "Re: Garbage Collection/OutOfMemory Exception"
- In reply to: Daniel Roth [MSFT]: "RE: Asynchronous vs Synchronous network communication"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|