I thought asp.net would recycle what it needed to. Is the best solution to just thro more RAM at it? Thats what I plan on doing, but its going to take a few days to get the server up and running and need a solution in the meantime. Also I am worried what is going to happen when I have my server maxed out on ram usage and I get this error
thanks for any help
mike123Are you setting any priority on the cache items when adding them? Reason I ask is that if everything is being set to "high", it may not be recycling anything w/ the garbage collection.
Also, when you add things to cache, are you checking to see if they already exist or possibly even deleting the old cache before adding it again?
Are any of your caches set to time out (I would think so).
If your cache is too broad, I can see this being a problem. If you are caching a search page, it would be very possible for you to hit the limit of your RAM.
Charley.
I am not setting priority on anything, not high or low. Here is an example of how I cache my dataset. I'm not sure about deleting the old cache before adding it again, because I dont think that happens since I check before I add, please correct me if im wrong on that.
Also, Charley I believe you may be exactly correct on the searches taking all of my memory, I am looking at making them expire quicker and setting their priority low. Is this what you would recommend? How would you modify this function?
Thanks alot
mike123
Public Function QuestionsGet(ByVal userID As Integer) As DataSet
Dim myDataSet As New DataSet()
If HttpContext.Current.Cache.Get("select_questions" & CStr(userID)) Is Nothing Then
' Create Instance of Connection and Command Object
Dim objConn As New SqlConnection("uid=")
Dim objCommand As New SqlDataAdapter("select_questions", objConn)
' Mark the Command as a SPROC
objCommand.SelectCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim parameterUserID As New SqlParameter("@.userID", SqlDbType.Int, 4)
parameterUserID.Value = userID
objCommand.SelectCommand.Parameters.Add(parameterUserID)
'Fill the DataSet
objCommand.Fill(myDataSet, "select_questions")
HttpContext.Current.Cache.Item("select_questions" & CStr(userID)) = myDataSet
Else
myDataSet = CType(HttpContext.Current.Cache.Get("select_questions" & CStr(userID)), DataSet)
End If
Return myDataSet
End Function
Tell us a bit about what you are trying to accomplish.
What type of data are you returning?
I see 'questions' based by the user Id.
Are these very static?
If so, a different way to approch this might be to generate an XML file durning a nightly batch, and instead of reading the DB, read that file instead...
They are fairly static I have probably 20k cached, but not static enough to do a nightly update I believe. I have at least a few hundred changing daily. They are directly tied to users info, I have cached each users info. The data is about 8 text strings shorter than 500 chars.
Thanks for the suggestion, but I dont think it will work in this case. What do you think?
Also, I am attempting to add ", Caching.CacheItemPriority.Low" to my cache statement, but its not accepting the final argument. Am I approaching this wrong?
Thanks again
mike123
anyone? I'm still getting this error and have no idea what to do! :(
thanks again
mike123
Mike.
I'm just throwing out ideas here...
Instead of caching the datasets, have you tried caching the page itself?
Some other options are (Not saying these are the BEST options, but options nonetheless):
- Disable caching until you get more RAM
- Reevaluate queries and see if you can combine anything
- Reevaluate your architecture so that you aren't as database intensive on any given page
Are your pages hitting directly against the database?
Charley,
Unforunately I can't output cache the page, because I need to manually expire it when certain occurances happen. One page in particular has 4 queries, and is being hit about 1 million times per day, so if I lose the caching my database server is going to have soem seroius extra load on it. I would love to get more RAM, however I need a scalable solution and I dont want the same thing to happen when I max out on my new server with 4gigs instead of 2.
Thanks for the input
mike123
4 million queries a day... yowsers...
What the heck kind of app is this?
Have you done performance monitoring on the SQL server?
If you have caching off, does it peg that server?
It's a web app where users have their own personal page, that is database driven. Yes, it sure does peg the server if I turn caching off so I really appreciate the caching. It just really sucks to have it crap out when it runs out of memory, I thought asp.net would be a little better at handling it.
I can upgrade to 4 gigs, but thats just a temporary solution and its goign to cost alot of time / money.
Thanks
0 comments:
Post a Comment