What is it?
Rudimentary spot market simulator with an HTTP frontend written in Sinatra.
Why is it?
While working on spotocles I looked around and couldn't find any spot market simulators so decided to take a small detour and write one for my use cases. I'm making it available because it might also be useful to others.
How do I use it?
To start the frontend you'll need npm so make sure npm is installed and then run
npm install bundle rake js:bundle bundle exec ruby app.rb
Make sure you have SQLite installed because the simulation uses an in-memory SQLite database to keep track
of its state. When you are done with the simulation you can flush the data to disk by posting to
You can use the library directly in your own code if you are writing something in Ruby by importing
It is self-contained other than requiring SQLite for managing internal state. If you are writing your spot
bidding strategy in another language then you can use the HTTP frontend and write a small client to drive the
simulation through HTTP. Here are the endpoints you can use to drive the simulation
Returns the list of regions that that have non-zero initial capacity, i.e. these are the regions you can create
instances in by making bids/requests. You can modify the regions and instances by modifying the JSON file
Returns the current capacities for each region. If you want to change the initial capacities then you can post and modify it. Capacities can be mutated at any time during the simulation to simulate addition and removal of capacity.
Change the capacities for each region. This will affect spot prices and can be used for simulating addition and removal of capacity.
Grab the instances and their attributes like on-demand price, vCPU, memory, etc. If no parameters are given then all regions and instance types are returned. If the second parameter is given then only instances in that region are returned. If the third parameter is given then only information for that instance type in that region is returned.
Grab the spot prices. If no parameters are given then spot prices in all regions are returned. If the second parameter is given then only spot prices in that region are returned. If the third parameter is given then only the spot price for that instance type in that region is returned.
Create a request for an instance. Nothing will happen to the request until
/tick is called to advance the state
of the simulation.
Grab the request object to find out its state.
Cancel a request by providing the request ID in the post body as a JSON object, e.g.
Advance the simulation counter and perform any necessary actions to transition the existing requests to their next state along with updating all the necessary internal state and tables.
The simulation uses an in-memory SQLite instance for speed but when you are done with the simulation you can post to this endpoint to dump the in-memory data to disk for analysis. If you don't provide a name of the backup then by default the backup/dump file will be the time when flush was called.