The extra-credit is only if you want more points and are having too much fun..
EXTRA CREDIT 1:
But since python has the GIL, this will block any other IO from happening. Thus let us run all distance calculations in processes. Thus, let each thread in the server have access to a co-processor pool (see http://chimera.labs.oreilly.com/books/1230000000393/ch12.html#_discussion_204) and note you will have to hand the two time series (one the incoming and two the one from the db) over to a process in this pool.
EXTRA CREDIT 1: even more credit
Now, take your code to insert a time series and to create a vantage point and encapsulate these into functions which can be run in threads as well. Each new time series insertion should trigger a process that computes its distance to all vantage points. This should happen in the process pool. (Similarly each new vantage point insertion should trigger computing distances to all time series and these two operations should not happen simultaneously. We will, for simplicity in this project, assume that only the initial vantage points are allowed.)
You can choose between the below two electives.
The extra-credit is only if you want more points and are having too much fun..
EXTRA CREDIT 1:
But since python has the GIL, this will block any other IO from happening. Thus let us run all distance calculations in processes. Thus, let each thread in the server have access to a co-processor pool (see http://chimera.labs.oreilly.com/books/1230000000393/ch12.html#_discussion_204) and note you will have to hand the two time series (one the incoming and two the one from the db) over to a process in this pool.
EXTRA CREDIT 1: even more credit
Now, take your code to insert a time series and to create a vantage point and encapsulate these into functions which can be run in threads as well. Each new time series insertion should trigger a process that computes its distance to all vantage points. This should happen in the process pool. (Similarly each new vantage point insertion should trigger computing distances to all time series and these two operations should not happen simultaneously. We will, for simplicity in this project, assume that only the initial vantage points are allowed.)