I am currently developing a statistics system in ASP.NET, and need to share
information about the customers websites, in this application.
(I have simplified my code, to make my project easier to explain.)
The simple version of the system is like this : A customer inserts HTML code
on his webpage, which contacts my statistics server each time the customers
website recieves a hit - like a classic "register website traffic" system.
When the customers hit reaches my web application, I need to maintain info
and state about the customers website - therefore I have a "website" class,
which hold information about the customer website (raw hits, unique hits,
website name, hit today ect).
So the first time a customer hits my servers, I need to instantiate an
instance of the website class, and update the information in this class. Next
time I recieve a request for the same customer, I only need to update the
websites information in the instance of that class.
So, here is a picture of how it works today, when the first hit comes in :
1. Customer #100 sends a request to my statistics application.
2. I have no information about customer #100, so I instantiate a new
instance of the "website" class.
3. I update information, and sets the "unique hits" variable to 1 (as this
is the first hit).
After this, all hits coming after the first hit, only updates information in
the "website" class (ie. adds 1 to the "unique hits" variabel) - like in step
3.
I think (and hope) all the above is readable and understandable.
My problem now, is how I share these website classes in the global
application ????
Today I have a shared collection, which hold each instance of the website
class - like this :
public shared websites as new sortedlist
This shared collection can be accessed from all classes in my application,
and actually this works fine.
But, when my collection of websites reaches a certain limit (about 2500
"website" classes), the application starts to become VERY slow, and after
10-15 minutes it totally slows down and becomes useless.
And listen to me - we are talking VERY SLOW here - it runs on dual xeon HP
server, so hardware is enough for testcase ...
My question is now, if I am doing this the right way ??? How are you guys
shared objects among pages in an ASP.NET application ???
Is there are correct way to share objects globally in an ASP.NET application ?
-
Regards,
Tony Fonager, Denmark 8 4547
Sorry about the identical post - my mistake!
"Tony Fonager" <fo*****@newsgr oups.nospam> wrote in message
news:14******** *************** ***********@mic rosoft.com... I am currently developing a statistics system in ASP.NET, and need to
share information about the customers websites, in this application.
(I have simplified my code, to make my project easier to explain.)
....
Tony, a few thoughts:
1. If you use a shared variable, you'll get a new instance of that
sortedlist each time IIS spins up a new instance of your app (which it may or
may not decide to do).
2. Tough to tell based on this where your bottleneck is. You might set some
start time/end time breakpoints to see what starts taking so long (e.g.
maintaining the sortedlist, excessive garbage collection due to poor string
handling, etc.). The memory required to store 2500 instances of that class
and the cpu time required to find items in it shouldn't be that
oppressive--I'm guessing the problem is somewhere else (unless you're
supporting a ton of hits/second or are otherwise way underpowered).
3. Regardless, your design isn't built to scale well, because you keep
hanging onto all the web site info. You need a way to flush it periodically
and start over.
4. Why hold onto all the web site information in memory? Why not just write
each "hit" to disk? I presume at some point you have to do that anyway so you
can package it up for your customers. Yes, slightly slower to insert a row
each time, but you'll avoid a whole host of other problems and scalability
should go way up (at least it will be more linear). You could also save up
your writes in cache and persist them when traffic is light, maybe persist
each customers info in a tiny xml file for the day. etc.
5. One way to create a global repository across all instances of your app is
to write a separate web service.
hth,
Bill
"Tony Fonager" wrote: I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application.
(I have simplified my code, to make my project easier to explain.)
The simple version of the system is like this : A customer inserts HTML code on his webpage, which contacts my statistics server each time the customers website recieves a hit - like a classic "register website traffic" system.
When the customers hit reaches my web application, I need to maintain info and state about the customers website - therefore I have a "website" class, which hold information about the customer website (raw hits, unique hits, website name, hit today ect).
So the first time a customer hits my servers, I need to instantiate an instance of the website class, and update the information in this class. Next time I recieve a request for the same customer, I only need to update the websites information in the instance of that class.
So, here is a picture of how it works today, when the first hit comes in :
1. Customer #100 sends a request to my statistics application. 2. I have no information about customer #100, so I instantiate a new instance of the "website" class. 3. I update information, and sets the "unique hits" variable to 1 (as this is the first hit).
After this, all hits coming after the first hit, only updates information in the "website" class (ie. adds 1 to the "unique hits" variabel) - like in step 3.
I think (and hope) all the above is readable and understandable.
My problem now, is how I share these website classes in the global application ????
Today I have a shared collection, which hold each instance of the website class - like this :
public shared websites as new sortedlist
This shared collection can be accessed from all classes in my application, and actually this works fine.
But, when my collection of websites reaches a certain limit (about 2500 "website" classes), the application starts to become VERY slow, and after 10-15 minutes it totally slows down and becomes useless.
And listen to me - we are talking VERY SLOW here - it runs on dual xeon HP server, so hardware is enough for testcase ...
My question is now, if I am doing this the right way ??? How are you guys shared objects among pages in an ASP.NET application ???
Is there are correct way to share objects globally in an ASP.NET application ?
- Regards, Tony Fonager, Denmark
Bill,
It is not a memory problem (I guess), as my app uses 60 mb, when it totally
slows down ...
I want to update information about each customers website, exactly to leave
out these (slow) SQL updates - thats why I want to store everything in
memory - I then have a seperate thread, that in the background writes back
the information from memory, into a SQL database. So I DO flush data
regularly :-)
I dont understand your comment #1 - what do you mean by that ? IIS should
only have one instance of my app or ?
-
Regards,
Tony Fonager
"Bill Borg" <Bi******@discu ssions.microsof t.com> wrote in message
news:9C******** *************** ***********@mic rosoft.com... Tony, a few thoughts:
1. If you use a shared variable, you'll get a new instance of that sortedlist each time IIS spins up a new instance of your app (which it may
or may not decide to do).
2. Tough to tell based on this where your bottleneck is. You might set
some start time/end time breakpoints to see what starts taking so long (e.g. maintaining the sortedlist, excessive garbage collection due to poor
string handling, etc.). The memory required to store 2500 instances of that class and the cpu time required to find items in it shouldn't be that oppressive--I'm guessing the problem is somewhere else (unless you're supporting a ton of hits/second or are otherwise way underpowered).
3. Regardless, your design isn't built to scale well, because you keep hanging onto all the web site info. You need a way to flush it
periodically and start over.
4. Why hold onto all the web site information in memory? Why not just
write each "hit" to disk? I presume at some point you have to do that anyway so
you can package it up for your customers. Yes, slightly slower to insert a row each time, but you'll avoid a whole host of other problems and scalability should go way up (at least it will be more linear). You could also save up your writes in cache and persist them when traffic is light, maybe persist each customers info in a tiny xml file for the day. etc.
5. One way to create a global repository across all instances of your app
is to write a separate web service.
hth,
Bill
"Tony Fonager" wrote:
I am currently developing a statistics system in ASP.NET, and need to
share information about the customers websites, in this application.
(I have simplified my code, to make my project easier to explain.)
The simple version of the system is like this : A customer inserts HTML
code on his webpage, which contacts my statistics server each time the
customers website recieves a hit - like a classic "register website traffic"
system. When the customers hit reaches my web application, I need to maintain
info and state about the customers website - therefore I have a "website"
class, which hold information about the customer website (raw hits, unique
hits, website name, hit today ect).
So the first time a customer hits my servers, I need to instantiate an instance of the website class, and update the information in this class.
Next time I recieve a request for the same customer, I only need to update
the websites information in the instance of that class.
So, here is a picture of how it works today, when the first hit comes
in : 1. Customer #100 sends a request to my statistics application. 2. I have no information about customer #100, so I instantiate a new instance of the "website" class. 3. I update information, and sets the "unique hits" variable to 1 (as
this is the first hit).
After this, all hits coming after the first hit, only updates
information in the "website" class (ie. adds 1 to the "unique hits" variabel) - like in
step 3.
I think (and hope) all the above is readable and understandable.
My problem now, is how I share these website classes in the global application ????
Today I have a shared collection, which hold each instance of the
website class - like this :
public shared websites as new sortedlist
This shared collection can be accessed from all classes in my
application, and actually this works fine.
But, when my collection of websites reaches a certain limit (about 2500 "website" classes), the application starts to become VERY slow, and
after 10-15 minutes it totally slows down and becomes useless.
And listen to me - we are talking VERY SLOW here - it runs on dual xeon
HP server, so hardware is enough for testcase ...
My question is now, if I am doing this the right way ??? How are you
guys shared objects among pages in an ASP.NET application ???
Is there are correct way to share objects globally in an ASP.NET
application ?
- Regards, Tony Fonager, Denmark
Hi Tony,
As for the Bill's comment #1, I think he means the asp.net web
application(hos t in its own appdomain) may restart sometimes(for example ,
after some period of idle or configure file/ assembliy changed), and all
the
application scope data(include the static class members will also be
unavailable) after that, new ones will be initialized.
Also, In addition to Static class members, we can also use the
ApplicationStat e or Application Cache to store application level objects.
However, since the asp.net are request/response based and each request
execute in its own workerthread, we need to do concurrency protect on such
global datas. For example, when accessing the ApplicationStat e, we may use
the following statement to protect race condition:
Application.Loc k();
Application["SomeGlobalCoun ter"] =
(int)Applicatio n["SomeGlobalCoun ter"] + 1;
Application.UnL ock();
here is the reference on ASP.NET applicationStat e
#Application State http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconapplicatio nstate.asp
ASP.NET cache is mainly focus on provide cacheing some large and not
frequently changed data, so seems not very useful for your scenario.
In addition, what's the server's OS version? And is the memory useage you
mentioned the asp.net process's memory usage? If the memory is not the
problem, I suspect whether there are any concurency or deadlock problem
since the static variables is accessable throughout the whole application.
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
Thanks for your answer ...
I am afraid that my load of static classes is becoming to much for ASP.NET,
even though I am not glad to accept this idea :-)
I have profiled my entire application, and even though I request a page,
which takes maybe 30 seconds to return, the code I have in that particular
page, takes miliseconds to execute, according to the profiler - what happens
for the rest of the 30 seconds, must be inside the ASP.NET framework, which
I cannot profile.
But I am sad to see this - my application is a rewrite of a running JSP
(java) system, and the exact same principles are taken from the java app to
the asp.net app - in java it is running on a single CPU server, and my tests
are running on dual xeon 3 mhz HP server, with tons of memory ... and it
cannot even take 1/5 th of the load as the java version.
I must be doing something totally wrong ....
-
Regards,
Tony
Hi Tony,
Thanks for your response. Based on your further description, it seems that
there are something being blocked when your page's code executed, since it
'll take about 30 seconds more to return the response.
Since you mentioned that there is a background thread which will regularly
write the inmemory datas into database. Will the accessing to the static
objects in the background thread cause the page's request/response be
blocked? I think you can try stopping the background to see whether the
things will be different.
Also, if you feel it possible , you can also try using the ApplicationStat e
instead of the static class member to store the inmemory datas to see
whether it helps.
In addition, here is a list that shows some asp.net process model related
settings for both IIS5 and IIS6, there're some entries related to the
processs's memory / deadlock time limiation, you can also try adjusting
them to see whether helps.
#Mapping ASP.NET Process Model Settings to IIS 6.0 Application Pool Settings http://msdn.microsoft.com/library/en...etprocessmodel
settingequivale ncetoapplicatio npoolsettings.a sp?frame=true
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
Problem IS solved - how am I going to tell you this - it is embarrassing ;-)
(It was NOT my background thread - it has been disabled all thru the entire
test, so ...)
Here it comes : The slowdown was caused by ENORMOUS viewstate data in the
local browser - actually, when I clicked around in my manager interface
(aspx page), it started slowing down after I had visited a particular page,
with lots and lots of information ...
Information which got posted into the viewstate, as it was bound to a
servercontrol (label) - so what actually happend, was that suddently all my
pages was "carrying aound" a 5-6 MB viewstate, which totally made the
manager interface "non responsive", ..
Arrggggh, I feel like such a beginner :-(
Anyway, on the other side I now know that I can trust .NET again - and the
speed of .NET, as my application is running on lightspeed today, with over
5000 customers in the system - wuhuuu!
Thanks to everybody for their kind help!!!
-
Regards,
Tony
Hi Tony,
Thanks for your followup. Glad that you've figured out the problem(
especially that you've trust .NET again -:)). Anyway, since the ASP.NET
provide so many new rich features, we may also be careful when using them.
If you meet any other problems on ASP.NET later, please always feel free to
post here.
Thanks again for choosing Microsoft :)
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kyle.tk |
last post by:
So I have a central list of python objects that I want to be able to
share between different process that are possibly on different
computers on the network. Some of the processes will add objects to
list and another process will be a GUI that will view objects in the
list. I want this all to happen in real-time (e.g once a processes adds
an object to the list the GUI will see it.)
What would be the best way to accomplish this. Some of...
|
by: rkusenet |
last post by:
http://biz.yahoo.com/rc/040526/tech_database_marketshare_1.html
Interesting to see that database sales for windows is more than
Unix.
|
by: Ashura |
last post by:
H
I want to make a project where one or more object could be shared between 2 applications
For example : the first application create a connection to a web-service, this connection is stored in an object (through a service perhaps). A second application is launch and I want this application, use the same connection as the frst one (so retrieve the object where the connection is stored)
Any idee of th process ??
I think I need to...
|
by: Macca |
last post by:
Hi,
I have a C# Solution/Application that contain 4 projects.
Each of these projects needs at some time to access the same database.
I would like to know how to share a single connection between these projects
as i assume this would be more efficient than having a separate connection
string for each project.
|
by: Tony Fonager |
last post by:
I am currently developing a statistics system in ASP.NET, and need to share
information about the customers websites, in this application.
(I have simplified my code, to make my project easier to explain.)
The simple version of the system is like this : A customer inserts HTML code
on his webpage, which contacts my statistics server each time the customers
website recieves a hit - like a classic "register website traffic" system.
...
| |
by: Joe |
last post by:
I have an application which runs in a non-secure environment. I also have an
application that runs in a secure environment (both on the same machine). Is
there any way to share the session data for this?
Most of the site allows the user to add things to a cart (non-secure), once
they choose to check-out, I need this information which was stored in the
session to be read by the payment page(secured).
Hope this makes sense. It's probably...
|
by: tendim |
last post by:
G'day group.
Currently our organization us using VB6 based applications, and I am
trying to push forward and migrate some of the smaller things to
VB.NET, eventually migrating all applications from VB6 and other legacy
languages/systems (Pure VBScript, DataEase, etc.) over to .NET.
Currently, *all* user data is stored on network shares. When a user
logs in to a workstation, their home drive is mounted from one share,
all of their...
|
by: Nayana Thara |
last post by:
We have a web site where we have asp and asp.net.
how can we share session data b/w the two environments.
|
by: Immortal Nephi |
last post by:
First class is the base class. It has two data: m_Base1 and m_Base2.
Second class and third class are derived classes and they are derived
from first class. m_Base1 and m_Base2 are inherited into two derived
classes.
Second class has its own m_Base1 and m_Base2 and third class does the
same. I am curious. How can second class and third class share the
same m_Base1 and m_Base2?
You define second class first and enter data into...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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 we have to send another system
| |
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...
| |