Search code examples
entity-framework-4benchmarkingredisdb4oobject-lifetime

What is the best object lifetime strategy for Redis in web application


  • I will plan to use Redis (ServiceStack) as whole database for web application.
  • I can insert 76000 records in 7.4 seconds.
  • But using single connection (RedisClient object-life-time is Application),
  • I used Set generic method not Store (huge performance difference)

I had used Per-Request object-life-time for Entity Framework ObjectContext.

So what is the best strategy for object-life-time in web application (Asp.Net MVC) for Redis (ServiceStack)..

Or Redis is not mature project for 100 Sql Server Tables (related to each other in various)

I'm totally confused.. I'm thinking to store entities in DB4O (I'm scare 'DB4o is Embedded-Java Db' slogan also ), relations in Redis ?!

And to support Include Concept in EF4.

My total project will have 1.000.000 entities, 100.000.000 relations ! (I have 3 years Entity Framework 1-4 experience)


Solution

  • The ServiceStack Redis Client includes 2 Thread-Safe Connection managers:

    • PooledRedisClientManager - Is the connection pool implementation where RedisClient's are pooled. Recommended when accessing redis-server remotely.

    • BasicRedisClientManager - Returns a new RedisClient instance each time, recommended if redis-server is on the same server as your ASP.NET web application.

    Note Redis is not an RDBMS, it's a data structures server providing atomic access to server-side Key-Values, Sets, Sorted Sets, Hashes and Lists. You need to maintain your own relationships using Custom Indexes you can see an example of this in the source code of the RedisStackOverflow demo application.

    You should also check out Designing a simple blog application with Redis.

    Otherwise the ServiceStack C# RedisClient wiki is the best place for documentation on ow to use the C# Redis Client.