openwhisk icon indicating copy to clipboard operation
openwhisk copied to clipboard

Move concurrent activation information from consul to controller

Open perryibm opened this issue 10 years ago • 6 comments

Currently, the controller writes out the number of completed activations (per use) and so does every invoker. This creates a lot of continuous traffic on consul and I believe can cause latency issues. Now that active ack is in place, the invoker can stream back completion as they occur instead of writing a large piece of information for the state. This has the benefit of reducing traffic, making consul healthier, and centralizing information in the load balancer.

@jeremiaswerner As discussed before, we want to reduce consul traffic. The proposal that @rabbah and I arrived at is the following. @ChrBi @markusthoemmes Any thoughts?

  1. The controller extends the outstanding activation map to include non-blocking as well as blocking calls. Both types are already part of the active ack from the invoker so no work needed there.
  2. A secondary map based on user id can then be maintained in the controller giving the number of concurrent activations. This also optimizes the responsiveness of the throttle because the load balancer immediately has information to this rather than enduring consul latency.
  3. The N invokers no longer writes any such information to consul - thus greatly decreasing the load. The controller only writes the digested information (queued activations per user) to consul. This also improves monitoring.
  4. As a future option, centralizing the notion in the controller also allows the creation of an admin endpoint that would allow manual un-wedging of a user.
  5. RAS: This is the hard part. What if the invoker's active ack fails? From the controller's perspective, an activation was issued but it did not hear back. This will be rare but we must be robust against this. Also we must consider the case when the invoker is restarted.
  • Initial idea. Use the global action timeout (or some factor thereof) as a proxy for when the invocation has already been completed. This is no worse than the existing system in that we could fail to write to consul and have the same issue. However, repeated lost acks can cause unbounded queue growth so we don't like this.
  • New idea. Use a revised version of the original protocol. We extend the active ack with a count for actions completed for that user as well as an indication of invoker restart by adding the timestamp for when the invoker started. Since there is a count reported, a few active ack will not affect the cumulative count. If the timestamp varies indicating a reboot, we reset the count for that user+invoker pair.

perryibm avatar Aug 02 '16 18:08 perryibm

Additional benefit: The monitoring service does not have to fetch a huge volume of data repeatedly which probably is also hurting consul currently. Since the controller will reflect its view of concurrent activity, this can be used by the UI directly and we can avoid logic getting out-of-sync.

If we do this, I think it should proceed in 3 phases:

  1. This first step should immediately make things better. Decrease the frequency of consul updates by the invoker so we have some breathing room. Since we don't want extra connection and also don't want health updates to be slower, we can simply do the per user count writes on every other iteration of consul posting while doing health updates on every iteration.
  2. This creates the appropriate abstraction for the monitoring service. Have the controller put into consul its view of concurrent activity. The monitoring service should look only at these values and not at the old controller values and not anything from the invoker.
  3. Intermediate step to confirm that adding 2 extra (small) fields will not impact performance Extend the active ack with the additional fields as outlined in "New idea" above.
  4. Cutover to new logic and decrease consul traffic Change the controller to use active ack and maintain the new maps and no longer poll consul for invoker information. Delete the posting of per counts by the invokers.

perryibm avatar Aug 02 '16 21:08 perryibm

Steps 1 and 2 are completed. Steps 3 and 4 will probably be done in parallel so we can start reducing consul load as there is evidence that occasional lags and slow performance in the invoker and loadbalancer is resulting from consul overload.

perryibm avatar Sep 27 '16 22:09 perryibm

@perryibm wrt. monitoring, I'am wondering if we might want to write log's for the queue length by using markers, i.e. if the controller calculates the overall queue length for the throttles it could just write a log. We could then directly gather the monitoring information out of the logs, rather than querying consul from the monitoring service. @cbickel what do you think?

jeremiaswerner avatar Sep 28 '16 12:09 jeremiaswerner

Either way is fine with me once we complete the existing items.

perryibm avatar Sep 28 '16 17:09 perryibm

We'd need to add statsd-gaiges to the markers. But I can have a look a it in the next days.

cbickel avatar Sep 29 '16 06:09 cbickel

The invoker no longer writes activation counts (global or per subject) nor does the controller read this of course. Instead, the controller maintains the state and publishes the digested information for the monitor to read by using the activation maps it maintains. This hugely reduces consul traffic volume taking it down by a factor of however many users have ever run an activation since deployment.

perryibm avatar Oct 27 '16 15:10 perryibm