Enyim memcached provider cpu spike

I have implemented a caching and memchanged provider interface for our site using enyim. Works great in testing until we load the test, where it downloads the w3wp.exe processor to almost 100%. We have a configuration property to switch the caching provider back to the dotnet API, and the processor returns to 5-7%. Has anyone experienced this?

+3
source share
2 answers

Each time you store something in memcached via enyim, the .NET runtime will binary-serialize the stored object. And deserialization upon receipt. For some types (string, byte [] and some others), enyim implements a more specific and easy serialization, but most types are serialized with the standard BinaryFormatter. This is the processor intensity.

This is especially painful when your code is written in memory cache in ASP.NET. You will probably have a code that believes that getting something from the cache is free. You can get it from the cache again and again and again. We had comparable problems when we switched to memcached. If you do profiling, you will probably find that you are doing insanely many reads from the cache.

enyim . memcached ASP.NET 10 . ( ) in-memory ASP.NET.

+4

.

w3p.exe, 99% , , Enyim/Membase, . , , Dispose() MemoryStream Deserializing JSON JSON:

   public static T DeserializeToObject<T>(this string json)
    {
        byte[] byteArray = Encoding.ASCII.GetBytes( json );
        MemoryStream stream = new MemoryStream( byteArray );

        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
        T returnObject = (T)serializer.ReadObject(stream);
        stream.Close();
        stream.Dispose();  // we forgot this line!
        return returnObject;
    }
0

Source: https://habr.com/ru/post/1712692/


All Articles