473,503 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Socket application getting unstable with many connected users

2 New Member
Helloes,

I'm experiencing a nasty problem in a server-client application. Don't have the perfect solution yet, but I have ideas. Seeking opinions/ideas to find the perfect solution.

The application is a card/board gaming platform with many other functions for chat, management and such.
Client is healthy and works as an user interface to communicate with server and other clients. Typical client, nothing special.



As you can see on the chart server is divided into parts. Listeners are actually infinite loops awaiting connection requests. You can pick the channel you want to connect and login.

Channels have a maximum limit of 100 clients, it's the place where all chatting and gaming happens. Clients can roll new rooms and get to gaming part. They can publicly chat with everyone in the channel, they can perform management functions (kick, ban, etc) if they are authorized. Each channel is another independant executable, they can't reach other directly. However for some particular occasions they can reach each other indirectly via socket.

Each channel has a "Client" object to define users and a "ClientCollection" to hold all of them. Since each client object works under their own thread, I use SyncLock on the collection to avoid inconsistence.

The main problem is;
when the channel reaches certain numbers of online users (limit's 100, but it starts with 75-80 clients), things start to get interestingly unstable. For instance, when you type a single sentence on chatbox, it can be distributed to other 80 people after one minute (instead of instantly). I monitor the server's CPU usage, surely it increases, but nothing unusual. Normally, a single channel application uses a minumum of 0% - 4%. When we have 75-80 users, it goes up to 5%-10% which looks acceptable. It feels like a temporary lag, whatever is causing it can lag everything for a couple of minutes (it even disconnect users), then it goes back to normal. Somehow it gets frozen and out of breathe, it coughs, catches its breathe and goes on running. Even sometimes, we are forced to restart individual channels.

When we have less online, everything goes smoothly.

At this point, since channel runs unstable only when it is crowded, I tried to observe the differences between a crowded environment and an underpopulated environment. I logged incoming and outgoing data to reduce and eliminate the most repetitive one in order to reduce traffic, hoping for some performance increase.

In my theory, this unstability occurs more often when an action effects the whole channel, just like chatting. Whenever you type something, if there are 80 clients inside, this has to be sent to 79 other clients (each task is done by a single thread, not a thread per client). And this is my main suspect. It's a lot of distributation work for the server, when 10-15 users are chatting at the same time in public. Currently, I'm distributing all these messages to the users by a single thread per task (new user connected, someone typed something, someone left the channel). Maybe using another way like TaskFactory could solve this issue. I wonder if it makes sense to gather the data required and deal with the distributation using TaskFactory. Would it solve my problem, what do you think?

http://bytes.com/topic/net/answers/909195-net-client-server-application-gets-frozen-need-ideas-fix

We addressed a similar issue before when we first started on this project. It was advised us to set socket's NoDelay property to true. Maybe it is possible to get over with this by a single smart trick.
Feb 16 '12 #1
1 2075
apesyradepoge
1 New Member
Hmmm... interesting.
Mar 1 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1597
by: Giuseppe | last post by:
Hello.. I hope someone could help me here... I've installed a phpbb forum and the mod char pjirc. I'm using IRC server irc.blitzed.org and a custom channel. Is it possibile to read via php o js...
1
1957
by: scott289 | last post by:
Getting the lists of users in a given Domain Group? For example, our Network people have created a group called MyAppUsers, and have added certain Users to this group. I need to get a list of...
7
5471
by: Jeff Pritchard | last post by:
I need to get a count only of the number of users currently connected to a back-end mdb when a front-end is opened. This is for 2000 onwards. Preferably without requiring any special references...
3
6643
by: Shane Suebsahakarn | last post by:
I have a rather odd problem that I'm at a loss to explain. The mdb is in A2K2 format, and has many tables linked to around 3-4 different back end mdbs. It is running on a Win2K3 server (set up as...
3
2135
by: u473 | last post by:
.... Or, How do you identify connected users ? Help appreciated. Celeste Edwards,
4
1374
by: Mindy Myers | last post by:
I have been working on a web application for a while. All of a sudden, I can only open the project when connected to the Internet. If I'm not connected, I get an error message stating that "a...
1
1477
by: Justin Creasy | last post by:
Hello, I am trying to add the ability to save my applications settings for each user. I was just wondering what the best method is to do this. The only requirement is that any user account (user,...
9
1972
by: David | last post by:
With a non-server app there is one instance of the program running and one user 'using' it at a time. With this scenario I'm pretty comfortable with variable scope and lifetime. With a server app...
1
1693
by: meenus | last post by:
dears, i downloaded one socket application fro recvng the data from different units(vehicle tracking system) .my pblm is sometimes some of the data is not getting in to the server socket which is...
0
7204
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
7282
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
7342
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
7464
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
5586
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
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
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...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.