tags:

views:

45

answers:

2

Hi,

I added memchached to my website. And site started running very slow. If I cancel memchached ,application backs to work quickly.

Why is this happening?And how to avoid it?

Thanks, kukuwka

A: 

That is impossible to answer without knowing how you are using it and what data you are storing. For example, if you are using it as the HttpCache provider (if you are using ASP.NET), and you were previously using the in-process cache provider, then it will behave very differently; the in-process provider has no serialization or network costs, so you might be storing some insanely large objects in the cache. That is fine when it is in-process, but for any other provider this is very very bad; you will have to transfer and deserialize for every usage (and serialize and transfer for every storage).

There are ways to improve the serialization/deserialization/network times, but it sounds like you are simply storing too much data (or inappropriate data) in the cache at the moment. I'd address that first, and then look at tuning it.

Marc Gravell
What does this mean " inappropriate data"?I'm storing only serialization data.What limit of storing data?
kukuwka
@kukuwka - well, how *big* is it? Storing a complete `DataTable`, for example, can be surprisingly expensive. Storing very specific, tightly-scoped data should be fine though.
Marc Gravell
Don't forget it has to go over the wire each time you ask for it... (unless you double-cache)
Marc Gravell
Ok,thanks.I'm really storing a complete DataTable.
kukuwka
@kukuwka - I had a hunch ;p
Marc Gravell
A: 

Memcached doesn't mean "make things faster." It provides fast and very scalable access to a shared cache of something that is otherwise expensive to acquire.

If you add caching to something that's cheap, it may end up being slower.

For example, if it takes you five seconds to do something and you can cache that, then you'll save almost five seconds on each subsequent request assuming the results are still useful.

If it takes you a few nanoseconds to do it, then it'll slow you down considerably to fetch the results over the network.

Dustin
Memcached and application are located on the same server
kukuwka