Re: How to share objects in an ASP.NET application ???
From: Tony Fonager (tony_at_dontspamthisemailadress_fonager.dk)
Date: 10/19/04
- Next message: Ted Callander: "Re: Auth Problem"
- Previous message: Thomas: "RE: Classes and SQL Database in ASP.net"
- In reply to: Bill Borg: "RE: How to share objects in an ASP.NET application ???"
- Next in thread: Steven Cheng[MSFT]: "Re: How to share objects in an ASP.NET application ???"
- Reply: Steven Cheng[MSFT]: "Re: How to share objects in an ASP.NET application ???"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 00:08:40 +0200
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" <BillBorg@discussions.microsoft.com> wrote in message
news:9C38C478-E04E-43CD-AC42-2FFA97C90601@microsoft.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
> >
- Next message: Ted Callander: "Re: Auth Problem"
- Previous message: Thomas: "RE: Classes and SQL Database in ASP.net"
- In reply to: Bill Borg: "RE: How to share objects in an ASP.NET application ???"
- Next in thread: Steven Cheng[MSFT]: "Re: How to share objects in an ASP.NET application ???"
- Reply: Steven Cheng[MSFT]: "Re: How to share objects in an ASP.NET application ???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|