Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume memory & disk overflow queues in order #30

Open
david-eckardt-sociomantic opened this issue Feb 15, 2018 · 2 comments
Open

Consume memory & disk overflow queues in order #30

david-eckardt-sociomantic opened this issue Feb 15, 2018 · 2 comments
Assignees
Milestone

Comments

@david-eckardt-sociomantic
Copy link
Contributor

david-eckardt-sociomantic commented Feb 15, 2018

Some applications need the records to be in order. The current disk overflow push strategy can change the order dramatically. The current strategy is to

  • try pushing the record to the memory queue,
  • if the record does not fit, push it to the disk overflow instead.

The pop strategy is the same - try popping from the memory queue, if it is empty, pop from the disk overflow.
With this push strategy records can be pushed in the memory queue when a disk overflow is present, and these records will be popped earlier than the records in the disk overflow that have been pushed earlier. The order of records can be preserved by changing the the push strategy as follows:

  • If there is disk overflow, push the record to it.
  • If not, apply the above strategy.

That way, if there is a disk overflow, it will contain the most recently pushed records while the memory queue will contain the least recently pushed records -- the records stay in order.

So the way how pushing is carried out determines the order in which the records are popped. Looking at pushing and consuming application a problem arises here: It is the consuming application that cares about the order, the pushing application doesn't and shouldn't need to.
The proposed solution is to extend the Consume request with a flag determining the push strategy. The first consumer that subscribes to a to a DMQ channel requests the push strategy for that queue. Subsequent consumers are expected to request the same push strategy or the Consume request fails with an error for them. This is feasible because multiple consumers using the same subscriber name for the same channel are expected to be instances of the same application and therefore require the same push strategy.

Another problem is what happens if a queue (i.e. channel with or without subscribers) is created but the push strategy is not know at that time.

  • If a Push request creates a new channel, the push strategy doesn't matter because records are anyway pushed to the memory queue first, then to the disk overflow, so they stay in order. The push strategy does matter only after the first consumer has started consuming, popping records from the memory queue.
  • If the DMQ node starts and creates a channel from a memory dump without disk overflow data present, the situation is the same as in the previous point: The push strategy matters only after the first consumer has started consuming. That means that the push strategy does not need to be stored in the memory dump.
  • If the DMQ node starts and creates a channel where disk overflow data is present, the push strategy needs to be known: If the memory queue is not full and a record is pushed before the first consumer has started consuming, it must be know whether this record should go in the memory queue or the disk overflow.

So the push strategy needs to be stored in the disk overflow index but not in the memory dump.

Finally there is still the Pop request. For now there is no need for any application that uses Pop to pop records in order so we can ignore that.

@nemanja-boric-sociomantic
Copy link
Contributor

Would the permanent change of the push strategy be bad?

@david-eckardt-sociomantic
Copy link
Contributor Author

Would the permanent change of the push strategy be bad?

Yes, it would be for some of the consumer processes in our system which need priority for live traffic.

@gavin-norman-sociomantic gavin-norman-sociomantic added this to the v1.9 milestone Feb 15, 2018
@gavin-norman-sociomantic gavin-norman-sociomantic modified the milestones: v1.9, v1.10 Feb 27, 2018
@gavin-norman-sociomantic gavin-norman-sociomantic modified the milestones: v1.10, v1.11 Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants