473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

service soemtime will get slower -- what to watch

Hi,

I use C# wrote an Client/Server application. In production environment, will
be 130 clients (Windows XP) connect to a Server (Windows 2000/2003 Server)
thought TCP/IP socket in a local 100M LAN. "Server" is running as a Windows
service. The is one thread running for one clinet in the server.

Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

Usually what will be the cause? Managed code won't have memory leaking,
right? And how efficient is the garbage collection in .NET? Should I force
garbage collection once a while in my code?

And if I want to use the performance counter to check the problem, what
usually are the objects/parameters I should look at? How many threads are
running for my service? Memory used by the service or each server thread in
my service? Thread idle time ..? I just see too many things in the
performance counter.

And if I write code to sample those performance parameters, will it make the
service runs even slower?

Thanks!

Ryan

Dec 27 '07 #1
9 1611
"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running as
a Windows service. The is one thread running for one clinet in the server.
Keep in mind that doing so, you are wasting a lot of memory resources for
the thread's stack (1MB per thread).Better is to apply an asynchronous
design pattern.

Sometime the user tells me the Sever will be slow after it runs for 1-2
days.
Probably caused by a memory 'leak', which causes higher memory pressure and
resulting in paging after a long period of time.
Usually what will be the cause? Managed code won't have memory leaking,
Managed code can have 'leaks' but that's the result of a 'bug' in your code
or a design flaw, but (usable) memory can also get scarce because of
fragmentation of the GC heap, especially on V1.1 (better move to V2) in
combination with socket based communications using large buffers (taken from
the Large Object Heap).

right? And how efficient is the garbage collection in .NET? Should I force
garbage collection once a while in my code?
No, forcing a GC won't help, what you have to do is measure first...before
you can take some corrective actions.
And if I want to use the performance counter to check the problem, what
usually are the objects/parameters I should look at? How many threads are
running for my service? Memory used by the service or each server thread
in my service? Thread idle time ..? I just see too many things in the
performance counter.
Use Perfmon to check the CLR preformance counters, especially you should
keep an eye on the GC memory counters like the LOH size and the Gen2 size
and the process (your service) Memory counters like the "Private Bytes" and
"Virtual Bytes" should stay stable (within some bounds) after a while.
And if I write code to sample those performance parameters, will it make
the service runs even slower?
There is no need to write something yourself, Perfmon was invented for this.

Willy.
Dec 27 '07 #2
Ryan,

Well, if you do some sort of monitoring, it will make your server
slower. By how much is impossible to say, depending on the method you use
to monitor the performance of your server. The simple act of monitoring
anything will have the effect of changing what you are monitoring.

I would say that forcing a GC is a bad idea, since it will typically do
a good job of that for you. There are exceptions to this though, but they
are rare. In a server environment, or any environment where you have a
consistent, almost predictable use, it's definitely a bad idea.

As for not having memory leaks, you are right, managed code doesn't have
memory leaks, but that doesn't mean you don't have to pay attention to what
you are using. Anything that implements IDisposable definitely needs
special attention, as you need to make sure you call Dispose (or you should,
at least) on those instances when you are done, as the IDisposable interface
indicates that the instance in question is holding onto something which
should be disposed of when done (as opposed to waiting around for it to be
disposed of, like file handles, sockets, database connections, etc, etc).

Of course, the most important thing to do is really look at what your
server is doing. I know that sounds broad, but you didn't indicate anything
about what your server does, so it's impossible for anyone to comment on
what might be making it slow. Are you executing a massive stored procedure
which processes five billion rows for each of your 100 clients? Are you
writing out 20GB of files for each client at the same time? There are many
things that could indicate performance problems, but you can't even begin to
diagnose them unless you know what the app is doing (or supposed to do) in
the first place.

That being said, can you shed some more light on what your app does?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running as
a Windows service. The is one thread running for one clinet in the server.

Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

Usually what will be the cause? Managed code won't have memory leaking,
right? And how efficient is the garbage collection in .NET? Should I force
garbage collection once a while in my code?

And if I want to use the performance counter to check the problem, what
usually are the objects/parameters I should look at? How many threads are
running for my service? Memory used by the service or each server thread
in my service? Thread idle time ..? I just see too many things in the
performance counter.

And if I write code to sample those performance parameters, will it make
the service runs even slower?

Thanks!

Ryan

Dec 27 '07 #3
Nicholas,

Thanks a lot for your help.

Things server does mainly including:

1: Passing very short string messages from one client to another, most
time
it does not parse it, just route it;

2: sync some client operation -- only one client can get an item from
database to work on it; And quota control -- only limited number of one type
of items can be taken out from db for all clients.

3: Client write result directly to the database, but notify server the item
is done.

4: Call database stored procedures that might updates lots of db records
(but just 1-2 time a day ); Parse some XML files (< 1M) once a while.

5: Write log files, one file per day for all clients. Most time I only
write log when there are things go wrong.

The database is running on the same machine as the server.

Thanks again!
Ryan
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omдÈëÏûÏ¢
news:e9******** ******@TK2MSFTN GP05.phx.gbl...
Ryan,

Well, if you do some sort of monitoring, it will make your server
slower. By how much is impossible to say, depending on the method you use
to monitor the performance of your server. The simple act of monitoring
anything will have the effect of changing what you are monitoring.

I would say that forcing a GC is a bad idea, since it will typically do
a good job of that for you. There are exceptions to this though, but they
are rare. In a server environment, or any environment where you have a
consistent, almost predictable use, it's definitely a bad idea.

As for not having memory leaks, you are right, managed code doesn't
have memory leaks, but that doesn't mean you don't have to pay attention
to what you are using. Anything that implements IDisposable definitely
needs special attention, as you need to make sure you call Dispose (or you
should, at least) on those instances when you are done, as the IDisposable
interface indicates that the instance in question is holding onto
something which should be disposed of when done (as opposed to waiting
around for it to be disposed of, like file handles, sockets, database
connections, etc, etc).

Of course, the most important thing to do is really look at what your
server is doing. I know that sounds broad, but you didn't indicate
anything about what your server does, so it's impossible for anyone to
comment on what might be making it slow. Are you executing a massive
stored procedure which processes five billion rows for each of your 100
clients? Are you writing out 20GB of files for each client at the same
time? There are many things that could indicate performance problems, but
you can't even begin to diagnose them unless you know what the app is
doing (or supposed to do) in the first place.

That being said, can you shed some more light on what your app does?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******** ******@TK2MSFTN GP03.phx.gbl...
>Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running as
a Windows service. The is one thread running for one clinet in the
server.

Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

Usually what will be the cause? Managed code won't have memory leaking,
right? And how efficient is the garbage collection in .NET? Should I
force garbage collection once a while in my code?

And if I want to use the performance counter to check the problem, what
usually are the objects/parameters I should look at? How many threads are
running for my service? Memory used by the service or each server thread
in my service? Thread idle time ..? I just see too many things in the
performance counter.

And if I write code to sample those performance parameters, will it make
the service runs even slower?

Thanks!

Ryan

Dec 27 '07 #4
Hi,

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running as
a Windows service. The is one thread running for one clinet in the server.
How you know how many clients are running at a given time?
Do you close your connections after you transfer data?
Sometime the user tells me the Sever will be slow after it runs for 1-2
days.
It sound like you are not closing the connections. Do a netstat -an and see
how many open connections you have.
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Dec 27 '07 #5

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comдÈëÏûÏ¢
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi,

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******** ******@TK2MSFTN GP03.phx.gbl...
>Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running as
a Windows service. The is one thread running for one clinet in the
server.

How you know how many clients are running at a given time?
Do you close your connections after you transfer data?
>Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

It sound like you are not closing the connections. Do a netstat -an and
see how many open connections you have.

The connectoins will be closed probably at the end of day, when all the
operators go home. Otherwise, yes, they remain open since operators are
continously work on it. I am using a statefull connection.

Thanks,

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Dec 28 '07 #6
Hi,

How many open connections there are?
I bet that after a couple of days you have a BIG number of connections open
and that is the problem you are seeing.

Can you use a poll method instead? The client connect to the server in
regular intervals and send/receive messages?
What about using UDP?
IIRC all the IM systems use UDP for this same reason

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oz******** ******@TK2MSFTN GP05.phx.gbl...
>
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comдÈëÏûÏ¢
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
>Hi,

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running
as a Windows service. The is one thread running for one clinet in the
server.

How you know how many clients are running at a given time?
Do you close your connections after you transfer data?
>>Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

It sound like you are not closing the connections. Do a netstat -an and
see how many open connections you have.


The connectoins will be closed probably at the end of day, when all the
operators go home. Otherwise, yes, they remain open since operators are
continously work on it. I am using a statefull connection.

Thanks,

>--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

Dec 28 '07 #7


"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comдÈëÏûÏ¢
news:uH******** ******@TK2MSFTN GP04.phx.gbl...
Hi,

How many open connections there are?
I bet that after a couple of days you have a BIG number of connections
open and that is the problem you are seeing.

Can you use a poll method instead? The client connect to the server in
regular intervals and send/receive messages?
What about using UDP?
IIRC all the IM systems use UDP for this same reason

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

Machin,

Not just client initiative the conversation, sometime the srever will
actively send data to client,and then client response as well.

And the conversation between client and server has to be "real time". I am
afraid poll mechanism is not handling it quick enough.

And I heard UDP is not as reliable as TCP. Maybe LAN enviorment is not a
problem. Also I use "statefull connectoin" to make my programming easy.

All clients will disconnect from the server at the end of day.

Thanks,
Ryan
"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oz******** ******@TK2MSFTN GP05.phx.gbl...
>>
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comдÈëÏûÏ¢
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
>>Hi,

"Ryan Liu" <rl**@PowerCATI .comwrote in message
news:Oo****** ********@TK2MSF TNGP03.phx.gbl. ..
Hi,

I use C# wrote an Client/Server application. In production environment,
will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003
Server) thought TCP/IP socket in a local 100M LAN. "Server" is running
as a Windows service. The is one thread running for one clinet in the
server.

How you know how many clients are running at a given time?
Do you close your connections after you transfer data?

Sometime the user tells me the Sever will be slow after it runs for 1-2
days.

It sound like you are not closing the connections. Do a netstat -an and
see how many open connections you have.


The connectoins will be closed probably at the end of day, when all the
operators go home. Otherwise, yes, they remain open since operators are
continously work on it. I am using a statefull connection.

Thanks,

>>--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

Dec 30 '07 #8
Hi,

And I heard UDP is not as reliable as TCP. Maybe LAN enviorment is not a
problem. Also I use "statefull connectoin" to make my programming easy.
You could use UDP to send a "ping" to the other party and then a TCP
connection is established and closed when the data is sent.
All clients will disconnect from the server at the end of day.
Are you sure of that?
More importantly, are you sure that teh server close all the connections?
Most probably you are handling each connection in a separated thread, are
all those threads being recicled and the instances of objects they use
returned?
How big is the memory consuption of the server?
Thanks,
Ryan
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Dec 31 '07 #9

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comдÈëÏûÏ¢
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Hi,

>And I heard UDP is not as reliable as TCP. Maybe LAN enviorment is not a
problem. Also I use "statefull connectoin" to make my programming easy.

You could use UDP to send a "ping" to the other party and then a TCP
connection is established and closed when the data is sent.
Thanks fot the suggestion.
>All clients will disconnect from the server at the end of day.

Are you sure of that?
Yes, it is the rule of my client company.
More importantly, are you sure that teh server close all the connections?
Most probably you are handling each connection in a separated thread, are
all those threads being recicled and the instances of objects they use
returned?
How big is the memory consuption of the server?
I don't know extractly, but seems it is not a lot. The server is 800 miles
away from me and most time it OK. I will try to log it when it happens next
time.

Thanks,
Ryan
>
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Dec 31 '07 #10

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

Similar topics

11
2259
by: Michael Riggio | last post by:
Is there a way to have a windows service instantiate a class that is a web service, which will then be accessible to clients via HTTP? Thanks, -Mike
5
5024
by: Belsam | last post by:
Hi all I need to create a windows service that will wait for a file to be copied somewhere, write it to the database, and then move the file to a storage area. I don't know when the file will come in, so I think I need a service vs using task scheduler. Am I correct? If yes, can someone help with how to do this? So far
1
10054
by: Troy Murphy | last post by:
I seem to remember using a walkthru in the early beta that demonstrated how to create a Windows Service that would monitor events in a folder. Can someone please direct me to an example of doing this? Thanks, Troy
7
712
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: service 1 - my service watches service 2 - windows service service 2 is stopped - service 1 starts service 2
2
6120
by: Genojoe | last post by:
I have a Windows Service (VB.NET) that runs 24/7. It contacts a Web Service (VB.NET on IIS). As long as we send requests to the Web Service at least once every 15 minutes, everything works fine. We send the request asynchronously and wait for the response. When there is a 30 minute or greater gap between requests, we get the following error message in the Windows service return thread: Error #: 5, Description: The underlying...
3
2096
by: Brecht Yperman | last post by:
Hi, I am running a .NET application as a Windows Service. In that application I create a FileSystemWatcher. I want it to watch a network drive which maps to an IBM iSeries IFS directory. Every time I log in, I have to retype the password to connect to that network drive, so it isn't stored and thus the service cannot connect to the network drive.
4
2901
by: Jianwei Sun | last post by:
Hi, all, I have a question, and I hope to get some hints here.. I created a really simple service just to check why the service manager doesn't start my service the second time if the first time failed.. I created an atl service through the wizard, and the only thing I do is override the PreMessageLoop()...
12
1848
by: jimocz | last post by:
Did I do something wrong? I cross posted this on the dotnet development group -- sorry if it is a double posting but we are seriously considering going to c# and this could be a show stopper. I ran the following C# program and it ran in 9 seconds (give or take 1 sec) using System; using System.Collections.Generic; using System.Text;
33
11841
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM). I understand that when the service starts, no user may be logged in, but that's ok, as the app I am monitoring can only be run by a logged in user. Do I need to use WMI to get the user context of Explorer.exe or is there a...
0
8399
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8504
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8606
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7337
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4159
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1622
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.