Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2004, 01:29 PM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default Best way to access data.... question

Alright, I've been reading tons of books our company's upcoming project and I am pushing for .NET. Basically i've been granted this request, yay for me! anyways here is my questions.

What is the best way to store/access data.

Scenario:
We have An articles mainpage. It displays 12 articles on the mainpage. This mainpage will receive over 10,000 hits a day, and will have over 1000 unique visitors on at one time.


I've seen about 3 distinct ways of doing this.

1. Basic, always read from the database via datareader and bind to controls.

2. If dataSet doesn't exist, retreive data one time, store in cache and grab from cache every other time.

3. Store information in an XML file, and set the varybyparam to the xml file, so every time the xml file is updated, we update the cached dataSet.

4. Simply store the data in an xml file, and just read the xml data to a dataset and then bind to the controls.

All seem like they have their advantages.

#1 seems like it still is the fastest, but with our site, we will have over thousands of users on at one time so i want to be able to free up system resources for other things.

#2, Seems alright, but for some reasons performance wise doesn't perform as well as the other 3.

#3 seems pretty cool, because it uses all of the .net technology features that are just pretty sweet and does perform better than #2 because in #2 everytime a datasource is updated, then it has to re-update cache and re-query the database instead of just re-reading from an xml file.

#4, is sweet, but i seem to have locking isssues with the xml file. If one thread is updating, and 1 is trying to read, it seems to all crap out. so that's not an option. #3, locks the cache and updates it approprietly.

Is there any other options out there to optimize the performance, scalability, and throughput? If not, which of these do you suggest? all opinions are welcome, if you can please give a good description on why you chose what you did. Thanks alot! I hope this thread will help all people out.

 
Old March 24th, 2004, 01:50 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I am not sure I understand the situation completely. You expect about 10,000 hits, but with a 1,000 concurrent users. So, they all hit the system at the same time, generating 1,000 hits. And this repeats itself 10 times a day? Seems strange....
Or are you talking about a potential of 1,000 users?

Anyway, I'd go for option 2. Storing your data in a database has loads of advantages, including querying, updating, and accessibility by other applications.
Future versions of ASP.NET will allow cache invalidating from SQL Server too. Just point to a table, and your dataset will be invalidated whenever the table changes.
Method two is fast, while you still have a scalable solution. Just invalidate the cache every x minutes, where x is the number of minutes you allow for "stale data" (differences between the cached version and the live database).

If you want, you can even mix 2 and 3 a little. Cache the dataset from the database, and setup a FileDependency. Whenever the backend changes the database, change / touch the XML file as well to invalidate the cache. Not pretty, but it may work.....

Depending on your scenario, option 1 is good too. 10,000 hits, querying 12 articles is not too much work for a database server. It's a query every 5 seconds if you consider a 12 hour use of the application.

But personally, I'd go for option 2. It will be fast, easy to create and deploy, will work in a Web farm scenario, and basically "feels like the right way to this".


I can see you're a good programmer: You even think zero-based:
Quote:
quote:I've seen about 3 distinct ways of doing this.

1. Basic, always read from the database via datareader and bind to controls.

2. If dataSet doesn't exist, retreive data one time, store in cache and grab from cache every other time.

3. Store information in an XML file, and set the varybyparam to the xml file, so every time the xml file is updated, we update the cached dataSet.

4. Simply store the data in an xml file, and just read the xml data to a dataset and then bind to the controls.
;)

Cheers,

Imar




---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 24th, 2004, 02:47 PM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

thank you very much for the compliments Imar. yes sorry for the confusion about the users and what not. Basically we have about 2500 Unique visitors on per hour or so. Yes i figured that option 2 is the best way to go and most commonly used. Next is question is page level caching, i'll create a new post for that one, hope you get a chance to view it!

 
Old March 24th, 2004, 03:01 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I second Imar's suggestions. That is how I have done it. Cache the data. If you can tie a cache dependency to something like a file, then even better, otherwise a timed expiration is usually suitable. (I have heard that ASP.NET resets itself within IIS on a somewhat regular basis, so you might find that ASP.NET will reset, thus wiping the cache clean, before your cache timeouts pass.)

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old March 24th, 2004, 03:16 PM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

Ah yes, Mr. Peter, a person who has helped me alot. Yes I agree with both you and Imar. Not sure yet if i want to do the absolute expiration or the dendency via an xml file. I am thinking XML file because then i won't have to re-create the RSS feed for the main page and kill two stones with one bird.... or the other way around.:D

 
Old March 24th, 2004, 06:53 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ah, that is a very good idea. Make the server cache dependent on the XML file that you use for the RSS feed. You get a file based RSS feed that is built when you update the data that it contains (so you don't have to query the DB every time), but you also get a file dependency for the web cache. That's very, very clever!
 
Old March 24th, 2004, 07:19 PM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

Yes Sir. Peter that works well. Especially for those sites who have rss feeds, you can basically automate that system to drive off of 1 rss feed. I am thinking smarter not harder! The problem i run into randomly is when a process is trying to read the rss feed while another process is writing it. Ever ran into this? I get the run-time error or "This file is being used by another process" and it's just a pain to get it up and running again. any thoughts?

Any locking methods to the extent of this psuedo code:

Lock(MyFile.rss)
' Write stuff to MyFile.rss
Unlock(MyFile.rss)
 
Old March 24th, 2004, 07:20 PM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

I just wanted to drop a side note of thanks alot for your opinions Peter and Imar. You two seem to have a really good handle on .Net, this makes my adventures much more easier!






Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Access: Data Access Page sevp95 Access VBA 0 July 14th, 2008 11:07 AM
Please Help! Ms Access Data Access Pages Iashia06 Access 0 May 4th, 2006 03:29 PM
SQL Access/ASP.NET data access issue saeta57 SQL Server ASP 1 July 4th, 2004 04:29 PM
SQL Access/ASP.NET data access issue saeta57 Classic ASP Databases 1 July 4th, 2004 03:32 PM
Data access page access problem :) kev_79 Access 0 September 4th, 2003 04:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.