Feature/delete service stats worker jobs#73
Conversation
|
There are mainly 2 aspects of this PR that I think should be addressed before merging. The first one is that there are no tests. The second one is that, in my opinion, the responsibilities of the 2 types of jobs (
Wouldn't it be better to generate all the keys in the Generator job and just pass X of them to each of the Delete jobs? That way, the jobs would not perform any duplicated work. Also, I think that conceptually it would be easier to understand, because one job type would be responsible for generating all the keys, and the other just for deleting the keys that it received. |
|
The design was made to avoid serializing/deserializing to/from redis all the keys that have to be deleted. You are proposing to do that. Besides, resque job size (basically json body size) can be big. The body size is controlled by The trade off is
Other implementation would be passing indexes besides jobs, and eraser worker will only have to generate required keys, hence no duplicated work. Resque jobs would be small in size and no keys would be serialized to redis. However the implementation of indexes increases complexity of the key generator and I decided to leave it for now. Maybe future improvement. WDYT @davidor ? Can we afford big jobs and serializing all the keys including them in job bodies? |
80526e4 to
f6e960c
Compare
|
Implementation of |
|
Serializing/deserializing could be a problem too. This is the kind of thing that needs to be measured. What if For example, if we need to delete a whole year of stats, we could generate one job for each month, or for each day. Not sure what would be the most appropriate granularity. Or maybe split by apps or metrics? |
|
Partitioning by time, applications, metrics or users is rough way of partitioning. You cannot control the number of keys received by a worker to be deleted. With the current implementation, the size of a partition is controlled by a configuration parameter. Anyway, it is a partitioning, yes. We could leave it like it is now and write an issue to implement indexes. WDYT @davidor ? |
f6e960c to
5f642f1
Compare
…ON_BATCH_SIZE config params
6b0dbd7 to
800b26c
Compare
29cb976 to
80d8627
Compare
|
@davidor ready for a review |
|
|
||
| stats_key_gen = KeyGenerator.new(job.to_hash) | ||
|
|
||
| stats_key_gen.keys.drop(offset).take(length).each_slice(configuration.stats.delete_batch_size) do |slice| |
There was a problem hiding this comment.
I'm still not convinced about the idea of generating the whole set of keys on every PartitionEraserJob. It'd be good to hear other opinions on this. @unleashed ? @miguelsorianod ?
This might be good enough for a first version but we'll need to closely measure the impact on CPU time consumed by this kind of worker with something like stackprof. It's difficult to tell now because there are many factors that can have an impact like number of this kind of jobs generated, the average from-to interval, etc.
At least we should add a TODO here explaining what this does and mention that this is probably something that could be improved.
There was a problem hiding this comment.
isn't just a subset of the keys generated/removed (length) ?
There was a problem hiding this comment.
it is generating all keys up to offset + length.
I will write an issue about improving the algorithm to use indexes.
Deleting service stats is not a job that will be created often
There was a problem hiding this comment.
Only a subset is deleted, but all of them are generated stats_key_gen.keys.
There was a problem hiding this comment.
👍 , I was thinking on the old implementation, when enumerators were used and not all keys were generated.
…spec_helper: improve tests
|
Good job @eguzki 👍 |
Stats::PartitionEraserJobBackground job to delete stat keys
Stats::PartitionGeneratorJobBackground job to generate
Stats::PartitionEraserJobfor each stats keys subset