views:

25

answers:

2

I'm currently developing a WCF REST Web Service that will be running on Microsoft Azure. To limit the number of requests per IP address to prevent abuse, I currently store the IP and timeout using the ASP.NET Cache.

This method works great but since muliple VM instances with Azure don't share a single cache, the requests could be split between different VMs and be cleared if a VM is reset.

I don't think this is a major problem but since I already store user info in a SQL Azure database and authenticate users using the WCF service, would I be better off using the database instead of the ASP.NET cache?

Any adive would be really helpful.

+1  A: 

You have to decide when the threshold is acceptable.
Data from cache will be faster, but there's a risk it doesn't represent actual current data. Where fetching data from the database is fresh, but it takes time to make the trip to the database and back.

OMG Ponies
Thanks for the help.
Bram
+1  A: 

What about using a hybrid approach? You could store it into the SQL database in addition to putting it in your cache. Then when they hit a different instance it is put into the cache with the time that was stored in the database. Minimizes round trips to the database, and makes the information available to all of the servers.

Matt
Thanks for the idea.
Bram