473,509 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building a Scalable (100K+ User) Socket Server in .Net

One of the things I've spent the last several years working on is a highly
scalable socket server written in C#.

The SoapBox Server has recently been tested to well over 100k simultanous
users. This means it's handling 100k TCP connections on a Windows Platform
without any trouble at all.

I finally got around to writing a blog post that describes the different
architectures we've gone through, and the pros and cons of each. All of
these architectures scale fairly well, but there have been some surprising
results. These architectures have included using the system threadpool,
managing our own thread pool, doing work on the IOCP threads, and a few
other things thrown in for good luck.

I've seen so many people asking for guidance in this area, and I hope this
serves people as a good starting point.

http://makeashorterlink.com/?R2EE5246D

All feedback is welcome, either here or on the blog...

--
Chris Mullins
Coversant, Inc.
Jul 12 '06 #1
8 4099
Chris Mullins wrote:
One of the things I've spent the last several years working on is a
highly scalable socket server written in C#.

The SoapBox Server has recently been tested to well over 100k
simultanous users. This means it's handling 100k TCP connections on a
Windows Platform without any trouble at all.

I finally got around to writing a blog post that describes the
different architectures we've gone through, and the pros and cons of
each. All of these architectures scale fairly well, but there have
been some surprising results. These architectures have included using
the system threadpool, managing our own thread pool, doing work on
the IOCP threads, and a few other things thrown in for good luck.

I've seen so many people asking for guidance in this area, and I hope
this serves people as a good starting point.

http://makeashorterlink.com/?R2EE5246D

All feedback is welcome, either here or on the blog...
Thanks for sharing - great article!

-cd
Jul 13 '06 #2
"Carl Daniel [VC++ MVP]" wrote
> [Writing a Scalable Socket Server]
http://makeashorterlink.com/?R2EE5246D
Thanks for sharing - great article!
Any suggestions for how to improve things? The great thing about UseNet is
the wealth of knowledge out here, people wise. Getting hold of that
knowledge can be tough, but please, if you have suggestions fire away!

--
Chris Mullins
http://www.coversant.net/blogs/cmullins
Jul 13 '06 #3
"Chris Mullins" <cm******@yahoo.comwrote in message
news:Og**************@TK2MSFTNGP03.phx.gbl...
"Carl Daniel [VC++ MVP]" wrote
>> [Writing a Scalable Socket Server]
http://makeashorterlink.com/?R2EE5246D
>Thanks for sharing - great article!

Any suggestions for how to improve things? The great thing about UseNet is
the wealth of knowledge out here, people wise. Getting hold of that
knowledge can be tough, but please, if you have suggestions fire away!
I think you're to the (really) hard part now - do as SQL Server does (as
discussed in a previous thread). You need to keep your threads from being
blocked and avoid context switches like the plague. Unfortunately, ADO.NET
doesn't help you out a lot there. It'd be interesting to see (as you've
already commented) how much more you'd get out at the high end just by using
lockfree queues on high-end systems while sticking with the locking queue on
low(er) end systems.

-cd
Jul 13 '06 #4
"Carl Daniel [VC++ MVP]" wrote:
It'd be interesting to see (as you've already commented) how much more
you'd get out at the high end just by using lockfree queues on high-end
systems while sticking with the locking queue on low(er) end systems.
My next topic will probably be just that. I wrote a mean little program that
is contention bound, and uses all the different types of locks. I ran this
on single x86, dualx86, single x64, dual x64, dual x64 with hyperthreading,
dual itanium2, quad itanium2, and 16 processor itanium2.

The resulting graphs are.... interesting.

Now I just need to find time to write that up...

--
Chris Mullins
http://www.coversant.net/blogs/cmullins
Jul 13 '06 #5
Chris Mullins <cm******@yahoo.comwrote:
"Carl Daniel [VC++ MVP]" wrote:
It'd be interesting to see (as you've already commented) how much more
you'd get out at the high end just by using lockfree queues on high-end
systems while sticking with the locking queue on low(er) end systems.

My next topic will probably be just that. I wrote a mean little program that
is contention bound, and uses all the different types of locks. I ran this
on single x86, dualx86, single x64, dual x64, dual x64 with hyperthreading,
dual itanium2, quad itanium2, and 16 processor itanium2.

The resulting graphs are.... interesting.

Now I just need to find time to write that up...
If you have the time to run the tests with my "feature-rich" locks, I'd
be really interested in seeing the results. See
http://www.pobox.com/~skeet/csharp/m...e/locking.html for
usage, download link etc.

It sounds like they wouldn't be appropriate for your situation, but it
would be good to get more diverse stats on the penalty for using my
code over the "plain" locking.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 13 '06 #6
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote
>
If you have the time to run the tests with my "feature-rich" locks, I'd
be really interested in seeing the results. See
http://www.pobox.com/~skeet/csharp/m...e/locking.html for
usage, download link etc.
I recently (just this week) took a long and deep look through Jeff Richters
"Power Threading" library. It's online at:
http://www.wintellect.com/Resources.aspx
(signing up for an account is free, then you can download the source).

As somebody who takes quite a bit of pride in my knowledge of multi-threaded
code, I have to say I was humbled.

I learned more about locking in 4 hours this past tuesday evening than I've
leared in a long, long time - possibly ever. Some of his source code
commends were... eye opening.
// NOTE: Just reading here (as compared to repeatedly calling Exchange)
// improves performance because writing forces all CPUs to update this value

// Don't do variable = value because reordered by compiler and/or CPU

There was stuff like this throughout - as well as stuff that I wish I could
wrap my head arond.

I quite liked his abstract ResourceLock implementation, and the concrete
variations on it.

Unfortunatly I can't use this library, as the licensing of it prevents it
from being run with Mono. I'll have to send him an email and see if I can
get a relaxed license version.

--
Chris Mullins
Jul 13 '06 #7
Chris Mullins wrote:
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote
>>
If you have the time to run the tests with my "feature-rich" locks,
I'd be really interested in seeing the results. See
http://www.pobox.com/~skeet/csharp/m...e/locking.html for
usage, download link etc.

I recently (just this week) took a long and deep look through Jeff
Richters "Power Threading" library. It's online at:
http://www.wintellect.com/Resources.aspx
(signing up for an account is free, then you can download the source).

As somebody who takes quite a bit of pride in my knowledge of
multi-threaded code, I have to say I was humbled.

I learned more about locking in 4 hours this past tuesday evening
than I've leared in a long, long time - possibly ever. Some of his
source code commends were... eye opening.
// NOTE: Just reading here (as compared to repeatedly calling
Exchange) // improves performance because writing forces all CPUs to
update this value
// Don't do variable = value because reordered by compiler and/or CPU

There was stuff like this throughout - as well as stuff that I wish I
could wrap my head arond.

I quite liked his abstract ResourceLock implementation, and the
concrete variations on it.

Unfortunatly I can't use this library, as the licensing of it
prevents it from being run with Mono. I'll have to send him an email
and see if I can get a relaxed license version.
Cool library - definitely some good stuff in there. Kinda short on
documentation though :) Makes for more interesting reading that way, I
guess.

-cd
Jul 14 '06 #8
"Chris Mullins" <cm******@yahoo.comwrote:
I recently (just this week) took a long and deep look through Jeff Richters
"Power Threading" library. It's online at:
http://www.wintellect.com/Resources.aspx
(signing up for an account is free, then you can download the source).

As somebody who takes quite a bit of pride in my knowledge of multi-threaded
code, I have to say I was humbled.
Yes, memory models are mind-bending - especially when you bring compiler
optimizations into mind as well. Are we really certain that the JIT
compiler respects Thread.MemoryBarrier(), or does it just affect the
CPU? :) It's certainly enough to scare you away from playing with
sophisticated lock-free programming unless you've got a lot of time and
hardware to play with to prove and test correctness.

-- Barry

--
http://barrkel.blogspot.com/
Jul 14 '06 #9

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

Similar topics

6
1456
by: Sridhar R | last post by:
I am looking for a class browser that has these features. 1. Given a symbol (class, method or function) it should giveback the lineno n source code 2. It should be efficient and quick. I...
0
1912
by: MS Guru | last post by:
Hi, The following simple ASP scripts works fine when the attached file is less than 100K. It fails (no errors or warnings returned) by inserting an empty attachment when the file is greater than...
0
687
by: mailing | last post by:
hi, it's possible in mysql set the db folder into home user? example: user fred, home is /home/fred i want store db data in /home/fred/db. it's possible? i've tested in /home/fred/.my.cnf...
1
2406
by: .:: - Hades - ::. | last post by:
Hi, 1. I am trying to find out something close to the Overlapped IO / Completion Ports model provided to me by the Winsock 2 library in C#. The two ways provided to me to move towarsds...
2
3767
by: lewi | last post by:
I started an unmanaged VC++ dlg app that I want to play arround with socket for Peer to Peer app on my local LAN and I got it connected up the the app is the same on both computer and creates a...
4
9126
by: SRLoka | last post by:
After reading the newsgroups and various .Net web sites, I have come to a conclusion that BeginReceive and BeginSend are the way to go as they use IOCompletion Ports(I have no clue what they mean...
0
367
by: Jonas Hei | last post by:
I need to develop a scalable server which has to receive and send UDP messages. It is required to process hundreds of messages (coming from different remote computers) per second (possibly even...
3
1440
by: Terry Holland | last post by:
Ive read that to build scalable web apps it is not recommended that state be stored in session variables. My understanding of this is that, with many users using the application concurrently,...
0
950
by: boazin | last post by:
Hi all, I was trying to build a rather simple server (with a twist) using asyncore and got myself complicated. Well, here's the deal: My server will handle multiple connections, some require...
0
7233
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
7135
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
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
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...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
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
3215
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
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.