for i in {1..2000}
do
time curl localhost:8000/api/v1/job/ -d '{"command": "echo cool", "name": "test_job", "schedule": "R/2017-04-011T11:11:11-07:00/PT10S}'
done
Then continue to add more jobs in smaller increments. From time to time, a request would take >2s to complete.
I created a jobdb with a few thousand entries.
Then continue to add more jobs in smaller increments. From time to time, a request would take >2s to complete.
I tracked the issue down to Persist holding the lock for an extended time. So, I started looking for a way to remove the locks. To solve the problem, I implemented a
FreeJobCache
that uses a thread safe, lock free hashmap: https://github.com/gwoo/kala/commit/a458d4c06c4a3552e550fdfeae7e7e2fc1a3d5edYou can also see, I modified the rest of the source to use the FreeJobCache. All the tests passed, so this seemed like a good change.
Probably the best thing to do would be to modify MemoryJobCache with the code from FreeJobCache. I can work on a PR if that you are interested.