I recently started hosting a side project on a new Azure VM. The application uses Redis as a cache in memory. Everything worked fine in my local environment, but now that I have moved the code to Azure, I see some strange exceptions coming out of Booksleeve.
When the application starts everything, everything works fine. However, after about 5-10 minutes of inactivity, the next application request raises a network exception (I am working now and do not have exact error messages, so I will send them when I get home if people think that they are related to the discussion). This closes the internal MessageQueue, which causes each subsequent call to Enqueue () to throw an exception ("Queue closed").
So, after some googling, I found this SO post: Maintaining an open Redis connection using BookSleeve about the DIY connection manager. I can, of course, implement something like this if this is the best course of action.
So the questions are:
- Is it okay for RedisConnection to periodically close after a certain time?
- I saw the
conn.SetKeepAlive()
method, but I tried many different values, and none of them matter. Is there more to this, or am I barking the wrong tree? - Is the idea of โโthe connection manager from the post above to deal best with this scenario?
- Can anyone shed more light on why placing my Redis instance in the new Azure VM is causing this problem? I can also confirm that if I ran my local environment against the Azure Redis virtual machine, I ran into this problem.
As I said, if it is unusual for Redis to die after inactivity, I will send stack traces and exceptions from my logs when I get home.
Thanks!
UPDATE Didier noted in the comments that this could be due to the load balancer that uses Azure: http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/12/windows-azure-load-balancer-timeout -details.aspx
Assuming the case, what would be the best way to implement a connection manager that could explain this problem. I assume that I should not create the connection per unit of work correctly?
source share