I am developing a PaaS. The application will be hosted in Azure websites. Currently I am using EF / SQL as a datastore with in memory caching. I was planning on using the Azure Reddis Cache if the application grows and I need to share this cache across multiple instances.
As I looked more into reddis I started to like what I saw. It was really fast and perfect for a number of my domain objects. My logging model for instance. So now I am wondering, can I use Azure Reddis Cache as a primary data store ?
The word Cache in the name has me concerned. Is the data purged when not being used?
Application
The app is a MVC5 app. It includes a HtmlController administration section but the meat of the work is in an ApiController. The ApiController will serve mostly OData Get's, but I will have my share of PUT requests as well. I bill by request, so all user actions must be logged (a perfect job for reddis).
My model has three objects and no relations. User's which is used infrequently for authentication. Logging which is 90% put 'fire and forget', and Storage which is partitioned by 'app key' and 'group key'. Storage 'sets' will be requested and the Odata verbs will be applied manually in memory.
Would Azure Tables would be a better solution?
CodePudding user response:
You could use Redis as a primary data store but there is always a small risk of data loss, between the time Redis receives data and by the time it tries to write it to the AOF file. If during that window, the instance dies, you'll lose that portion of the data.
Having said that, there is no clear indication if Azure Redis Cache does background saves or not (in simple words, writing to the disk). If they don't then everything stays in memory on the servers, meaning if you lose all the servers, you lose all the data. Losing all the servers is an highly unlike scenario, but still possible.
Until there is further information, I would go with the assumption that data can be lost from the cache (volatile) and have another type of data store (e.g. SQL as you do now) to be safe.
UPDATE: Redis Cache does not have persistence enabled, so the original assumption was correct.
CodePudding user response:
Here is an interesting post about disadvantages of using MongoDB as primary source instead of relational database.
I think most of conclusions take place in your scenario as well.
Most important issue - if you need or will need in future to find connections and relationships between data, calculate metrics and extract business values from data, then using solutions like Redis could cause problems, because they designed to store and retrieve SINGLE values, without relationships to other data.