Re: Architecure Question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello M.

I'll try to answer your question, but there's not a lot of detail there
about the business problem you are trying to solve.

"Muckeypuck" <BlahBlahBlah@xxxxxxxxx> wrote in message
news:aq%Cg.129$xk3.52@xxxxxxxxxxxxx
Lets say i had two classes, user and customer that represented tables in
the database with 7 or 8 fields max. Lets say that instead of passing an
id around hitting my database any time i needed information from those 2
tables, i just made those two classes serializable and passed them around
in a session object.

Is this a good idea? Is it scalable if the app were to host 1000000's of
users at once? Will it perform well?

There is nothing wrong with using the Data Transfer Object pattern to move
data around. Keeping a bit of data in the session is essentially the same
as placing it in a cache object that you can access later.

Normally, you want to place things in the cache that ALL of your customers
can use. For example, let's say that you have a set of canned reports that
you can make available to your customers. Keeping the names of the reports
in the cache is useful because you may need to fill a navigation list or
drop-down box in 100 page requests in the same second and making a bunch of
database requests may not be terribly efficient.

On the other hand, if you place things in the cache that are likely to be
specific to the user on your site, you run the risk of blowing your cache up
to a very large size. That will CERTAINLY affect throughput. Realize that
the session object tends to hang around a while after the user has actually
left, so if you have 60,000 users per hour, you need to be able to hold data
for 20,000 of them at a time.

You also have the problem of making your session objects available across a
web farm. (at the rate of 60K users per hour, you will have a LOT of web
servers). Realize what this means... the web server servicing the request
does not actually have the session object. It has to contact another server
to get it. That other server has to use an ID to look it up. If there is a
lot of data in the cache, it will store things on a hard drive in a system
known for fast lookup (like, for example, SQL Server). The data will be
found and transmitted across your internal network back to the web server.
Sounds like a db lookup, doesn't it? Not really a good tradeoff to try to
avoid hitting a database by putting things into a cache that is backed up by
a database.

In a normally stateless environment, it is rare to see the need for placing
a customer or user object in the session. I'd leave the data in the
database between requests. No harm in bringing the data into a singleton
during the request processing, so that multiple classes can access it.
Wouldn't use the session for that, though.

I hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--


.



Relevant Pages

  • Re: Good Idea for WebService ?
    ... go, If the cache was local, they would all have different counts, and if I ... hit the database every request it will get too much traffic (about 220 ... > see each update immediately on the web server, ... > each web server have its own cache. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Speeding up Sql Server
    ... Not all queries will run faster the second time you run them. ... With only 2GB database ... chances are you will cache most of the data very quickly. ... > we have a large customer installation with 8 application servers running metaframe on Win 2003 server against a database server with Win 2003 server running MS Sql server. ...
    (microsoft.public.sqlserver.setup)
  • Re: a question on synchronizing distributed servers
    ... --Each server forwards its received add/get message to the Database, ... stores the data in its cache as well as into the database. ... Thanks for the response. ...
    (comp.os.linux.development.apps)
  • Re: Cant make write cache stay on
    ... > the controller bios for a write cache option. ... Very few drives these days dont. ... I upgraded from NT to Win2k Server, ... thats where I installed the AD database. ...
    (microsoft.public.win2000.registry)
  • Generic list stored in session....??
    ... My webpage has a GridView showing rows from a table in the database. ... these rows are stored in the session object -> what's actually stored is ... When using cache it is possible to ...
    (microsoft.public.dotnet.framework.aspnet)