Closed chris-4chain closed 10 months ago
Welcome to our open-source project @chris-4chain! π
Attention: 44 lines
in your changes are missing coverage. Please review.
Comparison is base (
1d3bbb2
) 53.18% compared to head (12a41f8
) 53.04%. Report is 8 commits behind head on master.
Pull Request Checklist
Initially, the goal of this task was to simplify the taskmanager by fixing taskq and localCron and make some refactorization & simplification changes. All are done:
client
-related names/filenames to more precise ones;With
functional options;Redis
configuration:taskmanager.WithRedis
function;localCron
structure, instead, thegithub.com/robfig/cron/v3
-cronService
is used directly.After my changes, a lot of test files had to be adjusted - that's why so many files are modified.
I tested it locally running different examples and
bux-server
with backend/frontend. Tasks were correctly scheduled.TL;DR
Additionally, I tested the
bux
, running several parallel instances with Redis configuration fortaskq
. Apparently, the codebase before my changes didn't allow to run it that way. So I fixed the issue, according to task-doc, adding:After that, the
taskq
in different nodes (instances) started to communicate via Redis.But another problem appeared. Number of cronJob executions in defined period was about number of active nodes.
In this PR I'm proposing a fix using
distributed redis locks
with TTL.lockTime
period, the job is added to ataskq
queue.Diagrams for better understanding:
Previous solution
New solution
I tested it with 6 instances and collecting local metrics. My example task has
2sec
period and every time it was executed it sent1
(one) to my local influxDB.I analysed the results, grouping metrics in
2sec
aggregation window and then summing the number of points per window.Without cronlocks
With cronlocks
Note:
Of course, the solution can be developed, but, for now:
In the future we should re-think whether using
taskq
is a good idea for us:Maybe a good alternative will be asynq.