0

I'm working on a website that has a fairly good size database that is stored in memory. Because I don't yet understand how to do it otherwise, when the page is accessed, the database is read and certain data is stored in memory for faster performance while the user is on the page. What I don't like about it is the delay during the initial rendering of the page.

I'm sure there is a way for the data to be maintained in memory when that particular page is not loaded, but I don't know how to do it and I have not had any success yet using Google University (search). Can anyone recommend a link or search terms that will help me find out what I need to know?

Thanks all.

2
  • Is what you are wanting similar to my post here stackoverflow.com/questions/18337112/… Commented Aug 30, 2013 at 17:09
  • Well, I haven't used MVC. My site is a Web Forms application, and the database will never change. Commented Aug 30, 2013 at 17:27

1 Answer 1

1

Store it in the Cache. You're still going to run into an issue of first-load slowness as it reads from DB and into Cache, but that's impossible to avoid. You can put it in the Application_Start event to guarantee it happens the first time the app is loaded.

http://msdn.microsoft.com/en-us/library/dd997357.aspx

Sign up to request clarification or add additional context in comments.

7 Comments

When you say first load, do you mean initially for the first time when the application is run, or every time a new user visits the site?
I mean every time a new user visits the site. The database is loaded into a trie collection when the Page_Load event is called.
If the result is different for every user, you could load all the relevant data in memory (assuming it's not millions of rows) and then query it in-memory for the user-specific data. Alternatively, you could attempt to speed up your DB by adding indexes on the columns in your where clause.
The data I need to persist in one form another (cache sounds pretty good) is a word dictionary used for reference only -- it will never change in this particular usage.
Then just load it up on Application_Start. It'll be slow for the first user of the site and then fast. If your app isn't often-used, you can change the App Pool Recycle from the default 20 min to something longer (once the app is recycled, your cache goes, too).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.