Project checkpoint: AWS spot market simulator

I’m currently working on a very basic spot market simulator for testing various spot market strategies. I initially thought that this would be pretty simple but it turns out it’s not so simple mostly because programming languages are terrible at expressing transactional semantics of high level state machines. Let me try to elaborate.

Update: I’ve now written a simulator that can be used for testing bidding and control strategies without having to pay for actual server time.

From a very high level the spot market is some function of current available capacity and current request volume. Concretely, if there are 1000 units of something available out of 3000 then one would expect the price to be proportional to some function of available vs total units. You could get fancy and do even more clever things but that simple strategy should be sufficient for everything that follows. Once you have the pricing strategy figured out the rest of the simulation comes down to managing queues of requests. Clients send the market requests that is basically a tuple consisting of requested units and the price the client is willing to pay for those requested units. The market then takes this request, does some internal calculation and decides whether to fulfill it or just leave it hanging.

The request accounting is again easy to describe from a high level. If there is enough capacity and the request is above the current market price then fulfill the request at the current market price and increase the market price. If there is no available capacity then we go hunting for existing requests that could be booted out and their resources freed up to fulfill this request. This is where it gets a little tricky because it turns into a form of bin packing. From the market operators perspective we would like to optimize profits so it’s not enough to boot existing clients until we have free capacity. We have to be selective about how we boot clients in order to maximize our profits as market operators and at this point our decision making starts to feed back into the pricing strategy because if we are going to boot a set of clients to fulfill another request then we have to make sure the money we would have made from those clients is less than the money we are going to make from fulfilling the request for the new client. This is where I’m currently stuck because it is not clear to me how to best simulate this. I might not need to address this concern but it would be nice if there was an elegant solution.