Principles Of Distributed Database Systems Exercise Solutions

Given:
Three fragments F1, F2, F3; two sites S1, S2.
Read frequencies (per second):

Question: Find an allocation minimizing total cost.

Solution:
Cost for a fragment at site j = sum over all sites i of (read_freq(i,j)*remote_read_cost + update_freq(i,j)*remote_update_cost).

For F1:

For F2: symmetric cost 100 if at S1 or S2 → either site is optimal.

For F3:


Problem:
Social media app: user profile update (need immediate consistency across all followers’ caches) vs. “like” counter (can be eventually consistent). Which replication strategy for each? Given: Three fragments F1, F2, F3; two sites S1, S2

Solution:

Answer:
Profile update → eager replication (strong consistency). Like counter → lazy replication (eventual consistency).


Exercise: Fragment F1: 100 queries from site A, 10 from B, 0 from C. Updates: 5 from A, 20 from B, 0 from C. Cost of remote read=1, remote write=10. Local read=0, local write=0 (costs). Find allocation. Question: Find an allocation minimizing total cost

Solution:

Replication decision: If update cost is low, replicate to A and B to reduce reads. Here updates from B are high (20 writes), so replicating at B and A would increase update cost (writes to 2 copies). So no replication.

Solution Strategy: Compute total weighted cost for each candidate site. Use the formula: Total cost = Σ (reads_from_other_site × read_cost) + Σ (updates_from_other_site × update_cost). Choose site with lowest cost. For F2: symmetric cost 100 if at S1