Spring 2008
Programming Assignment 2: Spring Break Sale at Pygmy.com
Due: April 3, 2008
Pygmy.com is celebrating it's one month anniversary since launching it's online bookstore. During Spring Break, it is offering every tenth customer a 10% discount coupon for a book of their choice.
Also, since they expect their sale to be a wide success, they have added capacity to their store by replicating the front-end tier. Any customer can contact any of the k front-end replicas with their requests. The back-end database is not replicated and, like before, each front-end must contact the back-end database server to process requests.
This assignment has two parts. Each part uses a different set of techniques to solve the problem of issuing discount for every tenth customer.
You can be creative as to when elections are triggered. For example, the leader can resign at any time and another time server will need to be chosen.
Every incoming request at each front-end replica is timestamped with the syncronized clock value; this time stamp is relayed to the database server for buy requests. The time stamps are used to determine an ordering of buy requests and every 10th buy request is automatically given a 10% discount (by charging a lower amount for the requested book.
To do so, each client process and each front-end server maintain logical clocks. You can either use Lamports clocks or vector clocks for this purpose. Pick either the totally ordered multicast or causally ordered mutlicast algorithm to determine an ordering of all requests made by the clients to the Pygmy.com front-end servers. Note that in this case, requests must be multicast to all processes, in addition to being sent to the front-end server that will process the request. You are free to design the system with either algorithm.
Use the logical clock values to determine the odering of buy requests. Again, every 10th buy request gets a 10% discount on the book being purchased.
A pictorial representation of the system is shown in the figure below:
Make necessary plots to support your conclusions.