I am building a process for launching user built queries (business rules) using Scala-Spark/SQL. One of the requirements is that if the SQLs perform slower than expected (every rule has an expected performance (time in seconds) attribute), I need to flag them as such for future references, as well as kill the long running (slow) process/job,
So far I am thinking of the following approach -
- Start timing
- launch job in a scala future - thread
- wait for time for the job
- if the thread hasnt completed in the time expected kill the job and report it as a slow process
I am concerned that I am fiddling with the distributed nature of the job. Another concern is that, for my "job" (that of running that query), spark internally will launch an unknown number of tasks across nodes, how will the timing process work, what kind of actual performance shall be reported back to my program!!
Suggestions please..