Dynamic Replication Based on Availability and Popularity in the Presence of Failures